Skip to content

browser.scroll#

Functions#

by(x, y, delay_seconds=1) #

If possible, scroll by X and Y pixels as relative to current position.

Parameters:

Name Type Description Default
x int

In pixels. Scroll on horisontal X axis as relative to current position. Can be positive or negative.

required
y int

In pixels. Scroll on vertical Y axis as relative to current position. Can be positive or negative.

required
delay_seconds float

Option to add custom delay in seconds to ensure the view is updated after scroll.

1
Example
browser.scroll.by(0, 100)

down_by(pixels, delay_seconds=1) #

If possible, scroll down by Y pixels. Horisontal position is unchanged.

Parameters:

Name Type Description Default
pixels int

Amount to scroll down as relative to current position.

required
delay_seconds float

Option to add custom delay in seconds to ensure the view is updated after scroll.

1
Example
browser.scroll.down_by(100)

into_view(xpath, timeout=None, delay_seconds=1) #

Find element and scroll up or down until element is visible.

Parameters:

Name Type Description Default
xpath str

XPath of the element.

required
timeout float | None

In seconds. Timeout to wait for element. If None, the global timeout setting is used (default 5 seconds).

None
delay_seconds float

Option to add custom delay in seconds to ensure the view is updated after scroll.

1
Example
browser.scroll.into_view("//xpath/to/element")

into_view_if_not_in_viewport(xpath, timeout=None, delay_seconds=1) #

If not visible in the current viewport, find element and scroll up or down until element is visible.

Parameters:

Name Type Description Default
xpath str

XPath of the element.

required
timeout float | None

In seconds. Timeout to wait for element. If None, the global timeout setting is used (default 5 seconds).

None
delay_seconds float

Option to add custom delay in seconds to ensure the view is updated after scroll.

1
Example
browser.scroll.into_view_if_not_in_viewport("//xpath/to/element")

left_by(pixels, delay_seconds=1) #

If possible, scroll left by X pixels. Horisontal position is unchanged.

Parameters:

Name Type Description Default
pixels int

Amount to scroll left as relative to current position.

required
delay_seconds float

Option to add custom delay in seconds to ensure the view is updated after scroll.

1
Example
browser.scroll.left_by(50)

right_by(pixels, delay_seconds=1) #

If possible, scroll right by X pixels. Horisontal position is unchanged.

Parameters:

Name Type Description Default
pixels int

Amount to scroll right as relative to current position.

required
delay_seconds float

Option to add custom delay in seconds to ensure the view is updated after scroll.

1
Example
browser.scroll.right_by(50)

to_position(x, y, delay_seconds=1) #

If possible, scroll to coordinate X and Y pixels of page as absolute position.

Parameters:

Name Type Description Default
x int

Absolute position in pixels on horisontal X axis.

required
y int

Absolute position in pixels on vertical Y axis.

required
delay_seconds float

Option to add custom delay in seconds to ensure the view is updated after scroll.

1
Example
browser.scroll.to_position(0, 100)

up_by(pixels, delay_seconds=1) #

If possible, scroll up by Y pixels. Horisontal position is unchanged.

Parameters:

Name Type Description Default
pixels int

Amount to scroll up as relative to current position.

required
delay_seconds float

Option to add custom delay in seconds to ensure the view is updated after scroll.

1
Example
browser.scroll.up_by(50)