Skip to content

Commit

Permalink
Merge pull request #211 from ikerreyes/force-scroll-chrome
Browse files Browse the repository at this point in the history
Add chrome to the list of browsers with "force_scroll"
  • Loading branch information
Dmitrii Misharov authored Jan 11, 2022
2 parents b5f5b1b + b0c5269 commit 7b22887
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/widgetastic/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,8 +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 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 7b22887

Please sign in to comment.