Header Ads Widget

Responsive Advertisement

Ticker

6/recent/ticker-posts

What is ExpectedCondition Class in WebDriver ?




Implementing wait for element to appear using WebDriver wait and ExpectedCondition class ie Implicit and Explicit wait.

That is only to find the element in a web page or wait till it appear in the DOM. But using ExpectedCondition class, you can wait for an alert to be present, for an element to be staled while loading another page, for an element to be ready for a click operation, and many more.

Let us see some of the code to implement above things. As an example, lets have a situation where you perform some action on a element and it reloads the frame/page.
How do you know that the page is reloaded after performing the action?
Simple answer is if the page is reloaded then the existing element will be staled right? Ok so lets see how we can verify that.

sample code-:

WebDriverWait wait = new WebDriverWait(driver, 10); 

WebElement TestElement = driver.findElement(By any locator);

// perform some action on the element to reload the page

wait.until(ExpectedConditions.stalesnessOf(TestElement ));

Post a Comment

0 Comments