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.

When a Playwright TypeScript click fails, do not start with a longer timeout or a forced click. First read the error and call log, then verify that the locator identifies exactly one intended control, and finally fix the specific actionability condition that is blocking the real interaction. Playwright’s locator.click() waits for the element to be visible, stable, enabled, able to receive events, and in view before clicking.

Use the failure message to choose the right fix

Playwright failures that look similar usually have different causes. Separate strict-mode errors from timeouts before changing code.

Strict mode violation

A strict-mode error means the locator matched more than one element for an action that requires one target. The click did not fail because the browser was slow; it failed because Playwright cannot safely choose a button.

await page.getByRole('button', { name: 'Save' }).click();

If two “Save” buttons exist, scope the locator to the relevant dialog, form, or card and make the accessible name more specific:

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
Logitech M185 Compact Ambidextrous 2.4 GHz Wireless Mouse - Swift Grey
  • Compact Mouse: With a comfortable and contoured shape, this Logitech ambidextrous wireless mouse feels great in either right or left hand and is far superior to a touchpad
  • Durable and Reliable: This USB wireless mouse features a line-by-line scroll wheel, up to 1 year of battery life (2) thanks to a smart sleep mode function, and comes with the included AA battery
  • Universal Compatibility: Your Logitech mouse works with your Windows PC, Mac, or laptop, so no matter what type of computer you own today or buy tomorrow your mouse will be compatible
  • Plug and Play Simplicity: Just plug in the tiny nano USB receiver and start working in seconds with a strong, reliable connection to your wireless computer mouse up to 33 feet / 10 m (5)
  • Better than touchpad: Get more done by adding M185 to your laptop; according to a recent study, laptop users who chose this mouse over a touchpad were 50% more productive (3) and worked 30% faster (4)
const dialog = page.getByRole('dialog', { name: 'Profile settings' });
await dialog.getByRole('button', { name: 'Save changes' }).click();

Timeout while waiting to click

A timeout means the locator may be correct, but the element did not become actionable before the deadline. The call log normally identifies whether the element was hidden, moving, disabled, or covered by another element. Treat each condition differently instead of adding a blind sleep.

Confirm that the locator names the intended element

Prefer user-facing locators: a role with an accessible name, a label for a form control, visible text when it is stable, or a deliberately assigned test ID. The goal is a locator that remains correct when the layout changes.

Check the match count

const saveButton = page.getByRole('button', { name: 'Save changes' });
console.log('matches:', await saveButton.count());
await expect(saveButton).toHaveCount(1);
await saveButton.click();

A count of zero indicates a missing or not-yet-rendered control. A count above one indicates that the locator needs more context. Do not automatically use .first(), .last(), or .nth(); positional selection can silently click the wrong control after a page change.

Scope by meaningful structure

const checkout = page.getByRole('region', { name: 'Checkout' });
await checkout.getByRole('button', { name: 'Place order' }).click();

When no reliable role or name exists, a stable test ID is preferable to a long CSS or XPath chain:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
await page.getByTestId('submit-order').click();

Use CSS selectors for implementation-specific cases, but keep them short and intentional. A selector tied to generated class names is likely to break.

Rank #2
Sale
Logitech G305 Lightspeed Wireless Gaming Mouse - Black
  • The next-generation optical HERO sensor delivers incredible performance and up to 10x the power efficiency over previous generations, with 400 IPS precision and up to 12,000 DPI sensitivity
  • Ultra-fast LIGHTSPEED wireless technology gives you a lag-free gaming experience, delivering incredible responsiveness and reliability with 1 ms report rate for competition-level performance
  • G305 wireless mouse boasts an incredible 250 hours of continuous gameplay on just 1 AA battery; switch to Endurance mode via Logitech G HUB software and extend battery life up to 9 months
  • Wireless does not have to mean heavy, G305 lightweight mouse provides high maneuverability coming in at only 3.4 oz thanks to efficient lightweight mechanical design and ultra-efficient battery usage
  • The durable, compact design with built-in nano receiver storage makes G305 not just a great portable desktop mouse, but also a great laptop travel companion, use with a gaming laptop and play anywhere

Understand Playwright’s click actionability checks

Before a locator click, Playwright performs checks designed to model a real user interaction. It scrolls the target into view, verifies visibility, waits for a stable position, checks that it is enabled, and confirms that the click point can receive events.

Hidden or not rendered

A matching element can exist in the DOM while its panel is closed, its parent is hidden, or a responsive breakpoint has removed it from view. Open the required UI state first and assert visibility:

await page.getByRole('button', { name: 'Open menu' }).click();
const account = page.getByRole('link', { name: 'Account' });
await expect(account).toBeVisible();
await account.click();

Moving or animating

Playwright waits for the element to stop moving. If a transition never settles, fix the application state or disable nonessential animation in the test environment. Waiting for a meaningful state is better than sleeping for an arbitrary number of milliseconds.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
await expect(page.getByRole('status')).toHaveText('Ready');
await page.getByRole('button', { name: 'Continue' }).click();

