Skip to content

Commit

Permalink
Enable force_scroll on any browser
Browse files Browse the repository at this point in the history
  • Loading branch information
ikerreyes committed Jan 11, 2022
1 parent 56ae6d9 commit b0c5269
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/widgetastic/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,11 +592,10 @@ def move_to_element(self, locator: LocatorAlias, *args, **kwargs) -> WebElement:
self.move_to_element(parent)
return el

# FF60+ doesn't raise MoveTargetOutOfBoundsException. it just silently does nothing
if (
(self.browser_type == "firefox" and self.browser_version >= 60)
or self.browser_type == "chrome"
) and force_scroll:
# element can be obscured by e.g. sticky header,
# selenium doesn't recognize this case as MoveTargetOutOfBoundsException,
# thus we have to forcefully scroll the page to have the element in the center
if force_scroll:
self.execute_script("arguments[0].scrollIntoView({block: 'center'});", el)

move_to = ActionChains(self.selenium).move_to_element(el)
Expand Down

0 comments on commit b0c5269

Please sign in to comment.