Use Selenium 4’s Actions wheel methods when you need browser-like scrolling, and use execute_script() when you need the page’s DOM scrolling APIs. For a known element, call scroll_to_element(); for a fixed movement, call scroll_by_amount(0, pixels); for a particular scroll origin, call scroll_from_origin(). Selenium’s official wheel guide is labeled Chromium Only, so verify support for your browser and language binding before depending on wheel actions.
Choose the scrolling method that matches the job
| Need | Recommended method | What it does |
|---|---|---|
| Bring a known element into view | ActionChains(driver).scroll_to_element(element).perform() |
Uses wheel input and positions the page with the element’s bottom at the bottom of the viewport. |
| Move a fixed distance | scroll_by_amount(delta_x, delta_y) |
Scrolls from the upper-left of the viewport. Negative values move left or up. |
| Scroll from an element or viewport coordinate | scroll_from_origin(origin, delta_x, delta_y) |
Applies deltas relative to an element (optionally offset) or a viewport point. |
| Invoke page scrolling behavior directly | driver.execute_script(...) |
Runs synchronous JavaScript in the current window or frame, such as scrollIntoView() or window.scrollBy(). |
Wheel input was introduced in Selenium 4.2. Actions do not automatically scroll a target into view before another action; explicitly scroll first when the target is outside the viewport.
Prerequisites and a minimal Python setup
Install Selenium in the environment that runs your test:
python -m pip install -U selenium
The examples below assume a driver is available through Selenium Manager or your normal driver configuration, and that driver is a live WebDriver session.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
from selenium import webdriver
from selenium.webdriver.common.by import By
with webdriver.Chrome() as driver:
driver.get("https://example.com")
heading = driver.find_element(By.TAG_NAME, "h1")
print(heading.text)
Replace the URL and locator with your application. If a page is inside an iframe, switch to that frame before locating or scrolling its elements.
Scroll a specific element into view
Wheel action for a target element
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.by import By
# Locate the element first; use an explicit wait in dynamic applications.
element = driver.find_element(By.CSS_SELECTOR, "#checkout")
ActionChains(driver).scroll_to_element(element).perform()
# The element is now positioned for a subsequent action.
element.click()
scroll_to_element() is the clearest choice when your intent is “make this element visible.” The documented behavior places the element’s bottom at the bottom of the screen, rather than promising a centered position. If your next operation depends on a different alignment, use JavaScript with an explicit option.
JavaScript alignment options
element = driver.find_element(By.CSS_SELECTOR, "#checkout")
driver.execute_script(
"arguments[0].scrollIntoView({block: 'center', inline: 'nearest'});",
element,
)
scrollIntoView() accepts normal DOM options. For a sticky header, center alignment often leaves the target unobscured; the correct value depends on your page layout. JavaScript executes in the current window or frame, so it does not cross an iframe boundary automatically.
Scroll by a defined amount
Wheel distance
from selenium.webdriver.common.action_chains import ActionChains
# Down 500 CSS pixels; use a negative vertical value to move up.
ActionChains(driver).scroll_by_amount(0, 500).perform()
ActionChains(driver).scroll_by_amount(0, -500).perform()
The deltas are relative to the viewport’s upper-left. Horizontal movement uses delta_x; vertical movement uses delta_y. A wheel delta is an input action, not a guarantee that a particular application has finished loading content afterward, so wait for a condition before continuing.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
JavaScript distance
driver.execute_script("window.scrollBy(0, arguments[0]);", 500)
driver.execute_script("window.scrollTo(0, 0);")
Use scrollBy() for relative movement and scrollTo() for an absolute document position. These calls manipulate the page context rather than synthesizing a wheel gesture, which can matter for sites that listen specifically for wheel events.
Scroll relative to an element or a viewport point
scroll_from_origin() is useful when a component has its own scrollable region or when the starting point matters. The origin can be an element, with an optional offset, or a viewport coordinate.
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.actions.wheel_input import ScrollOrigin
from selenium.webdriver.common.by import By
panel = driver.find_element(By.CSS_SELECTOR, ".results-panel")
origin = ScrollOrigin.from_element(panel)
ActionChains(driver).scroll_from_origin(origin, 0, 200).perform()
To start from an offset inside the element, construct the origin with that offset according to your binding’s API. If the element origin is outside the viewport, Selenium first brings it into view. An offset that lands outside the viewport raises an exception. This method is distinct from scrolling the document: it gives the wheel action a defined origin, which is important for nested panels.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Scroll a nested, scrollable container
For a container with overflow: auto or overflow: scroll, first identify the container, then use an element origin or JavaScript on that element.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11panel = driver.find_element(By.CSS_SELECTOR, ".results-panel")
driver.execute_script(
"arguments[0].scrollTop = arguments[0].scrollTop + arguments[1];",
panel,
300,
)
If the container is virtualized, newly rendered rows may not exist until scrolling triggers the framework. Wait for the row you need instead of assuming one large movement renders every item.
Wait for content after scrolling
Scrolling and rendering are separate operations. Use an explicit wait for a visible, present, or stateful result.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
row = WebDriverWait(driver, 15).until(
EC.presence_of_element_located((By.CSS_SELECTOR, "[data-row-id='42']"))
)
ActionChains(driver).scroll_to_element(row).perform()
WebDriverWait(driver, 10).until(EC.visibility_of(row))
For lazy images, wait for an attribute such as complete or for a nonempty rendered size when that is how the application signals readiness. Avoid fixed sleeps unless the page offers no observable condition.
Complete Python example
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
URL = "https://example.com/catalog"
with webdriver.Chrome() as driver:
driver.set_window_size(1280, 900)
driver.get(URL)
wait = WebDriverWait(driver, 15)
# Fixed movement.
ActionChains(driver).scroll_by_amount(0, 600).perform()
# Wait for a lazy-loaded target, then bring it into view.
target = wait.until(
EC.presence_of_element_located((By.CSS_SELECTOR, "[data-testid='details']"))
)
ActionChains(driver).scroll_to_element(target).perform()
# Align it away from a sticky header and verify visibility.
driver.execute_script(
"arguments[0].scrollIntoView({block: 'center'});", target
)
wait.until(EC.visibility_of(target))
print(target.text)
Browser and binding compatibility
The official Selenium wheel-actions page is explicitly labeled “Chromium Only.” Do not assume identical wheel behavior in Firefox, Safari, remote providers, or every language binding. Check the current Selenium documentation and the binding’s API reference for your exact browser version. JavaScript scrolling is the fallback when wheel support or event semantics do not meet your needs, but it still runs inside the current page and frame.
Recommended Free Tools
Troubleshooting scrolling failures
The element is located but click still fails
- Cause: Actions do not automatically scroll targets into view, or a sticky header covers the target.
- Fix: Call
scroll_to_element(), then usescrollIntoView({block: 'center'})and wait for clickability. Confirm that an overlay is not intercepting the click.
Nothing moves
- Cause: The active scroll region is a nested container, the page is already at an edge, or focus is in another frame.
- Fix: Switch to the correct iframe, use an element origin for the container, and inspect whether its
scrollHeightexceedsclientHeight.
An origin or offset raises an exception
- Cause: The origin element is outside the viewport, or the requested offset falls outside it.
- Fix: scroll the origin into view first, reduce the offset, and retry after layout settles.
Lazy-loaded content never appears
- Cause: The script moves before the application observes the scroll, or content requires incremental movement.
- Fix: scroll in smaller increments, wait for the expected DOM change, and inspect network or application-state errors rather than adding an arbitrary long sleep.
Wheel actions fail in a non-Chromium browser
- Cause: The documented wheel guide’s coverage is Chromium Only.
- Fix: verify support for that browser and binding, or use the JavaScript approach where page-level scrolling is sufficient.
Performance, reliability, and test design
- Prefer one target-based scroll over dozens of small wheel events when the test only needs a particular control.
- Use explicit waits tied to DOM state, visibility, or application events; fixed delays make tests slower and still flaky.
- Keep viewport size consistent when pixel distances affect assertions.
- For infinite feeds, define a stop condition such as a target row, a loading marker disappearing, or no increase in item count. Otherwise a loop can run forever.
- Capture diagnostics on failure: current URL, viewport dimensions, screenshot, and the target’s bounding rectangle.
- Use JavaScript only when its semantics are acceptable; it may not trigger the same listeners as a real wheel gesture.
Or skip the browser setup
If your goal is a clean page image or PDF rather than interactive test input, ScreenshotNeo provides a single screenshot request. It accepts consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be disabled. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the result with X-Page-Verdict and X-Billed headers. Its MCP server exposes take_screenshot, get_page_info, and capture_pdf to Claude, Cursor, and other MCP clients.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for all options, including full-page lazy-image loading, CSS-selector element capture, device and viewport settings, retina scale, PDF controls, custom JavaScript and CSS, click actions, wait conditions, request blocking, headers, cookies, timezone, geolocation, transparency, resizing, caching, signed links, asynchronous webhooks, bulk capture, usage data, and OpenAPI compatibility.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
The Free plan includes 1,000 screenshots per month with no card. Paid plans start at $5 for 3,000 shots; every feature is on every plan. Create a free ScreenshotNeo account to start.
Frequently Asked Questions
Which Selenium version has wheel scrolling?
The wheel input API was introduced in Selenium 4.2; verify the current binding documentation before relying on a particular method.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Can Selenium scroll an element inside an iframe?
Yes, after switching to that iframe with the WebDriver frame API. Locate and scroll the element while that frame is active.
Should I use wheel actions or JavaScript for end-to-end tests?
Use wheel actions when realistic input and browser event behavior matter. Use JavaScript when you need deterministic DOM alignment or when wheel support is unavailable for the target browser.
Quick Recap
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.

