webdriver_test_tools.webdriver.actions.scroll module

Functions for scrolling elements into view

webdriver_test_tools.webdriver.actions.scroll.into_view(driver, element, align_to_top=True)[source]

Scroll to an element

Parameters
  • driver – Selenium WebDriver object

  • element – WebElement to scroll to

  • align_to_top – (Default = True) Aligns element to top of scrollable parent if True, aligns it to the bottom if False

webdriver_test_tools.webdriver.actions.scroll.to_and_click(driver, element, align_to_top=True)[source]

Short hand function for scrolling an element into view and clicking it

Parameters
  • driver – Selenium WebDriver object

  • element – WebElement to scroll to and click on

  • align_to_top – (Default = True) Aligns element to top of scrollable parent if True, aligns it to the bottom if False

webdriver_test_tools.webdriver.actions.scroll.to_position(driver, x, y)[source]

Scroll window to the specified x,y coordinates

Executes JavaScript window.scroll(x,y)

Parameters
  • driver – Selenium WebDriver object

  • x – Horizontal scroll coordinate

  • y – Vertical scroll coordinate

webdriver_test_tools.webdriver.actions.scroll.to_element(driver, element, offset=0, align_to_top=True)[source]

Vertically scroll to an element with an optional offset

When align_to_top=True, the scroll y coordinate is calculated:

element.offsetTop - offset

When align_to_top=False, the scroll y coordinate is calculated:

element.offsetTop + element.offsetHeight - window.innerHeight + offset

Parameters
  • driver – Selenium WebDriver object

  • element – WebElement object for the target element

  • offset – (Default = 0) Scroll offset

  • align_to_top – (Default = True) Aligns element to top of scrollable parent if True, aligns it to the bottom if False

webdriver_test_tools.webdriver.actions.scroll.into_view_fixed_nav(driver, target_element, fixed_element, additional_offset=0, align_to_top=True)[source]

Scroll an element into view offset by the height of a fixed element so it’s not obstructed

Parameters
  • driver – Selenium WebDriver object

  • target_element – WebElement object for the target element

  • fixed_element – WebElement object for the fixed nav

  • additional_offset – (Default = 0) Additional offset from the top

  • align_to_top – (Default = True) Aligns element to top of scrollable parent if True, aligns it to the bottom if False