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

For ordinary Playwright locator actions, an element being below, above, or beside the current viewport is usually not an error: actions such as click() wait for actionability and scroll the target into view. When you need to establish the position yourself, call scrollIntoViewIfNeeded(), then assert the viewport condition with toBeInViewport(). If the action still fails, investigate the locator, overlays, and other actionability checks instead of treating scrolling as the complete fix.

This guide shows the reliable patterns, version caveats, screenshot differences, and a troubleshooting workflow. The examples use TypeScript, followed by options for deliberate scrolling and a browser-free screenshot route.

The shortest reliable fix

Start with a user-facing locator and the action you actually want to test. Playwright’s locator actions perform their documented actionability checks and handle the required scrolling.

const continueButton = page.getByRole('button', { name: 'Continue' });
await continueButton.click();

Prefer roles, accessible names, labels, and other meaningful locators over brittle positional selectors. Locators are retried while the page changes, so the locator should describe the control a user would recognize. See the Playwright locators guide and Locator API for the current behavior.

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.
#1 Best Overall
Sale
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
  • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents

If position itself is part of the test—for example, you want a screenshot or a separate viewport assertion—make the scroll explicit:

const target = page.getByRole('button', { name: 'Continue' });
await target.scrollIntoViewIfNeeded();
await expect(target).toBeInViewport();
await target.click();

scrollIntoViewIfNeeded() waits for actionability and attempts to scroll only when the element is not completely visible according to the browser’s IntersectionObserver ratio. It is not a command to keep forcing the page to move.

What “outside the viewport” actually means

The viewport is the currently visible browser area, not the complete document. A target can be outside it because the page is long, because a nested panel scrolls independently, or because the target moved while the page was loading. Viewport position is only one part of actionability.

Automatic scrolling during actions

For a normal locator action, Playwright first waits for the actionability conditions documented for that action and scrolls the target into view when necessary. This is why a direct click() is normally preferable to a hand-written scroll followed by a click. The official Actions guide summarizes the behavior as: “Most of the time, Playwright will automatically scroll for you before doing any actions.” Read the Actions documentation for the complete sequence.

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

Explicit scrolling for a separate check

Use an explicit call when the test needs to prove that a control has entered the viewport, when you are taking a targeted screenshot, or when the scroll is a meaningful step in the user journey:

Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
  • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
  • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
const target = page.getByTestId('checkout-continue');
await target.scrollIntoViewIfNeeded();
await expect(target).toBeInViewport({ ratio: 0.5 });

The assertion uses viewport intersection. With the default ratio of zero, any positive intersection satisfies the check. A ratio such as 0.5 requires at least that much intersection, which is useful when a sliver of a control is not sufficient for your test. The assertion API is documented at LocatorAssertions.

A repeatable diagnosis when the action still fails

  1. Run the intended locator action first. Use a role, label, text, or another locator that identifies the intended element. Do not add a manual scroll merely because the element starts below the fold.
  2. Make position explicit if it matters. Call scrollIntoViewIfNeeded(), then use toBeInViewport() with a ratio that matches the requirement.
  3. Read the failure as an actionability report. A viewport problem can coexist with an element that is covered, detached, changing, or otherwise not actionable. The Locator API documents these checks separately from scrolling.
  4. Verify that the locator points to the intended node. A successful scroll of the wrong matching element does not make the intended control clickable. Tighten the role, accessible name, label, or surrounding locator scope.
  5. Inspect the page state at the failure point. Capture a trace or screenshot from the same moment and look for a covering dialog, consent layer, animation, or a re-render that changes the target. Fix the page state or wait condition rather than bypassing the check.

Avoid making force: true the default response. It bypasses actionability checks; it does not demonstrate that a real user could see and activate the control. Use it only when bypassing those checks is an intentional part of the test.

Controlling whether Playwright may scroll

The Locator API documents a scroll action option. auto is the default: Playwright scrolls when required, including through nested scrollable containers. none disables that scrolling, so an action fails if the element is not already in the viewport.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const target = page.getByRole('button', { name: 'Continue' });
await target.click({ scroll: 'none' });

This option is marked as added in Playwright v1.62. Check the version installed in your project before using it. A deliberate scroll: 'none' test can expose a layout or focus problem, but it is not a general repair for an ordinary click.

When you need finer scrolling control

The Actions guide recommends finding the element that should become visible and scrolling it into view. For a controlled amount of movement rather than element-based scrolling, use the mouse wheel or evaluate a DOM scrolling method.

Rank #3
Sale
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
  • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
  • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
  • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
  • Ultra-thin bezels: Maximize your viewing experience with thin bezels.

Scroll by a measured wheel delta

await page.mouse.wheel(0, 600);
await expect(page.getByRole('button', { name: 'Continue' })).toBeInViewport();

A wheel event is useful when the test is explicitly modeling a user scroll or when a container responds to wheel input. Choose the delta for your page and keep the subsequent assertion tied to the element you need.

Ask the element to scroll itself

const target = page.locator('#continue');
await target.evaluate((element) => {
  element.scrollIntoView({ block: 'center', inline: 'nearest' });
});
await expect(target).toBeInViewport();

Use this only when the alignment matters. Element-based scrolling through the locator API is usually less brittle because it keeps the operation connected to the locator that will be acted on.

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

Viewport assertions and screenshots are different jobs

Checking visibility

toBeInViewport() checks whether the element intersects the viewport through the Intersection Observer API. The default ratio is zero; supply a ratio when partial visibility is not enough. The assertion answers “is this element intersecting the current viewport?” It does not replace an interaction action’s other actionability checks.

Capturing one element

locator.screenshot() waits for actionability and scrolls that locator into view before capturing it:

