@@ -1443,7 +1443,14 @@ def highlight(self, selector, by=By.CSS_SELECTOR,
14431443 element = self .wait_for_element_visible (
14441444 selector , by = by , timeout = settings .SMALL_TIMEOUT )
14451445 if scroll :
1446- self .__slow_scroll_to_element (element )
1446+ try :
1447+ self .__slow_scroll_to_element (element )
1448+ except (StaleElementReferenceException , ENI_Exception ):
1449+ self .wait_for_ready_state_complete ()
1450+ time .sleep (0.05 )
1451+ element = self .wait_for_element_visible (
1452+ selector , by = by , timeout = settings .SMALL_TIMEOUT )
1453+ self .__slow_scroll_to_element (element )
14471454 try :
14481455 selector = self .convert_to_css_selector (selector , by = by )
14491456 except Exception :
@@ -1509,9 +1516,17 @@ def slow_scroll_to(self, selector, by=By.CSS_SELECTOR,
15091516 ''' Slow motion scroll to destination '''
15101517 if self .timeout_multiplier and timeout == settings .SMALL_TIMEOUT :
15111518 timeout = self .__get_new_timeout (timeout )
1519+ selector , by = self .__recalculate_selector (selector , by )
15121520 element = self .wait_for_element_visible (
15131521 selector , by = by , timeout = timeout )
1514- self .__slow_scroll_to_element (element )
1522+ try :
1523+ self .__slow_scroll_to_element (element )
1524+ except (StaleElementReferenceException , ENI_Exception ):
1525+ self .wait_for_ready_state_complete ()
1526+ time .sleep (0.05 )
1527+ element = self .wait_for_element_visible (
1528+ selector , by = by , timeout = timeout )
1529+ self .__slow_scroll_to_element (element )
15151530
15161531 def click_xpath (self , xpath ):
15171532 # Technically self.click() will automatically detect an xpath selector,
@@ -3071,7 +3086,14 @@ def __highlight_with_assert_success(
30713086 except Exception :
30723087 # Don't highlight if can't convert to CSS_SELECTOR
30733088 return
3074- self .__slow_scroll_to_element (element )
3089+ try :
3090+ self .__slow_scroll_to_element (element )
3091+ except (StaleElementReferenceException , ENI_Exception ):
3092+ self .wait_for_ready_state_complete ()
3093+ time .sleep (0.05 )
3094+ element = self .wait_for_element_visible (
3095+ selector , by = by , timeout = settings .SMALL_TIMEOUT )
3096+ self .__slow_scroll_to_element (element )
30753097
30763098 o_bs = '' # original_box_shadow
30773099 style = element .get_attribute ('style' )
0 commit comments