I have written few test cases in Selenium WebDriver using Java and execute them on grid (hub and multiple nodes). I have noticed that a few test cases fail due to NoSu
We can apply below codes to remove this exception condition
By applying WebDriverWait, webdriver object wait for a specific time (in second) of an element for its visibility.
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.visibilityOf(link));
We can handle NoSuchElementException through try-catch block inside Generic method
public boolean isElementPresent(By by) {
boolean isPresent = true;
try {
driver.findElement(by);
} catch (NoSuchElementException e) {
isPresent = false;
}
return isPresent
}
http://selenium-code.blogspot.in/2017/08/selenium-exception-nosuchelementexcepti.html