await target.screenshot({ path: 'continue.png' });

This positions the target for its own image. A covering element can still affect what the screenshot shows, just as it can affect a click.

Rank #4
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor
  • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
  • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
  • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
  • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
  • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient

Capturing the whole page

A page screenshot with fullPage: true captures the full scrollable page rather than only the current viewport:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
await page.screenshot({ path: 'page.png', fullPage: true });

Full-page capture does not make an off-screen control actionable; it is a page-length image option. The Page API and Locator API document these separate screenshot behaviors.

Common errors and the right correction

Symptom Likely interpretation Correction
The click waits, then times out saying the element is outside the viewport The target never became actionable, or the locator resolved to a changing/wrong node. Try the direct locator action, then explicitly call scrollIntoViewIfNeeded() and inspect the target and page state if it still fails.
toBeInViewport() fails although the element is partly visible The required intersection ratio is larger than the visible portion. Use the default ratio for any positive intersection, or choose a ratio that expresses the amount of visibility you actually require.
The target is in view but a click is rejected Scrolling succeeded, but another actionability condition did not. Check for an overlay, a moving or detached element, and whether the locator identifies the intended control. Do not treat force as the normal fix.
A manual scroll moves the page but the control remains unavailable The control may live in a nested scroll container, or the page changed after the scroll. Scroll the located element, or target the appropriate container with the documented wheel/evaluate techniques, then assert the result.
scroll: 'none' is rejected as an unknown option Your installed Playwright version may predate the option. Check the installed version; the Locator API marks the option as added in v1.62. Until then, use the normal action or an explicit scroll and assertion.
A locator screenshot does not show the intended pixels The locator was positioned, but another element may cover it. Inspect the covering state. A locator screenshot and a full-page page screenshot answer different questions.

Keeping tests reliable without unnecessary scrolling

  • Let actions do their normal work. Every extra scroll is another page operation that can make a test slower or more sensitive to layout changes. Add one when position is part of the requirement, not as a reflex.
  • Assert the condition you mean. Use a ratio when “barely intersects” is not good enough; otherwise the default intersection check is less restrictive.
  • Keep locator and assertion together. Reuse the same locator for scrolling, viewport assertion, screenshot, and action so a later step cannot silently target a different match.
  • Separate screenshot intent from interaction intent. Full-page images document page length; locator screenshots document one target after it is positioned. Neither substitutes for an actionable click.
  • Check version metadata before adopting newer options. In particular, the scroll option is documented as v1.62, while toBeInViewport is documented as added in v1.31.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If you only need a clean image or PDF of a URL, ScreenshotNeo is a website screenshot API and MCP server for developers. It accepts one request and returns PNG, JPEG, WebP, or PDF. Before capture it accepts cookie and consent banners as a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be turned off.

Only clean shots are billed. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, 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 for Claude, Cursor, and other MCP clients.

One GET request with cURL

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

See the ScreenshotNeo documentation for authentication, output formats, and all parameters.

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

Python

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://playwright.dev/docs/locators"}, timeout=90)
open("shot.webp", "wb").write(r.content)

Node.js

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://playwright.dev/docs/locators' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

Options useful for viewport-sensitive pages

  • Capture a full page with lazy images loaded, or capture one element by CSS selector.
  • Choose dark mode, any viewport, one of 12 device presets, and a retina scale.
  • Render PDFs with paper size, margins, landscape mode, and page ranges.
  • Supply custom CSS or JavaScript, click an element, hide selectors, and wait for a selector, delay, or network idle.
  • Block ads, trackers, requests, or resource types; set headers, cookies, user agent, Authorization, timezone, and geolocation.
  • Use transparent backgrounds, image resizing, a chosen cache TTL, signed links for public <img> tags, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, a usage API, and an OpenAPI specification.
  • Parameter names used by other screenshot APIs also work, which reduces changes when switching.

Plans and billing

Plan Included shots Price
Free 1,000 per month No card required
Starter 3,000 $5
Growth 15,000 $15
Pro 60,000 $39
Scale 250,000 $99
Business 1,000,000 $249

Every feature is available on every plan, and yearly billing gives two months free. If removing consent UI, popups, and chat widgets matters—or you want failed loads and bot checks excluded from billing—sign up for the free plan. It includes 1,000 screenshots a month with no card, and paid plans start at $5 for 3,000.

Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
  • 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
  • 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.

FAQ

Can an element intersect the viewport and still be unusable?

Yes. Viewport intersection is only one condition. A covering element, a detached or changing target, or a locator that resolves to the wrong node can still prevent an action. Keep the viewport assertion and the actionability diagnosis separate.

Should I use a full-page screenshot to debug an interaction timeout?

Use it when you need the complete document for visual context, but use a locator screenshot when you need the target positioned for its own image. Neither capture changes whether a click is actionable.

Is ScreenshotNeo a replacement for Playwright interaction tests?

No. ScreenshotNeo captures a URL, while Playwright drives and asserts browser interactions. Use Playwright for behavior and ScreenshotNeo when a one-request screenshot or PDF is the actual deliverable.

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

Frequently Asked Questions

Can an element intersect the viewport and still be unusable?

Yes. Viewport intersection is only one condition. A covering element, a detached or changing target, or a locator that resolves to the wrong node can still prevent an action.

Should I use a full-page screenshot to debug an interaction timeout?

Use it for complete-document context, but use a locator screenshot when you need the target positioned for its own image. Neither capture changes whether a click is actionable.

Is ScreenshotNeo a replacement for Playwright interaction tests?

No. ScreenshotNeo captures a URL, while Playwright drives and asserts browser interactions. Use Playwright for behavior and ScreenshotNeo for one-request screenshots or PDFs.

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.

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