Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/src/api/class-elementhandle.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ If the element is detached from the DOM at any moment during the action, this me
When all steps combined have not finished during the specified [`option: timeout`], this method throws a
[TimeoutError]. Passing zero timeout disables this.

### option: ElementHandle.click.steps = %%-input-move-steps-%%
* since: v1.8

### option: ElementHandle.click.button = %%-input-button-%%
* since: v1.8

Expand Down Expand Up @@ -260,6 +263,9 @@ When all steps combined have not finished during the specified [`option: timeout
`elementHandle.dblclick()` dispatches two `click` events and a single `dblclick` event.
:::

### option: ElementHandle.dblclick.steps = %%-input-move-steps-%%
* since: v1.8

### option: ElementHandle.dblclick.button = %%-input-button-%%
* since: v1.8

Expand Down
5 changes: 5 additions & 0 deletions docs/src/api/class-locator.md
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,8 @@ await page.Locator("canvas").ClickAsync(new() {
});
```

### option: Locator.click.steps = %%-input-move-steps-%%
* since: v1.14

### option: Locator.click.button = %%-input-button-%%
* since: v1.14
Expand Down Expand Up @@ -553,6 +555,9 @@ When all steps combined have not finished during the specified [`option: timeout
`element.dblclick()` dispatches two `click` events and a single `dblclick` event.
:::

### option: Locator.dblclick.steps = %%-input-move-steps-%%
* since: v1.14

### option: Locator.dblclick.button = %%-input-button-%%
* since: v1.14

Expand Down
6 changes: 6 additions & 0 deletions docs/src/api/class-mouse.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ X coordinate relative to the main frame's viewport in CSS pixels.

Y coordinate relative to the main frame's viewport in CSS pixels.

### option: Mouse.click.steps = %%-input-move-steps-%%
* since: v1.8

### option: Mouse.click.button = %%-input-button-%%
* since: v1.8

Expand Down Expand Up @@ -109,6 +112,9 @@ X coordinate relative to the main frame's viewport in CSS pixels.

Y coordinate relative to the main frame's viewport in CSS pixels.

### option: Mouse.dblclick.steps = %%-input-move-steps-%%
* since: v1.8

### option: Mouse.dblclick.button = %%-input-button-%%
* since: v1.8

Expand Down
5 changes: 5 additions & 0 deletions docs/src/api/params.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ A selector to search for an element to drop onto. If there are multiple elements
A point to use relative to the top-left corner of element padding box. If not specified, uses some visible point of the
element.

## input-move-steps
- `steps` <[int]>

Defaults to 1. Sends intermediate `mousemove` events.

## input-modifiers
- `modifiers` <[Array]<[KeyboardModifier]<"Alt"|"Control"|"ControlOrMeta"|"Meta"|"Shift">>>

Expand Down
30 changes: 30 additions & 0 deletions packages/playwright-client/types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11211,6 +11211,11 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
y: number;
};

/**
* Defaults to 1. Sends intermediate `mousemove` events.
*/
steps?: number;

/**
* Maximum time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via `actionTimeout`
* option in the config, or by using the
Expand Down Expand Up @@ -11294,6 +11299,11 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
y: number;
};

/**
* Defaults to 1. Sends intermediate `mousemove` events.
*/
steps?: number;

/**
* Maximum time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via `actionTimeout`
* option in the config, or by using the
Expand Down Expand Up @@ -12788,6 +12798,11 @@ export interface Locator {
y: number;
};

/**
* Defaults to 1. Sends intermediate `mousemove` events.
*/
steps?: number;

/**
* Maximum time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via `actionTimeout`
* option in the config, or by using the
Expand Down Expand Up @@ -12905,6 +12920,11 @@ export interface Locator {
y: number;
};

/**
* Defaults to 1. Sends intermediate `mousemove` events.
*/
steps?: number;

/**
* Maximum time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via `actionTimeout`
* option in the config, or by using the
Expand Down Expand Up @@ -20245,6 +20265,11 @@ export interface Mouse {
* Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0.
*/
delay?: number;

/**
* Defaults to 1. Sends intermediate `mousemove` events.
*/
steps?: number;
}): Promise<void>;

/**
Expand All @@ -20267,6 +20292,11 @@ export interface Mouse {
* Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0.
*/
delay?: number;

/**
* Defaults to 1. Sends intermediate `mousemove` events.
*/
steps?: number;
}): Promise<void>;

/**
Expand Down
3 changes: 3 additions & 0 deletions packages/playwright-core/src/protocol/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1410,6 +1410,7 @@ scheme.PageMouseUpResult = tOptional(tObject({}));
scheme.PageMouseClickParams = tObject({
x: tFloat,
y: tFloat,
steps: tOptional(tInt),
delay: tOptional(tFloat),
button: tOptional(tEnum(['left', 'right', 'middle'])),
clickCount: tOptional(tInt),
Expand Down Expand Up @@ -1597,6 +1598,7 @@ scheme.FrameClickParams = tObject({
noWaitAfter: tOptional(tBoolean),
modifiers: tOptional(tArray(tEnum(['Alt', 'Control', 'ControlOrMeta', 'Meta', 'Shift']))),
position: tOptional(tType('Point')),
steps: tOptional(tInt),
delay: tOptional(tFloat),
button: tOptional(tEnum(['left', 'right', 'middle'])),
clickCount: tOptional(tInt),
Expand Down Expand Up @@ -2039,6 +2041,7 @@ scheme.ElementHandleClickParams = tObject({
noWaitAfter: tOptional(tBoolean),
modifiers: tOptional(tArray(tEnum(['Alt', 'Control', 'ControlOrMeta', 'Meta', 'Shift']))),
position: tOptional(tType('Point')),
steps: tOptional(tInt),
delay: tOptional(tFloat),
button: tOptional(tEnum(['left', 'right', 'middle'])),
clickCount: tOptional(tInt),
Expand Down
6 changes: 3 additions & 3 deletions packages/playwright-core/src/server/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,10 @@ export class Mouse {
await this._raw.up(progress, this._x, this._y, button, this._buttons, this._keyboard._modifiers(), clickCount);
}

async click(progress: Progress, x: number, y: number, options: { delay?: number, button?: types.MouseButton, clickCount?: number } = {}) {
async click(progress: Progress, x: number, y: number, options: { delay?: number, button?: types.MouseButton, clickCount?: number, steps?: number } = {}) {
const { delay = null, clickCount = 1 } = options;
if (delay) {
this.move(progress, x, y, { forClick: true });
await this.move(progress, x, y, { steps: options.steps, forClick: true });
for (let cc = 1; cc <= clickCount; ++cc) {
await this.down(progress, { ...options, clickCount: cc });
await progress.wait(delay);
Expand All @@ -228,7 +228,7 @@ export class Mouse {
}
} else {
const promises = [];
promises.push(this.move(progress, x, y, { forClick: true }));
promises.push(this.move(progress, x, y, { steps: options.steps, forClick: true }));
for (let cc = 1; cc <= clickCount; ++cc) {
promises.push(this.down(progress, { ...options, clickCount: cc }));
promises.push(this.up(progress, { ...options, clickCount: cc }));
Expand Down
30 changes: 30 additions & 0 deletions packages/playwright-core/types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11211,6 +11211,11 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
y: number;
};

/**
* Defaults to 1. Sends intermediate `mousemove` events.
*/
steps?: number;

/**
* Maximum time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via `actionTimeout`
* option in the config, or by using the
Expand Down Expand Up @@ -11294,6 +11299,11 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
y: number;
};

/**
* Defaults to 1. Sends intermediate `mousemove` events.
*/
steps?: number;

/**
* Maximum time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via `actionTimeout`
* option in the config, or by using the
Expand Down Expand Up @@ -12788,6 +12798,11 @@ export interface Locator {
y: number;
};

/**
* Defaults to 1. Sends intermediate `mousemove` events.
*/
steps?: number;

/**
* Maximum time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via `actionTimeout`
* option in the config, or by using the
Expand Down Expand Up @@ -12905,6 +12920,11 @@ export interface Locator {
y: number;
};

/**
* Defaults to 1. Sends intermediate `mousemove` events.
*/
steps?: number;

/**
* Maximum time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via `actionTimeout`
* option in the config, or by using the
Expand Down Expand Up @@ -20245,6 +20265,11 @@ export interface Mouse {
* Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0.
*/
delay?: number;

/**
* Defaults to 1. Sends intermediate `mousemove` events.
*/
steps?: number;
}): Promise<void>;

/**
Expand All @@ -20267,6 +20292,11 @@ export interface Mouse {
* Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0.
*/
delay?: number;

/**
* Defaults to 1. Sends intermediate `mousemove` events.
*/
steps?: number;
}): Promise<void>;

/**
Expand Down
6 changes: 6 additions & 0 deletions packages/protocol/src/channels.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2455,11 +2455,13 @@ export type PageMouseUpResult = void;
export type PageMouseClickParams = {
x: number,
y: number,
steps?: number,
delay?: number,
button?: 'left' | 'right' | 'middle',
clickCount?: number,
};
export type PageMouseClickOptions = {
steps?: number,
delay?: number,
button?: 'left' | 'right' | 'middle',
clickCount?: number,
Expand Down Expand Up @@ -2798,6 +2800,7 @@ export type FrameClickParams = {
noWaitAfter?: boolean,
modifiers?: ('Alt' | 'Control' | 'ControlOrMeta' | 'Meta' | 'Shift')[],
position?: Point,
steps?: number,
delay?: number,
button?: 'left' | 'right' | 'middle',
clickCount?: number,
Expand All @@ -2810,6 +2813,7 @@ export type FrameClickOptions = {
noWaitAfter?: boolean,
modifiers?: ('Alt' | 'Control' | 'ControlOrMeta' | 'Meta' | 'Shift')[],
position?: Point,
steps?: number,
delay?: number,
button?: 'left' | 'right' | 'middle',
clickCount?: number,
Expand Down Expand Up @@ -3509,6 +3513,7 @@ export type ElementHandleClickParams = {
noWaitAfter?: boolean,
modifiers?: ('Alt' | 'Control' | 'ControlOrMeta' | 'Meta' | 'Shift')[],
position?: Point,
steps?: number,
delay?: number,
button?: 'left' | 'right' | 'middle',
clickCount?: number,
Expand All @@ -3520,6 +3525,7 @@ export type ElementHandleClickOptions = {
noWaitAfter?: boolean,
modifiers?: ('Alt' | 'Control' | 'ControlOrMeta' | 'Meta' | 'Shift')[],
position?: Point,
steps?: number,
delay?: number,
button?: 'left' | 'right' | 'middle',
clickCount?: number,
Expand Down
3 changes: 3 additions & 0 deletions packages/protocol/src/protocol.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1890,6 +1890,7 @@ Page:
parameters:
x: float
y: float
steps: int?
delay: float?
button:
type: enum?
Expand Down Expand Up @@ -2246,6 +2247,7 @@ Frame:
- Meta
- Shift
position: Point?
steps: int?
delay: float?
button:
type: enum?
Expand Down Expand Up @@ -3002,6 +3004,7 @@ ElementHandle:
- Meta
- Shift
position: Point?
steps: int?
delay: float?
button:
type: enum?
Expand Down