课程: Test Automation with Selenium WebDriver for Java
免费学习该课程!
今天就开通帐号,24,700 门业界名师课程任您挑!
Explicit wait
- [Instructor] While implicit waits apply to all WebDriver interactions, explicit waits let you wait for specific conditions only when necessary. Let's say that we want to click this button and then wait until the text box appears before entering any text into it. We can use the WebDriver wait class to explicitly wait for that condition before continuing with the interaction. Let's create a new variable called wait, which is an instantiation of the WebDriver wait class. This constructor accepts an instance of WebDriver and the duration of time to wait for a condition to be met before timing out and throwing an exception, so let's set that to two seconds. We can say Duration.ofSeconds(2). Now with this wait object, we can specify the explicit condition to wait for, which is for the text box to be displayed. So we'll say wait.until, then in parentheses we'll add an expected condition. Fortunately, WebDriver provides an expected conditions class Fortunately, WebDriver provides an…