Skip to content

Commit dcb7f10

Browse files
committed
Add better error handling on scrolling actions
1 parent d4b6520 commit dcb7f10

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

seleniumbase/fixtures/js_utils.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,12 @@ def highlight_with_jquery_2(driver, message, selector, o_bs, msg_dur):
592592

593593

594594
def scroll_to_element(driver, element):
595-
element_location = element.location['y']
595+
element_location = None
596+
try:
597+
element_location = element.location['y']
598+
except Exception:
599+
element.location_once_scrolled_into_view
600+
return
596601
element_location = element_location - 130
597602
if element_location < 0:
598603
element_location = 0
@@ -611,7 +616,12 @@ def slow_scroll_to_element(driver, element, browser):
611616
scroll_to_element(driver, element)
612617
return
613618
scroll_position = driver.execute_script("return window.scrollY;")
614-
element_location = element.location['y']
619+
element_location = None
620+
try:
621+
element_location = element.location['y']
622+
except Exception:
623+
element.location_once_scrolled_into_view
624+
return
615625
element_location = element_location - 130
616626
if element_location < 0:
617627
element_location = 0

0 commit comments

Comments
 (0)