Explicitwait


//explicit wait  is used in case of ajax based components
WebDriverWait wait=new WebDriverWait(driver,20);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//button[@id='searchBtn']")));

//implicit wait 
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

//Fluentwait
FluentWait<WebDriver> fWait=new FluentWait(driver);
fWait.withTimeout(5, TimeUnit.SECONDS);//
fWait.pollingEvery(1, TimeUnit.SECONDS);//we are specifying to selenium topool for 1 sec .
fWait.ignoring(NoSuchElementException.class);//if we get any exception we can ignore using this Fluent wait .
fWait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//button[@id='searchBtn']")));

List<WebElement> allDropDownfrom=driver.findElements(By.xpath("//*[@class='ui-menu-item']"));
//className("ui-menu-item"));
System.out.println(allDropDownfrom.size());

//pageLoadTimeout

//when ever we click on on link if we take to another page then it will wait for specific time to load the page
driver.manage().timeouts().pageLoadTimeout(20, TimeUnit.SECONDS);

Comments

Popular posts from this blog

Implicit and Explicit Waits,FluentWait,PageLoadTimeOut

A Interview Questions- selenium