@@ -124,8 +124,14 @@ public WebElement getWrappedElement() {
124124 } else {
125125 return findElement ();
126126 }
127- } catch (Exception ex ) {
127+ } catch (ElementNotInteractableException ex ) {
128+ scrollToVisible ();
128129 return findElement ();
130+ } catch (StaleElementReferenceException ex ) {
131+ return findElement ();
132+ } catch (WebDriverException ex ) {
133+ toExist ().waitToBe ();
134+ return wrappedElement ;
129135 }
130136 }
131137
@@ -844,7 +850,7 @@ private boolean inShadowContext() {
844850 }
845851
846852 public WebElement findElement () {
847- if (waitStrategies .size () == 0 ) {
853+ if (waitStrategies .isEmpty () ) {
848854 waitStrategies .add (Wait .to ().exist (webSettings .getTimeoutSettings ().getElementWaitTimeout (), webSettings .getTimeoutSettings ().getSleepInterval ()));
849855 }
850856
@@ -893,7 +899,8 @@ private void clickInternal() {
893899 try {
894900 wait .until (x -> tryClick ());
895901 } 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 ());
897904 }
898905 }
899906
@@ -902,9 +909,15 @@ private boolean tryClick() {
902909 toBeVisible ().toBeClickable ().findElement ().click ();
903910 return true ;
904911 } 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 ();
905918 return false ;
906919 } catch (WebDriverException e ) {
907- toBeVisible (). toBeClickable (). waitToBe ( );
920+ Log . error ( "WebDriverException found - trying again... " );
908921 return false ;
909922 }
910923 }
@@ -1291,6 +1304,9 @@ private void scrollToVisible(WebElement wrappedElement, boolean shouldWait, Scro
12911304 public boolean isVisible () {
12921305 try {
12931306 return getWrappedElement ().isDisplayed ();
1307+ } catch (StaleElementReferenceException e ) {
1308+ wrappedElement = findElement ();
1309+ return false ;
12941310 } catch (NotFoundException e ) {
12951311 return false ;
12961312 }
0 commit comments