Disabled

Buttons can remain disabled until validation, a request, or a required checkbox completes. Assert the prerequisite and enabled state:

await page.getByLabel('I agree to the terms').check();
const continueButton = page.getByRole('button', { name: 'Continue' });
await expect(continueButton).toBeEnabled();
await continueButton.click();

Another element receives the event

A cookie banner, modal backdrop, sticky header, loading mask, or chat widget can cover the target. The call log can show that another element intercepts pointer events. Close or remove the overlay as a user would, then click the underlying control.

const consent = page.getByRole('button', { name: 'Accept all cookies' });
if (await consent.isVisible()) {
  await consent.click();
}
await page.getByRole('button', { name: 'Start download' }).click();

If the overlay is irrelevant to the test, configure the application or test fixture to prevent it. Hiding an overlay should be an explicit test decision, not a random delay.

Rank #3
Sale
Logitech M185 Compact Ambidextrous Wireless Mouse with Rubber Grips - Blue
  • Compact Mouse: With a comfortable and contoured shape, this Logitech ambidextrous wireless mouse feels great in either right or left hand and is far superior to a touchpad
  • Durable and Reliable: This USB wireless mouse features a line-by-line scroll wheel, up to 1 year of battery life (2) thanks to a smart sleep mode function, and comes with the included AA battery
  • Universal Compatibility: Your Logitech mouse works with your Windows PC, Mac, or laptop, so no matter what type of computer you own today or buy tomorrow your mouse will be compatible
  • Plug and Play Simplicity: Just plug in the tiny nano USB receiver and start working in seconds with a strong, reliable connection to your wireless computer mouse up to 33 feet / 10 m (5)
  • Better than touchpad: Get more done by adding M185 to your laptop; according to a recent study, laptop users who chose this mouse over a touchpad were 50% more productive (3) and worked 30% faster (4)

Use the call log and debugging tools

Run the failing test with Playwright’s headed or inspector-based debugging options and read the action log. It shows the resolved locator and the condition Playwright is retrying. Add a screenshot or trace at the failure point when the page is visually different from what the test expects.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
npx playwright test tests/checkout.spec.ts --debug

Useful diagnostic assertions include:

await expect(locator).toHaveCount(1);
await expect(locator).toBeVisible();
await expect(locator).toBeEnabled();
console.log(await locator.evaluate(el => ({
  tag: el.tagName,
  text: el.textContent,
  rect: el.getBoundingClientRect().toJSON()
})));

Inspect the page at the moment of failure, not only after the test has already navigated away. A trace or screenshot can reveal a dialog, animation, or responsive layout that is invisible from the TypeScript source.

Wait for the condition, not for time

Playwright locators already retry relevant checks. A fixed waitForTimeout adds elapsed time without proving that the UI is ready and often creates flaky tests. Wait for a URL, response, state, or assertion that represents the user-visible condition.

