Block reference / Web interaction
Scroll element
Scroll the page or a scrollable area to an element or to a position.
Only in
WarpX Browser
Use Scroll element to bring an element into view, to load more results on a page that loads as you scroll, or to move a scrollable panel to an exact position. By default it scrolls to the element with human-paced mouse-wheel movement. With Scroll into view off, it sets the scroll position instead.
Settings
- Element Selector
The element to act on, as a CSS selector or an XPath; anything starting with
/,(,@orid(is read as XPath, and it can hold a reference such as{{variables.selector}}. The crosshair button (Select an element) lets you pick the element in the profile's browser, including inside iframes and shadow roots, and the check button (Verify selector) tests what you typed.Example.results-list > li:last-child- Multiple
Scrolls to or for every matching element instead of only the first. With it on, Human Emulation is not offered.
ExampleUnchecked- Mark elementwhen the selector is CSS
Skips elements this block has already handled, and tags the one it handles once the action is done, so inside a loop each pass takes the next untouched match. With Multiple, every match is tagged after all of them are handled. The tag is the attribute
block--plus the block's id, so it is gone once the page reloads or changes; only offered for CSS selectors.ExampleUnchecked- Wait for selector
Keeps looking for the element until it appears or Selector timeout (ms) runs out. Off, the element must be found almost at once, or the block fails.
ExampleChecked- Selector timeout (ms)when Wait for selector is on
How long Wait for selector keeps looking, in milliseconds. The default is
5000.Example10000- Scroll horizontalwhen Scroll into view is off
The horizontal position to scroll to, in pixels. With Increment horizontal scroll on, the distance to move from the current position instead.
Example0- Scroll verticalwhen Scroll into view is off
The vertical position to scroll to, in pixels. With Increment vertical scroll on, the distance to move down from the current position instead; a negative number moves up.
Example800- Scroll into view
On (the default), scrolls until the element is on screen. Off, scrolls the nearest scrollable area around the element to the position in Scroll horizontal and Scroll vertical.
ExampleChecked- Smooth scroll
Animates the scroll instead of jumping. It applies when Human Emulation is off. With Human Emulation on, the scroll is already gradual: the mouse wheel turns toward the element in steps, at a person's pace, so this box changes nothing there.
ExampleUnchecked- Increment horizontal scrollwhen Scroll into view is off
Treats Scroll horizontal as a distance to add to the current position.
ExampleUnchecked- Increment vertical scrollwhen Scroll into view is off
Treats Scroll vertical as a distance to add to the current position. Run the block repeatedly, for example in a loop, to page down step by step.
ExampleChecked- Human Emulationwhen Scroll into view is on and Multiple is off
On (the default), turns the mouse wheel toward the element in human-paced steps, the way a person scrolls. Off, the page jumps so the element sits in the middle of the screen.
ExampleChecked- Delay time (ms)
A pause after the block finishes, before the next block starts. Write one number such as
1000, or a range such as1000,3000to pick a random pause in that range on each run.Example2000
Every block also has the shared block settings — a description, Disable block and what to do on an error, and Finding elements explains selectors in more depth. Fields that take text accept data from earlier blocks.
What it hands on
Nothing is written to the table or to variables. The block leaves by its single output; if no element matches, it fails.
Example: Load more results on a page that loads as you scroll
- Start
- New tab
- Loop data
- Scroll element
- Loop breakpoint
- Get text
- Add a New tab block that opens the results page, for example
https://news.example.com/search?q=solar. - Add a Scroll element block and set Element Selector to
.results-list > li:last-child, the last result currently on the page. - Tick Wait for selector and set Selector timeout (ms) to
10000. Leave Scroll into view and Human Emulation on. - Set Delay time (ms) to
2000so the next batch has time to load. - Put it between a Loop data block (Loop through set to Numbers, from
1to5) and a Loop breakpoint, then add Get text after the loop to collect the headlines.
Good to know
- If no element matches, the block fails with an error that names the selector, and the workflow stops. Set On error in the block's settings to Continue flow or Execute fallback to carry on.
- With Human Emulation on, an XPath selector must start with
//outside a frame; other XPath forms such as(//li)[last()]or/html/bodyare not recognised on that path. Turn Human Emulation off, or use a CSS selector, for those. - With Increment vertical scroll or Increment horizontal scroll, the starting point is the scroll position of the element you selected, which is the right one when the selector names the scrollable area itself, such as the default
html.