Skip to content

Commit fd1e67d

Browse files
author
NikolayAvramov
committed
hunting down StaleElementReference Exception
1 parent 7290d7e commit fd1e67d

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

bellatrix.web/src/main/java/solutions/bellatrix/web/components/WebComponent.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,15 @@ private void clickInternal() {
893893
try {
894894
wait.until(x -> tryClick());
895895
} catch (TimeoutException e) {
896+
Log.info("Timeout Exception found - retrying... ");
896897
toBeVisible().toBeClickable().findElement().click();
898+
} catch (StaleElementReferenceException e) {
899+
Log.info("StaleElementReference Exception found - retrying with scroll.. ");
900+
browserService.scrollToTop();
901+
tryClick();
902+
} catch (Exception e) {
903+
Log.info("Exception found - retrying with scroll.. ");
904+
findElement().click();
897905
}
898906
}
899907

@@ -903,6 +911,9 @@ private boolean tryClick() {
903911
return true;
904912
} catch (ElementNotInteractableException e) {
905913
return false;
914+
} catch (StaleElementReferenceException e) {
915+
findElement();
916+
return false;
906917
} catch (WebDriverException e) {
907918
toBeVisible().toBeClickable().waitToBe();
908919
return false;

0 commit comments

Comments
 (0)