new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Playwright · API reference · all subjects

mouse & keyboard interaction

43 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Frame.click() method parameters and options

Frame.click() is an async, discouraged method that clicks an element matching selector. Parameters: selector (element selector). Options: button (string, 'left'/'right'/'middle', default 'left'), clickCount (number, defaults to 1), delay (float, time in ms between mousedown and mouseup, default 0), force (boolean, skip actionability checks), scroll (boolean, scroll into view), modifiers (array of 'Alt'/'Control'/'Meta'/'Shift'), noWaitAfter (boolean, don't wait for navigation), position (object with x, y), strict (boolean), timeout (float/number), signal (AbortSignal), trial (boolean, perform action without executing it).

Frame.dblclick() method parameters and options

Frame.dblclick() is an async, discouraged method that double clicks an element. It dispatches two click events and a single dblclick event. Parameters: selector. Options: button (string, default 'left'), force (boolean), scroll (boolean), delay (float, time between click down and up in ms), modifiers (array), noWaitAfter (boolean), position (object), strict (boolean), timeout (float/number), signal (AbortSignal), trial (boolean). Note: if first click triggers navigation, method throws error.

Frame.dispatchEvent() parameters and usage

Frame.dispatchEvent() is an async, discouraged method that dispatches a DOM event on an element. Parameters: selector (element selector), type (string, DOM event type like 'click', 'dragstart'), eventInit (optional EvaluationArgument with event-specific initialization properties). Options: strict (boolean), timeout (float/number), signal (AbortSignal). Events are composed, cancelable, and bubble by default. Supports passing JSHandle as property value for live objects.

Frame.dragAndDrop() parameters and options

Frame.dragAndDrop() is an async method. Parameters: source (element selector to drag from), target (element selector to drag to). Options: force (boolean), scroll (boolean), noWaitAfter (boolean), strict (boolean), timeout (float/number), signal (AbortSignal), trial (boolean), sourcePosition (object with x, y), targetPosition (object with x, y), steps (number of intermediate steps for drag operation).

Frame.focus() method parameters and options

Frame.focus() is an async, discouraged method. Parameters: selector. Options: strict (boolean), timeout (float/number), signal (AbortSignal). Fetches element and focuses it. Waits for matching element if not immediately found.

Frame.hover() method parameters and options

Frame.hover() is an async, discouraged method. Parameters: selector. Options: position (object with x, y), modifiers (array), force (boolean), scroll (boolean), strict (boolean), timeout (float/number), signal (AbortSignal), trial (boolean), noWaitAfter (boolean). Hovers over element matching selector by finding it, checking actionability, scrolling if needed, and using Page.mouse to hover.

Frame.press() method parameters and options

Frame.press() is an async, discouraged method. Parameters: selector, key (string, keyboard key name or character to generate). Options: delay (float, time in ms between keydown and keyup, default 0), noWaitAfter (boolean), strict (boolean), timeout (float/number), signal (AbortSignal). Key can be F1-F12, Digit0-9, KeyA-Z, Backquote, Minus, Equal, Backslash, Backspace, Tab, Delete, Escape, Arrow keys, End, Enter, Home, Insert, PageDown, PageUp, Shift, Control, Alt, Meta, ShiftLeft, ControlOrMeta. Supports key combinations like 'Control+o', 'Control+Shift+T'.

Frame.tap() method parameters and options

Frame.tap() is an async, discouraged method. Parameters: selector. Options: force (boolean), scroll (boolean), modifiers (array), noWaitAfter (boolean), position (object), strict (boolean), timeout (float/number), signal (AbortSignal), trial (boolean). Taps element by finding it, checking actionability, scrolling if needed, and using Page.touchscreen to tap. Requires hasTouch option of browser context set to true.

Locator.click() method

Locator.click() is an async method that clicks an element by waiting for actionability checks, scrolling into view if needed, using Page.mouse to click the center or specified position, and waiting for navigations to complete. Supports options: button, clickCount, delay, position, modifiers, force, scroll, noWaitAfter, timeout, signal, trial, and steps.

Locator.dblclick() method

Locator.dblclick() is an async method that double-clicks an element by waiting for actionability checks, scrolling into view if needed, and using Page.mouse to double-click the center or specified position. In C# it is aliased as DblClickAsync. Dispatches two click events and one dblclick event. Supports options: button, delay, position, modifiers, force, scroll, noWaitAfter, timeout, signal, trial, and steps.

Locator.dispatchEvent() method

Locator.dispatchEvent() is an async method that programmatically dispatches a DOM event on the matching element. Takes parameters: type (string, DOM event type like 'click', 'dragstart', etc.) and optional eventInit (EvaluationArgument, event-specific initialization properties). Events are composed, cancelable, and bubble by default. Supports timeout and signal options.

Locator.dragTo() method

Locator.dragTo() is an async method that drags the source element to a target element or position and drops it. Moves to source, performs mousedown, moves to target, and performs mouseup. Takes parameter 'target' of type Locator. Supports options: force, scroll, noWaitAfter, timeout, signal, trial, sourcePosition, targetPosition, and steps.

Locator.drop() method

Locator.drop() is an async method that simulates an external drag-and-drop of files or clipboard data onto the locator element. Dispatches dragenter, dragover, and drop events with a synthetic DataTransfer. Throws if the target element's dragover listener does not call preventDefault(). Takes parameter 'payload' of type drop payload. Supports options: position, timeout, and signal.

Locator.hover() method

Locator.hover() is an async method that hovers over the matching element by waiting for actionability checks, scrolling into view if needed, and using Page.mouse to hover over the center or specified position. Supports options: position, modifiers, force, scroll, timeout, signal, trial, and noWaitAfter.

Locator.press() presses keyboard keys on focused element

Locator.press() focuses the matching element and presses a combination of keys. It accepts a key parameter (string) specifying the key name or character to generate, such as 'Backspace', 'F1', 'ArrowDown', etc. Optional parameters include: delay (float, defaults to 0) for time between keydown and keyup in milliseconds, noWaitAfter, timeout, and signal. Supports modifier shortcuts like 'Shift', 'Control', 'Alt', 'Meta', 'ShiftLeft', 'ControlOrMeta', and compound shortcuts like 'Control+o' or 'Control+Shift+T'. Available since v1.14.

Locator.pressSequentially() sends key events one character at a time

Locator.pressSequentially() focuses the element and sends keydown, keypress/input, and keyup events for each character in the provided text string. It is preferred over Locator.type() for special keyboard handling. Parameters: text (string) - the characters to sequentially press. Options: delay (float, defaults to 0) for time between key presses in milliseconds, noWaitAfter, timeout, and signal. Available since v1.38.

Locator.tap() performs touch tap gesture on element

Locator.tap() performs a tap gesture on the element by: waiting for actionability checks (unless force option set), scrolling element into view if needed, using Page.touchscreen to tap the center or specified position. Requires that the browser context hasTouch option be set to true. Options: position, modifiers, force, scroll, noWaitAfter, timeout, signal, trial. Available since v1.14.

Locator.press() example pressing Backspace key

Example showing Locator.press() usage: ```python await page.get_by_role("textbox").press("Backspace") ``` This focuses a textbox locator and presses the Backspace key.

Locator.pressSequentially() example typing with delay

Example showing Locator.pressSequentially() usage: ```python await locator.press_sequentially("hello") # types instantly await locator.press_sequentially("world", delay=100) # types slower, like a user ``` And typing into a password field then submitting: ```python locator = page.get_by_label("Password") await locator.press_sequentially("my password") await locator.press("Enter") ```

input-source and input-target for drag operations

input-source: The source parameter is type string, a selector to search for element to drag. If multiple elements satisfy selector, first is used. input-target: The target parameter is type string, a selector to search for element to drop onto. If multiple elements satisfy selector, first is used.

input-position: Position object for mouse/element operations

The position parameter is type Object with alias Position. Contains x (float) and y (float) fields. A point relative to top-left corner of element padding box. If not specified, uses visible point of the element.

input-drag-steps: steps parameter for drag operations

The steps parameter is type int. Defaults to 1. Sends n interpolated mousemove events between mousedown and mouseup of drag. When set to 1, emits single mousemove event at destination.

input-modifiers: modifier keys for keyboard operations

The modifiers parameter is type Array of KeyboardModifier ('Alt', 'Control', 'ControlOrMeta', 'Meta', 'Shift'). Modifier keys to press. Ensures only these modifiers pressed during operation, then restores. If not specified, uses currently pressed modifiers. 'ControlOrMeta' resolves to 'Control' on Windows/Linux, 'Meta' on macOS.

input-button: mouse button parameter

The button parameter is type MouseButton ('left', 'right', 'middle'). Defaults to 'left'.

drop-payload: DropPayload structure for drag-drop operations

The payload parameter is type Object (DropPayload alias). Contains optional files (path, Array<path>, Object, or Array<Object>, with FilePayload structure: name, mimeType, buffer) and optional data (Object<string, string> for mime-type to string map like text/plain, text/html, text/uri-list). Provide files, data, or both.

input-down-up-delay: delay parameter for mouse down/up

The delay parameter is type float. Time to wait between mousedown and mouseup in milliseconds. Defaults to 0.

input-click-count: clickCount parameter for click operations

The clickCount parameter is type int, defaults to 1. See UIEvent.detail.

input-trial-with-modifiers: trial with keyboard modifiers

The trial parameter is type boolean. When set, performs actionability checks only and skips action. Defaults to false. Useful to wait until element ready without performing. Note: keyboard modifiers pressed regardless of trial to test elements visible only with those keys.

input-source-position and input-target-position for drag

input-source-position: Object (alias-java: Position) with x (float), y (float) relative to top-left of source element padding box. Clicks source at this point. If not specified, uses visible point. input-target-position: Object with x (float), y (float) relative to top-left of target element padding box. Drops at this point. If not specified, uses visible point.

Page.click clicks element

The async method Page.click (since v1.8, discouraged - use Locator.click instead) clicks an element matching the selector by: finding the element, waiting for actionability checks, scrolling into view if needed, using Page.mouse to click in the center or specified position, and waiting for initiated navigations. Returns undefined. Throws TimeoutError if not completed in time. Parameters: selector. Options: button, clickCount, delay, force, scroll, modifiers, noWaitAfter, position, strict, timeout, signal, trial.

Page.dblclick double clicks element

The async method Page.dblclick (since v1.8, discouraged - use Locator.dblclick instead) double clicks an element matching the selector by: finding the element, waiting for actionability checks, scrolling into view if needed, and using Page.mouse to double click. Note: dblclick() dispatches two click events and a single dblclick event. Returns undefined. Throws TimeoutError if not completed in time. Parameters: selector. Options: button, force, scroll, delay, modifiers, noWaitAfter, position, strict, timeout, signal, trial.

Page.dispatchEvent dispatches DOM event on element

The async method Page.dispatchEvent (since v1.8, discouraged - use Locator.dispatchEvent instead) dispatches a DOM event on an element matching the selector. Creates an instance of an event based on the given type, initializes it with eventInit properties, and dispatches it on the element. Events are composed, cancelable and bubble by default. Returns undefined. Parameters: selector, type (DOM event type string like 'click'), optional eventInit (event-specific properties). Options: strict, timeout, signal. JSHandle can be used as property value for live objects.

Page.dragAndDrop drags source element to target

The async method Page.dragAndDrop (since v1.13) drags the source element to the target element. It moves to the source element, performs a mousedown, then moves to the target element and performs a mouseup. Returns undefined. Parameters: source (selector), target (selector). Options: force, scroll, noWaitAfter, strict, timeout, signal, trial, sourcePosition (object with x, y), targetPosition (object with x, y), steps (since v1.57).

Page.dispatchEvent example triggers click event

Example showing Page.dispatchEvent usage. Code: await page.dispatchEvent('button#submit', 'click'); This dispatches a click event on the element, equivalent to calling element.click().

Page.dispatchEvent example with DataTransfer for drag

Example showing Page.dispatchEvent with JSHandle. Code creates a DataTransfer object using evaluateHandle, then passes it to dispatchEvent for dragstart event: await page.dispatchEvent('#source', 'dragstart', { dataTransfer }).

Page.dragAndDrop example basic and with positions

Example showing Page.dragAndDrop usage. Basic: await page.dragAndDrop('#source', '#target'). With positions: await page.dragAndDrop('#source', '#target', { sourcePosition: { x: 34, y: 7 }, targetPosition: { x: 10, y: 20 } });

Page.hover - hover over element

Page.hover() is an async method (since v1.8, discouraged in favor of Locator.hover) that hovers over an element matching a selector. Steps: 1) Find element matching selector, wait if needed. 2) Perform actionability checks. 3) Scroll into view if needed. 4) Use Page.mouse to hover over center or specified position. Accepts: selector (CSS selector). Options: force (boolean, since v1.8), scroll (boolean, since v1.62), modifiers (array of modifier keys, since v1.8), position (x, y coordinates, since v1.8), strict (boolean, since v1.14), timeout (number, since v1.8), signal (AbortSignal), trial (boolean, since v1.11), noWaitAfter (since v1.28).

