Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minuteSome links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
Use a locator and call dblclick():
await page.getByText('Item').dblclick();
In Python, the equivalent is:
page.get_by_text("Item").dblclick()
Locator-based interaction is Playwright’s current pattern. It identifies the intended element, waits for normal actionability checks, scrolls it into view when necessary, and performs a real mouse double-click. The older selector-based page.dblclick() method is discouraged for new code.
Use a locator, not a page-level selector
A locator keeps the action tied to the element your test means to use. Prefer a role, accessible name, label, or other unique locator over a broad CSS or text selector.
JavaScript and TypeScript
import { test, expect } from '@playwright/test';
test('opens an item on double-click', async ({ page }) => {
await page.goto('https://example.com/items');
const item = page.getByRole('row', { name: 'Item' });
await item.dblclick();
await expect(page.getByRole('heading', { name: 'Item details' })).toBeVisible();
});
The same call works in a plain Playwright script once you have a Page object:
await page.getByText('Item').dblclick();
Python
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
browser = p.chromium.launch()
page = browser.new_page()
page.goto('https://example.com/items')
page.get_by_text("Item").dblclick()
assert page.get_by_role("heading", name="Item details").is_visible()
browser.close()
For an asynchronous Python test, use the same locator method with await:
#1 Best Overall
- 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)
await page.get_by_text("Item").dblclick()
What Playwright does before and during the action
Actionability checks
By default, Playwright waits for the locator to resolve to an actionable element. It checks the normal readiness conditions, scrolls the element into view if needed, and then double-clicks its center. If the element is detached while the action is in progress, the action fails. If the configured timeout expires first, Playwright throws a timeout error.
These checks are useful: they expose a race in the page instead of hiding it. Use force only when you have deliberately decided that the page’s normal readiness checks are inappropriate.
Events generated
A locator double-click dispatches two click events followed by one dblclick event. If your application has both single-click and double-click handlers, account for that sequence in the test and in the application’s behavior. Assert the resulting state rather than merely asserting that the method returned.
Element detachment and timing
Virtualized lists, re-rendering frameworks, and navigation can replace a node between the first and second click. A locator is re-resolved for actions, but a node that disappears during the gesture can still make the action fail. Wait for the UI state that creates the target, use a locator that remains valid after re-rendering, and avoid arbitrary sleeps unless a real product delay must be modeled.
Options you can pass to dblclick()
The JavaScript and Python locator APIs expose the same practical controls, with language-specific syntax and timeout defaults.
| Option | Purpose | Important detail |
|---|---|---|
position |
Clicks a point inside the element. | The coordinates are relative to the element; Python documents the element’s padding box. JavaScript also accepts a relative position. |
button |
Selects the mouse button. | left is the default; right and middle are available. |
modifiers |
Holds keyboard modifiers during the gesture. | Supported values include Alt, Control, ControlOrMeta, Meta, and Shift. |
delay |
Waits between mouse-down and mouse-up. | The documented default is zero. It is not a general cure for flaky tests. |
force |
Skips actionability checks. | Use sparingly because it bypasses normal readiness safeguards. |
trial |
Runs readiness checks without performing the double-click. | Useful for diagnosing whether the target is actionable. |
timeout |
Sets the maximum wait for the action. | JavaScript’s locator reference gives a default of 0; Python’s locator reference gives a default of 30,000 ms. Set it explicitly when the distinction matters. |
JavaScript examples with options
// Double-click 12 pixels from the element's top-left padding-box corner
await page.getByRole('gridcell', { name: 'Item' }).dblclick({
position: { x: 12, y: 8 }
});
// Hold Control while using the right mouse button
await page.getByText('Item').dblclick({
button: 'right',
modifiers: ['Control']
});
// Check readiness without sending the gesture
await page.getByText('Item').dblclick({ trial: true });
// Bypass checks only for a known, intentional edge case
await page.getByText('Item').dblclick({ force: true });
Python examples with options
item = page.get_by_text("Item")
item.dblclick(position={"x": 12, "y": 8})
item.dblclick(button="right", modifiers=["Control"])
item.dblclick(trial=True)
item.dblclick(force=True)
Use the option names and value spelling for your installed language binding. API defaults and annotations can change between Playwright releases, so check the current language reference when upgrading.
Choosing a reliable locator
Prefer user-facing identity
A role plus accessible name is often more stable than a generated class name:
Free tools Windows power users keep installed
One-click scans. No signup required.
Rank #2
- 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
await page.getByRole('button', { name: 'Open Item' }).dblclick();
Text locators are appropriate when the visible text uniquely identifies the target:
await page.getByText('Item', { exact: true }).dblclick();
Disambiguate repeated matches
If several elements legitimately share the same text, narrow the locator to its container or use a more specific role and name. Do not rely on an accidental first match. A double-click that reaches the wrong row can still pass if the test asserts nothing afterward.
const row = page.getByRole('row').filter({ hasText: 'Item' });
await row.getByRole('cell', { name: 'Item' }).dblclick();
Assert the outcome
Follow the action with an assertion that represents the user-visible result: a dialog appears, a row enters edit mode, a URL changes, or a status message is shown. This catches both locator mistakes and pages that ignore the gesture.
When a position is necessary
Most tests should double-click the element without coordinates. Pass position when the control intentionally distinguishes regions inside one element, such as a canvas, timeline, map, or a cell whose left and right areas have different behavior.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →await page.locator('#timeline').dblclick({ position: { x: 240, y: 32 } });
The position is relative to the matched element, not the browser window. If the element moves responsively, choose a stable anchor or test the behavior at a fixed viewport instead of hard-coding page coordinates.
Modifier keys, mouse buttons, and delay
Modifiers
Pass an array of modifier names when the application defines a modified double-click. ControlOrMeta is useful when the same test should represent Control on Windows/Linux and Command on macOS.
await page.getByText('Item').dblclick({ modifiers: ['ControlOrMeta'] });
Non-left buttons
The default is the left button. A right-button or middle-button double-click is unusual and should be used only when the product explicitly implements it:
Rank #3
- 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)
await page.getByText('Item').dblclick({ button: 'middle' });
Delay
delay is the interval between mouse-down and mouse-up events. It does not mean “wait for the page to settle” and should not be added automatically to repair a flaky test. Fix the locator, page synchronization, or application race instead.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Timeouts and diagnosing failures
JavaScript timeout behavior
The JavaScript locator reference lists a default timeout of 0 for dblclick(). You can provide one operation-specific timeout:
await page.getByText('Item').dblclick({ timeout: 10_000 });
Python timeout behavior
The Python locator reference lists a default of 30,000 ms. Set it explicitly when a slower page is expected:
page.get_by_text("Item").dblclick(timeout=10_000)
Use trial to separate readiness from event handling
If the action fails before the event is sent, run a trial action. A successful trial indicates that the locator can become actionable; a failure points to visibility, attachment, stability, or timeout issues. If trial succeeds but the application does not respond, inspect the page’s event handlers and assert the emitted state.
The older page.dblclick() method
Playwright still exposes selector-based page methods in its API, but the JavaScript and Python page references mark page.dblclick() as discouraged and direct users to locator.dblclick(). Selector-based behavior can act on the first matching element when multiple elements match, which makes a broad selector risky.
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 & 11If maintaining legacy code, migrate in two steps: create a locator from the existing selector, then call dblclick() on that locator.
// Legacy style
await page.dblclick('.item');
// Preferred style
await page.locator('.item').dblclick();
Mouse-level double-clicking for coordinate-driven work
Use the mouse API when the test is genuinely about screen coordinates rather than an identified DOM element. This is useful for a canvas, a drawing surface, or a drag-and-drop style interaction where no meaningful locator exists. It gives up locator-based actionability and requires you to manage coordinates and page state yourself.
Rank #4
- 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
For an element-relative point, the locator’s position option is usually simpler and more resilient. For raw pointer control, use the mouse API’s mouse.dblclick method and consult the current language reference for its exact signature before pinning a coordinate-based test to a release.
Troubleshooting common failures
“Locator resolved to multiple elements”
Your selector is not unique. Add a role, accessible name, container filter, exact text match, or another stable condition. Avoid selecting an arbitrary first match unless that ordering is part of the product contract.
Timeout waiting for the element
The element may not exist yet, may be hidden, may be covered, or may keep moving during a re-render. Wait for the state that creates it, verify the locator in the trace or inspector, and increase the timeout only when the slower behavior is expected. Do not jump straight to force.
The element is detached during the double-click
A framework replaced the node between events. Locate the element through a stable parent or state, wait for the re-render to finish, and avoid triggering a navigation or update immediately before the gesture.
The page reacts to one click but not two
Remember that the gesture emits two click events and one dblclick event. Inspect whether the application cancels, debounces, or otherwise changes behavior after the first click. Assert the final UI state rather than assuming the browser event alone proves success.
The click lands in the wrong place
Check whether the locator matches the intended element and whether an overlay is intercepting input. If the product requires a particular point inside the element, use a relative position and keep the viewport deterministic.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →Using force makes the test pass but production behavior is wrong
force bypasses readiness checks; it does not make an unavailable control usable to a real visitor. Remove it unless bypassing those checks is the explicit behavior under test.
Best Value
- 【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.
Or skip the browser setup
If your goal is a clean screenshot after a page interaction rather than an interaction assertion, ScreenshotNeo provides a website screenshot API and MCP server. One GET request can return a PNG, JPEG, WebP, or PDF without maintaining Playwright browser setup.
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 documentation for request options and the complete API. The same call from Python is:
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)
And in Node.js:
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
- Cookie and consent banners are accepted like a visitor, then 60-plus known consent platforms, newsletter popups, and chat widgets are removed before the shot.
- Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing; response headers identify the page verdict and whether it was billed.
- An MCP server provides
take_screenshot,get_page_info, andcapture_pdftools for Claude, Cursor, and other MCP clients. - The Free plan includes 1,000 screenshots per month with no card. Paid plans start at $5 for 3,000 screenshots, and every feature is included on every plan.
Sign up for the free ScreenshotNeo plan to try it without a card.
Recommended Free Tools
Frequently Asked Questions
Can a double-click open a new tab or window?
Yes, if the page’s handler opens one. In that case, wait for the browser context’s new-page event around the double-click and then assert against the resulting page.
Is a mouse double-click equivalent to keyboard activation?
No. A double-click is a pointer gesture. If the control must also be usable from the keyboard, test its keyboard interaction separately rather than treating the mouse gesture as an accessibility check.
The Bottom Line
For normal Playwright tests, identify the target with a locator and call dblclick(); reserve coordinate-level mouse control for interactions that truly have no stable element target.
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.

