Skip to content

Commit bd085e8

Browse files
Also catch the NoSuchElementException if the element is not present in DOM thrown by findElement(locator) and return null in method visibilityOfElementLocated (#7395)
Co-authored-by: David Burns <david.burns@theautomatedtester.co.uk>
1 parent cf51826 commit bd085e8

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

java/client/src/org/openqa/selenium/support/ui/ExpectedConditions.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,8 @@ public static ExpectedCondition<WebElement> visibilityOfElementLocated(final By
203203
public WebElement apply(WebDriver driver) {
204204
try {
205205
return elementIfVisible(driver.findElement(locator));
206-
} catch (StaleElementReferenceException e) {
206+
} catch (StaleElementReferenceException | NoSuchElementException e) {
207+
// Returns null because the element is no longer or not present in DOM.
207208
return null;
208209
}
209210
}

0 commit comments

Comments
 (0)