Skip to content

Commit

Permalink
Also catch the NoSuchElementException if the element is not present i…
Browse files Browse the repository at this point in the history
…n DOM thrown by findElement(locator) and return null in method visibilityOfElementLocated (#7395)

Co-authored-by: David Burns <[email protected]>
  • Loading branch information
focbenz and AutomatedTester authored Jun 16, 2020
1 parent cf51826 commit bd085e8
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ public static ExpectedCondition<WebElement> visibilityOfElementLocated(final By
public WebElement apply(WebDriver driver) {
try {
return elementIfVisible(driver.findElement(locator));
} catch (StaleElementReferenceException e) {
} catch (StaleElementReferenceException | NoSuchElementException e) {
// Returns null because the element is no longer or not present in DOM.
return null;
}
}
Expand Down

0 comments on commit bd085e8

Please sign in to comment.