Ok, I'm not sure there is a ready solution to what my problem is, but essentially the website I am trying to do automated testing on is prone to "System Error"'s. I have a state machine that navigates through various webpages to get a desired result.
The crux of the issue is that selenium is doing a 120 second timeout while waiting for an element on the page but all the page has on it is the big "System Error" instead.
I already have some framework set up that can scan a page for the system errors and throw a CriticalPageException if it finds this. However, I want to be able to scan for this error in the WebDriverWait.
Is there a way to do this in the Java version of Selenium, or am I sol?
We had a similar issue. What we did was created a custom waitForWebElement method that polls the site, you could do something similar
public WebElement waitForWebElement(final By by, final boolean isDisplayed) {
// Waiting 30 seconds for an element to be present on the page, checking
// for its presence once every 5 seconds.
Wait<SearchContext> wait = new FluentWait<SearchContext>(getSearchElement()).withTimeout(timeout, TimeUnit.SECONDS).pollingEvery(pollSeconds, TimeUnit.SECONDS).ignoring(NoSuchElementException.class);
WebElement webElement = wait.until(new Function<SearchContext, WebElement>() {
public WebElement apply(SearchContext search) {
try{
WebElement element = search.findElement(by);
catch(NoSuchElementException e){
if(CHECK_YOUR_ERROR_PRESENT){
throw CriticalPageException()
}else{
throw e;
}
}
return element;
}
});
return webElement;
}
EDIT : getSearchElement() just returns your search context
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.