You can wait for the document to readyStatebecome complete. Run javascript return document.readyState").equals("complete")on the downloadable webpage.
void waitForLoad(WebDriver driver) {
ExpectedCondition<Boolean> pageLoadCondition = new
ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver driver) {
return ((JavascriptExecutor)driver).executeScript("return document.readyState").equals("complete");
}
};
WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until(pageLoadCondition);
}
And then you can get the page source:
driver.getPageSource();
And then make sure that pageSource contains what you are looking for:
driver.getPageSource().contains("your element/tag");
Hope this helps!
source
share