Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk5 min

How to Scroll Down a Page With Selenium

Use Selenium wheel actions for a fixed scroll or a known element, and JavaScript for DOM scrolling. Includes Java examples, browser scope, and troubleshooting.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Selenium’s wheel actions to scroll a set distance or bring a known element into view. In Java, the basic fixed-distance call is new Actions(driver).scrollByAmount(0, 500).perform();; a positive vertical delta scrolls down. The official Selenium wheel-actions guide is marked Chromium-only, so do not assume that wheel-action behavior is identical in every browser or binding.

Choose the right kind of scroll

  • Known distance: use a wheel delta for incremental movement, such as scrolling down the page by 500 pixels.
  • Known destination: scroll a target element into view instead of guessing how far down it is.
  • Specific scroll region or coordinate: use a scroll origin when the interaction needs to begin at an element or viewport position.
  • Page-bottom or DOM operation: use JavaScript when a browser DOM scroll method is a better fit than simulating wheel input.

Selenium’s official wheel-actions guide describes these patterns and says wheel input was introduced in Selenium 4.2. Its wheel-actions page is labeled Chromium-only; check the documentation for your browser, Selenium binding, and installed version before relying on that API elsewhere.

Scroll down by a fixed amount in Java

Use scrollByAmount(x, y) when a known incremental distance is what the test needs. For a vertical scroll down of 500 pixels:

new Actions(driver)
    .scrollByAmount(0, 500)
    .perform();

The first value is the horizontal delta and the second is the vertical delta. Positive vertical values move down; negative values move up. Adjust the distance to suit the page and test rather than assuming one value will land at the same content position on every viewport.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a complete Java test, create a WebDriver for the browser under test, navigate to the page, then run the action before asserting the page state. This example assumes driver is an initialized WebDriver and Selenium’s Java Actions API is available:

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;

public class ScrollPage {
    public static void main(String[] args) {
        WebDriver driver = new ChromeDriver();
        try {
            driver.get("https://example.com");
            new Actions(driver)
                .scrollByAmount(0, 500)
                .perform();
        } finally {
            driver.quit();
        }
    }
}

The example uses Chrome because Selenium’s cited wheel-actions guide is scoped to Chromium. Configure the browser driver and Selenium dependency according to your environment.

Rank #2
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option

Scroll a known element into view

When the next action depends on a particular element, target it directly. Selenium documents scrollToElement as bringing the element’s bottom to the bottom of the screen, whether the element is above or below the current viewport:

WebElement target = driver.findElement(By.cssSelector("#target"));
new Actions(driver)
    .scrollToElement(target)
    .perform();

This is generally more reliable than repeatedly guessing pixel distances when the destination is known. It is still necessary to locate the element successfully and to verify that the intended content is in the relevant scrollable region.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Scroll from an element or viewport origin

Origin-based scrolling is useful when the wheel action should begin relative to an element, such as a nested scrollable area, or at a point in the viewport. Selenium’s Java API uses scrollFromOrigin with a WheelInput.ScrollOrigin and horizontal and vertical deltas. The origin can include offsets. Selenium warns that an offset outside the viewport can cause an exception, so keep viewport coordinates and offsets within the visible area.

Use this approach only when the origin matters. For ordinary page movement, a direct amount or a target element is simpler. For a nested panel or frame, first confirm that the intended element and browsing context are selected; scrolling the top-level page is not the same as scrolling a nested region.

Rank #4
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers

Use JavaScript for page-bottom or DOM scrolling

Selenium’s JavaScript executor runs code in the currently selected frame or window. If the desired operation is to move the current document to its bottom, invoke the browser’s window.scrollTo method:

((JavascriptExecutor) driver).executeScript(
    "window.scrollTo(0, document.body.scrollHeight);"
);

For a known element, pass its WebElement into the script and call the DOM method scrollIntoView:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
((JavascriptExecutor) driver).executeScript(
    "arguments[0].scrollIntoView();", target
);

These are browser DOM methods executed through Selenium, not Selenium-specific scroll APIs. Ensure the selected frame or window is the one whose content should move. Also check the actual scroll container: some pages scroll an inner element rather than the document body, in which case scrolling the body may not move the content you expect.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Handle dynamically loaded content

A scroll action does not guarantee that a site will load more content. Infinite-scroll pages may fetch or render additional items only after the viewport reaches a trigger point, and the timing is controlled by the page. If the test expects more content:

  1. Scroll toward the relevant trigger point, using an element target or an incremental delta.
  2. Wait for a page-specific condition, such as the expected new element becoming available, rather than assuming the scroll itself means loading is finished.
  3. Repeat only while the required content has not appeared and the page can still make progress.

A single jump to the bottom may not trigger every intermediate loading behavior. Base the test’s completion condition on the content it needs, not only on the scroll command.

Troubleshooting

  • A scroll method is missing: check the installed Selenium version and the API for the language binding in use. The official guide says wheel input was introduced in Selenium 4.2; an older installation may not expose it.
  • The wheel action does not work in the chosen browser: the official wheel-actions guide is labeled Chromium-only. Do not infer universal support from its examples; verify compatibility for the browser and binding you run.
  • The page does not move: confirm that the intended window or frame is selected and determine whether the document or an inner scrollable element owns the scroll. A JavaScript call on the document body will not necessarily move a nested panel.
  • An origin-based action throws an exception: check whether the origin offset falls outside the viewport. Selenium documents this as a possible failure for out-of-viewport offsets.
  • The target cannot be found: verify the locator and browsing context, and make sure the target exists before calling findElement. For content created after scrolling, wait for the page’s actual loading condition before looking for it.
  • More content does not appear after scrolling: the page may require a trigger point, time to load, or another application-specific condition. Selenium does not guarantee that a page will fetch additional content just because the viewport moved.
  • A fixed delta lands inconsistently: use a known element as the destination when possible. Pixel movement and the resulting content position can differ with viewport size and page layout.

Or skip the browser setup

If the goal is to capture a page rather than test scroll behavior, ScreenshotNeo can return a screenshot or PDF through one API request. It does not replace Selenium for interacting with a page, but it avoids setting up a browser for a capture.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

ScreenshotNeo API documentation

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Before capture, it accepts cookie or consent banners and removes 60+ known consent platforms, newsletter popups, and chat widgets; each cleanup step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers identify the page verdict and billing status. Its MCP server offers take_screenshot, get_page_info, and capture_pdf for AI agents. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots.

Sign up for 1,000 free screenshots a month with no card.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. Shenzhen desk3 min
    HONOR Expands Beyond Smartphones With Humanoid Robot RevealHONOR said it unveiled its first humanoid robot at MWC 2026 and named shopping assistance, workplace inspections, and supportive companionship as intended uses. Later Robotics D1 claims and a reported…
  2. Cupertino desk5 min
    Apple Unveils AirPods Max 2: The Upgrade That Should Have Happened Years AgoAirPods Max 2 adds H2-powered audio features and Apple claims up to 1.5× more effective ANC, but its design, Smart Case, and 20-hour battery rating are unchanged. Wired lossless audio…
  3. Cupertino desk4 min
    Apple’s OLED Touch MacBooks Are Coming—but the Dynamic Island Is the Real GambleApple has not announced an OLED touchscreen MacBook, but reports point to high-end models arriving in late 2026 or early 2027. The reported Mac Dynamic Island could be useful, but…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.