@@ -124,8 +124,14 @@ public WebElement getWrappedElement() {
124
124
} else {
125
125
return findElement ();
126
126
}
127
- } catch (Exception ex ) {
127
+ } catch (ElementNotInteractableException ex ) {
128
+ scrollToVisible ();
128
129
return findElement ();
130
+ } catch (StaleElementReferenceException ex ) {
131
+ return findElement ();
132
+ } catch (WebDriverException ex ) {
133
+ toExist ().waitToBe ();
134
+ return wrappedElement ;
129
135
}
130
136
}
131
137
@@ -844,7 +850,7 @@ private boolean inShadowContext() {
844
850
}
845
851
846
852
public WebElement findElement () {
847
- if (waitStrategies .size () == 0 ) {
853
+ if (waitStrategies .isEmpty () ) {
848
854
waitStrategies .add (Wait .to ().exist (webSettings .getTimeoutSettings ().getElementWaitTimeout (), webSettings .getTimeoutSettings ().getSleepInterval ()));
849
855
}
850
856
@@ -893,7 +899,8 @@ private void clickInternal() {
893
899
try {
894
900
wait .until (x -> tryClick ());
895
901
} catch (TimeoutException e ) {
896
- toBeVisible ().toBeClickable ().findElement ().click ();
902
+ Log .info ("Click has timed out. Trying with JS click()..." );
903
+ javaScriptService .execute ("arguments[0].click()" , findElement ());
897
904
}
898
905
}
899
906
@@ -902,9 +909,15 @@ private boolean tryClick() {
902
909
toBeVisible ().toBeClickable ().findElement ().click ();
903
910
return true ;
904
911
} catch (ElementNotInteractableException e ) {
912
+ Log .error ("ElementNotInteractableException found - retrying with scroll.. " );
913
+ scrollToVisible ();
914
+ return false ;
915
+ } catch (StaleElementReferenceException e ) {
916
+ Log .error ("StaleElementReference Exception found - retrying with a new Find... " );
917
+ findElement ();
905
918
return false ;
906
919
} catch (WebDriverException e ) {
907
- toBeVisible (). toBeClickable (). waitToBe ( );
920
+ Log . error ( "WebDriverException found - trying again... " );
908
921
return false ;
909
922
}
910
923
}
@@ -1291,6 +1304,9 @@ private void scrollToVisible(WebElement wrappedElement, boolean shouldWait, Scro
1291
1304
public boolean isVisible () {
1292
1305
try {
1293
1306
return getWrappedElement ().isDisplayed ();
1307
+ } catch (StaleElementReferenceException e ) {
1308
+ wrappedElement = findElement ();
1309
+ return false ;
1294
1310
} catch (NotFoundException e ) {
1295
1311
return false ;
1296
1312
}
0 commit comments