课程: Test Automation with Selenium WebDriver for Java
免费学习该课程!
今天就开通帐号,24,700 门业界名师课程任您挑!
Implicit wait
- [Instructor] Using WebDriver to interact with web elements is much faster than if you were interacting with those elements manually as a human. Because of this, sometimes the elements aren't quite ready for interaction when WebDriver attempts to engage with them. This may be due to slow loading times or asynchronous calls. For example, if we click this Reveal a new input button, there's a slight delay before the text box appears. If we run this code that clicks the button that attempts to immediately add text to the text box, we'd get an element not interactable exception. Selenium WebDriver provides the ability to set an implicit wait time for all web interactions. Let's add that now. To do so, we can say driver.manage.timeouts.implicitlyWait. Inside of this method, we can specify the amount of time to wait, so we can use the Duration class and say ofSeconds, and we'll specify two seconds to wait. With this implicit wait, WebDriver will continue trying to interact with the element…