Page.keyboard property

Page.keyboard is a property (since v1.8) of type Keyboard that provides access to keyboard interaction methods.

Page.mouse property

Page.mouse is a property (since v1.8) of type Mouse that provides access to mouse interaction methods.

Page.press - press key

Page.press() is an async method (since v1.8, discouraged in favor of Locator.press) that focuses an element and presses a key. Accepts: selector (CSS selector), key (string - keyboardEvent.key value or single character). Key can be F1-F12, Digit0-9, KeyA-Z, and special keys like Backspace, Tab, Escape, etc. Shortcuts like 'Control+o' supported. Options: delay (float in milliseconds, default 0), noWaitAfter (boolean), strict (boolean, since v1.14), timeout (number, since v1.8), signal (AbortSignal).

Page.tap method

Page.tap() (async, added in v1.8, discouraged in favor of Locator.tap) taps an element matching selector. Waits for actionability checks (unless force option set), scrolls into view if needed, uses Page.touchscreen to tap center or specified position. Throws TimeoutError if not finished within specified timeout. Throws if Browser.newContext.hasTouch is false. Options: force, scroll (v1.62), modifiers, noWaitAfter, position, strict, timeout, signal, trial (v1.11).

Page.touchscreen property

Page.touchscreen is a property (added in v1.8) that returns a Touchscreen object for touch interactions.

Page.type method

Page.type() (async, added in v1.8, deprecated in favor of Locator.fill or Locator.pressSequentially) sends keydown, keypress/input, and keyup events for each character. Can send fine-grained keyboard events. For special keys like Control or ArrowDown, use Keyboard.press instead. Parameters: selector, text (string). Options: delay (time between key presses in milliseconds, defaults to 0), noWaitAfter, strict, timeout, signal.

Give your agent this brain