Issue
We are doing automation for a web application and most of the scenarios have a loading icon appearing at the center of a page. We need to wait for this loading icon to disappear.
The HTML:
<div id="loading" style="display: none; visibility: hidden;">
<div></div>
<div></div>
Example: We have search functionality in most of the scenarios. We are getting this loading icon while the search executes.
With the Selenium webdriver, we are using the ID.
We are getting for loading to complete id= "loading". Please any give any solution for the above issues I am facing.
We have a variety of subsequent testing functionality like clicks & sendkeys that can only be used once loading is complete.
Solution
Explicit Wait should help:
public static String waitForElementNotVisible(int timeOutInSeconds, WebDriver driver, String elementXPath) {
if ((driver == null) || (elementXPath == null) || elementXPath.isEmpty()) {
return "Wrong usage of WaitforElementNotVisible()";
}
try {
(new WebDriverWait(driver, timeOutInSeconds)).until(ExpectedConditions.invisibilityOfElementLocated(By
.xpath(elementXPath)));
return null;
} catch (TimeoutException e) {
return "Build your own errormessage...";
}
}
Answered By - Matthias
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.