WHAT IS EXPLICIT WAIT IN SELENIUM WEBDRIVER?

Explicit Wait is a method in Selenium WebDriver to pause the script till defined element is not available on web page.
When explicit wait method is called into a automation script then script will wait till defined element is available on web page to execute the next command.




Sample code for explicit wait is:
(new WebDriverWait(driver, 60)).until(new ExpectedCondition<WebElement>() {
    public WebElement apply(WebDriver newDriver) {
     return newDriver.findElement(By.id("BlogArchive1_ArchiveMenu"));
    }
   });
//where driver is the already defined WebDriver instance




If we use above code for explicit wait then script will execute next line of code after defined element is available on web page.
You can also change the ExpectedCondition by Boolean, etc.






Post a Comment

0 Comments