In my last post, i have written about 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.
Code-:
Here is the List of all methods present in the ExpectedCondition class.
you can try these methods yourself and any suggestion/comments are welcome.
Let us share our thoughts/ideas using this forum, feel free to provide your valuable comments and Happy Automating!!
Thanks!!
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.
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 ));
Here is the List of all methods present in the ExpectedCondition class.
you can try these methods yourself and any suggestion/comments are welcome.
Let us share our thoughts/ideas using this forum, feel free to provide your valuable comments and Happy Automating!!
Thanks!!
No comments:
Post a Comment