@@ -1443,7 +1443,14 @@ def highlight(self, selector, by=By.CSS_SELECTOR,
1443
1443
element = self .wait_for_element_visible (
1444
1444
selector , by = by , timeout = settings .SMALL_TIMEOUT )
1445
1445
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 )
1447
1454
try :
1448
1455
selector = self .convert_to_css_selector (selector , by = by )
1449
1456
except Exception :
@@ -1509,9 +1516,17 @@ def slow_scroll_to(self, selector, by=By.CSS_SELECTOR,
1509
1516
''' Slow motion scroll to destination '''
1510
1517
if self .timeout_multiplier and timeout == settings .SMALL_TIMEOUT :
1511
1518
timeout = self .__get_new_timeout (timeout )
1519
+ selector , by = self .__recalculate_selector (selector , by )
1512
1520
element = self .wait_for_element_visible (
1513
1521
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 )
1515
1530
1516
1531
def click_xpath (self , xpath ):
1517
1532
# Technically self.click() will automatically detect an xpath selector,
@@ -3071,7 +3086,14 @@ def __highlight_with_assert_success(
3071
3086
except Exception :
3072
3087
# Don't highlight if can't convert to CSS_SELECTOR
3073
3088
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 )
3075
3097
3076
3098
o_bs = '' # original_box_shadow
3077
3099
style = element .get_attribute ('style' )
0 commit comments