await page.getByRole('button', { name: 'Submit' }).click();
await expect(page).toHaveURL(//confirmation/);
await expect(page.getByRole('heading', { name: 'Thank you' })).toBeVisible();

For a component that appears after a request, wait for its presence or content:

await expect(page.getByRole('list', { name: 'Results' })).toBeVisible();
await expect(page.getByRole('listitem')).toHaveCount(10);
await page.getByRole('listitem').first().click();

Raise timeouts only when the delay is legitimate

You can set a timeout for one action:

await page.getByRole('button', { name: 'Generate report' }).click({ timeout: 15000 });

Or configure an action timeout for a project:

import { defineConfig } from '@playwright/test';

export default defineConfig({
  use: {
    actionTimeout: 10000
  }
});

Use a larger value only when you have identified a genuinely slow operation, such as a report that is known to become enabled after a long server calculation. If increasing the timeout merely makes a flaky test fail later, investigate the locator, overlay, animation, navigation, or application error instead.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Amazon Basics 3-Button USB Wired Mouse with Responsive Tracking, Plug & Play, Compatible with Windows and Mac, Black
  • Computer mouse for easily navigating a computer interface; click, scroll, and more
  • USB-A wired connection; if existing device only supports USB-C, an additional adapter will be required
  • High-definition (1000 dpi) optical tracking ensures responsive cursor control for precise tracking and easy text selection
  • 3 buttons offer effortless fingertip control
  • Plug-and-go ready for instant use

Do not confuse forced and programmatic clicks with real interaction

force: true

force bypasses actionability checks, including checks related to whether the target can receive click events:

await locator.click({ force: true });

This can be appropriate for a specialized test of a handler that intentionally sits behind another layer, but it does not prove that a user could click the control. It can also hide a regression such as a permanent modal backdrop.

dispatchEvent('click')

dispatchEvent('click') sends a programmatic event regardless of normal visibility and hit-testing:

await locator.dispatchEvent('click');

Use it only when the test specifically targets event-dispatch behavior. For end-to-end interaction, keep the normal locator click so failures expose broken UI state.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Prefer locator clicks over the Page API

The locator API carries strictness, retrying, and actionability semantics with the target. The older page-level form is discouraged:

Best Value
Sale
Acer Wireless Mouse for Laptop, 2.4GHz Computer Mouse 3 Adjustable 1600 DPI
  • 【Plug and Play for Home/Office/School】The wireless computer mouse features 2.4GHz connectivity, delivering a stable, interference-free connection up to 32ft. Designed for 𝐦𝐞𝐝𝐢𝐮𝐦 𝐭𝐨 𝐥𝐚𝐫𝐠𝐞 𝐬𝐢𝐳𝐞𝐝 𝐡𝐚𝐧𝐝𝐬, it ensures comfortable use all day. Simply plug in the USB-A receiver for instant pairing—no drivers needed. 📌📌 If the mouse isn’t suitable, place the USB receiver in the battery compartment and return both.
  • 【3 Levels Adjustable DPI】This travel USB mouse offers 3 adjustable DPI settings (800, 1200, 1600), allowing you to customize sensitivity for precise design work. Effortlessly switch to match your task and elevate your productivity. 📌 Please remove the film at the bottom of the mouse before use.
  • 【Effortless Browsing】Equipped with forward and backward buttons, this computer mice streamlines your workflow, making it easy to navigate through web pages and files with a simple click. 📌Side button does not work on Mac.
  • 【Visible Indicator Light】 The pc mouse features a visual indicator for DPI levels and low battery alerts. The red light flashes once for 800 DPI, twice for 1200 DPI, and three times for 1600 DPI. When the battery level is below 10%, the light flashes red until the mouse is completely out of power.
  • 【Click to Wake】With smart sleep mode, it saves power by standby after 10 inactive minutes, just 2-3 clicks to wake. This efficient design delivers 3x longer battery life than motion-wake mice. Engineered for durability, its buttons and scroll wheel are tested for 10 million clicks, ensuring long-term reliability and consistent performance.
// Prefer
await page.getByRole('button', { name: 'Save' }).click();

// Avoid for new code
await page.click('button.save');

Converting page-level selectors to locators also makes it easier to assert uniqueness and scope a control to its component.

A repeatable diagnosis checklist

  1. Read the exact error and call log.
  2. Check locator.count() and require one match.
  3. Confirm the locator’s accessible name and scope.
  4. Assert visibility, enabled state, and the prerequisite UI state.
  5. Look for overlays, pointer-event blockers, and unfinished animation.
  6. Use headed debugging, screenshots, or a trace at the failure point.
  7. Replace sleeps with assertions about UI state, URL, or responses.
  8. Increase the timeout only after proving the condition is legitimately slow.
  9. Reserve force and dispatchEvent for tests whose semantics explicitly require bypassing real interaction.

Or skip the browser setup

If your goal is a clean image of a page rather than an interaction test, ScreenshotNeo provides a single screenshot API request. It accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be disabled. Bot checks, CAPTCHAs, 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 offers take_screenshot, get_page_info, and capture_pdf for 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 and element capture, device presets, custom CSS and JavaScript, blocking rules, authentication headers, cookies, geolocation, PDF settings, caching, signed links, asynchronous webhooks, bulk capture, and usage reporting.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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, and every feature is available on every plan. Create a free ScreenshotNeo account.

Frequently Asked Questions

Why does a click work locally but fail in CI?

Compare the CI trace or screenshot with local output. Differences in viewport, browser, fonts, network speed, consent overlays, and environment variables can change which element is visible or enabled; diagnose that changed condition rather than adding a sleep.

Should I use a CSS selector or a role locator?

Use a role and accessible name when the control is user-facing. Use a stable test ID when semantics are unavailable or intentionally unstable. Reserve CSS for implementation-specific cases.

Can I test a click without navigating away?

Yes. Click normally, then assert the resulting UI state, such as a dialog, status message, enabled control, or network-driven content, instead of relying on a fixed delay.

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

Quick Recap

SaleBestseller No. 1
Logitech M185 Compact Ambidextrous 2.4 GHz Wireless Mouse - Swift Grey
Logitech M185 Compact Ambidextrous 2.4 GHz Wireless Mouse - Swift Grey
Product carbon footprint: 3.97 kg CO2e; Contoured shape: Gives you more comfort and control
$14.90
SaleBestseller No. 3
Bestseller No. 4
Amazon Basics 3-Button USB Wired Mouse with Responsive Tracking, Plug & Play, Compatible with Windows and Mac, Black
Amazon Basics 3-Button USB Wired Mouse with Responsive Tracking, Plug & Play, Compatible with Windows and Mac, Black
Computer mouse for easily navigating a computer interface; click, scroll, and more; 3 buttons offer effortless fingertip control
$9.70

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.