fix(api): rename relativePoint to offset, remove unused parameters from input (#1092)

This commit is contained in:
Dmitry Gozman 2020-02-24 21:12:02 -08:00 committed by GitHub
parent fdfec8eb2a
commit ba29470cc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 56 additions and 66 deletions

View File

@ -775,7 +775,7 @@ Shortcut for [page.mainFrame().check(selector[, options])](#framecheckselector-o
- `button` <"left"|"right"|"middle"> Defaults to `left`.
- `clickCount` <[number]> defaults to 1. See [UIEvent.detail].
- `delay` <[number]> Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0.
- `relativePoint` <[Object]> A point to click relative to the top-left corner of element padding box. If not specified, clicks to some visible point of the element.
- `offset` <[Object]> A point to click relative to the top-left corner of element padding box. If not specified, clicks to some visible point of the element.
- x <[number]>
- y <[number]>
- `modifiers` <[Array]<"Alt"|"Control"|"Meta"|"Shift">> Modifier keys to press. Ensures that only these modifiers are pressed during the click, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
@ -831,7 +831,7 @@ Browser-specific Coverage implementation, only available for Chromium atm. See [
- `options` <[Object]>
- `button` <"left"|"right"|"middle"> Defaults to `left`.
- `delay` <[number]> Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0.
- `relativePoint` <[Object]> A point to double click relative to the top-left corner of element padding box. If not specified, double clicks to some visible point of the element.
- `offset` <[Object]> A point to double click relative to the top-left corner of element padding box. If not specified, double clicks to some visible point of the element.
- x <[number]>
- y <[number]>
- `modifiers` <[Array]<"Alt"|"Control"|"Meta"|"Shift">> Modifier keys to press. Ensures that only these modifiers are pressed during the double click, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
@ -1115,7 +1115,7 @@ Shortcut for [page.mainFrame().goto(url, options)](#framegotourl-options)
#### page.hover(selector[, options])
- `selector` <[string]> A selector to search for element to hover. If there are multiple elements satisfying the selector, the first will be hovered.
- `options` <[Object]>
- `relativePoint` <[Object]> A point to hover relative to the top-left corner of element padding box. If not specified, hovers over some visible point of the element.
- `offset` <[Object]> A point to hover relative to the top-left corner of element padding box. If not specified, hovers over some visible point of the element.
- x <[number]>
- y <[number]>
- `modifiers` <[Array]<"Alt"|"Control"|"Meta"|"Shift">> Modifier keys to press. Ensures that only these modifiers are pressed during the hover, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
@ -1385,7 +1385,7 @@ Shortcut for [page.mainFrame().title()](#frametitle).
- `options` <[Object]>
- `button` <"left"|"right"|"middle"> Defaults to `left`.
- `delay` <[number]> Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0.
- `relativePoint` <[Object]> A point to triple click relative to the top-left corner of element padding box. If not specified, triple clicks to some visible point of the element.
- `offset` <[Object]> A point to triple click relative to the top-left corner of element padding box. If not specified, triple clicks to some visible point of the element.
- x <[number]>
- y <[number]>
- `modifiers` <[Array]<"Alt"|"Control"|"Meta"|"Shift">> Modifier keys to press. Ensures that only these modifiers are pressed during the triple click, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
@ -1811,7 +1811,7 @@ If there's no element matching `selector`, the method throws an error.
- `button` <"left"|"right"|"middle"> Defaults to `left`.
- `clickCount` <[number]> defaults to 1. See [UIEvent.detail].
- `delay` <[number]> Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0.
- `relativePoint` <[Object]> A point to click relative to the top-left corner of element padding box. If not specified, clicks to some visible point of the element.
- `offset` <[Object]> A point to click relative to the top-left corner of element padding box. If not specified, clicks to some visible point of the element.
- x <[number]>
- y <[number]>
- `modifiers` <[Array]<"Alt"|"Control"|"Meta"|"Shift">> Modifier keys to press. Ensures that only these modifiers are pressed during the click, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
@ -1841,7 +1841,7 @@ Gets the full HTML contents of the frame, including the doctype.
- `options` <[Object]>
- `button` <"left"|"right"|"middle"> Defaults to `left`.
- `delay` <[number]> Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0.
- `relativePoint` <[Object]> A point to double click relative to the top-left corner of element padding box. If not specified, double clicks to some visible point of the element.
- `offset` <[Object]> A point to double click relative to the top-left corner of element padding box. If not specified, double clicks to some visible point of the element.
- x <[number]>
- y <[number]>
- `modifiers` <[Array]<"Alt"|"Control"|"Meta"|"Shift">> Modifier keys to press. Ensures that only these modifiers are pressed during the double click, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
@ -1976,7 +1976,7 @@ console.log(frame === contentFrame); // -> true
#### frame.hover(selector[, options])
- `selector` <[string]> A selector to search for element to hover. If there are multiple elements satisfying the selector, the first will be hovered.
- `options` <[Object]>
- `relativePoint` <[Object]> A point to hover relative to the top-left corner of element padding box. If not specified, hovers over some visible point of the element.
- `offset` <[Object]> A point to hover relative to the top-left corner of element padding box. If not specified, hovers over some visible point of the element.
- x <[number]>
- y <[number]>
- `modifiers` <[Array]<"Alt"|"Control"|"Meta"|"Shift">> Modifier keys to press. Ensures that only these modifiers are pressed during the hover, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
@ -2051,7 +2051,7 @@ frame.select('select#colors', { value: 'blue' }, { index: 2 }, 'red');
- `options` <[Object]>
- `button` <"left"|"right"|"middle"> Defaults to `left`.
- `delay` <[number]> Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0.
- `relativePoint` <[Object]> A point to triple click relative to the top-left corner of element padding box. If not specified, triple clicks to some visible point of the element.
- `offset` <[Object]> A point to triple click relative to the top-left corner of element padding box. If not specified, triple clicks to some visible point of the element.
- x <[number]>
- y <[number]>
- `modifiers` <[Array]<"Alt"|"Control"|"Meta"|"Shift">> Modifier keys to press. Ensures that only these modifiers are pressed during the triple click, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
@ -2365,7 +2365,7 @@ If element is not already checked, it scrolls it into view if needed, and then u
- `button` <"left"|"right"|"middle"> Defaults to `left`.
- `clickCount` <[number]> defaults to 1. See [UIEvent.detail].
- `delay` <[number]> Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0.
- `relativePoint` <[Object]> A point to click relative to the top-left corner of element padding box. If not specified, clicks to some visible point of the element.
- `offset` <[Object]> A point to click relative to the top-left corner of element padding box. If not specified, clicks to some visible point of the element.
- x <[number]>
- y <[number]>
- `modifiers` <[Array]<"Alt"|"Control"|"Meta"|"Shift">> Modifier keys to press. Ensures that only these modifiers are pressed during the click, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
@ -2383,7 +2383,7 @@ If the element is detached from DOM, the method throws an error.
- `options` <[Object]>
- `button` <"left"|"right"|"middle"> Defaults to `left`.
- `delay` <[number]> Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0.
- `relativePoint` <[Object]> A point to double click relative to the top-left corner of element padding box. If not specified, double clicks to some visible point of the element.
- `offset` <[Object]> A point to double click relative to the top-left corner of element padding box. If not specified, double clicks to some visible point of the element.
- x <[number]>
- y <[number]>
- `modifiers` <[Array]<"Alt"|"Control"|"Meta"|"Shift">> Modifier keys to press. Ensures that only these modifiers are pressed during the double click, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
@ -2412,7 +2412,7 @@ Calls [focus](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus
#### elementHandle.hover([options])
- `options` <[Object]>
- `relativePoint` <[Object]> A point to hover relative to the top-left corner of element padding box. If not specified, hovers over some visible point of the element.
- `offset` <[Object]> A point to hover relative to the top-left corner of element padding box. If not specified, hovers over some visible point of the element.
- x <[number]>
- y <[number]>
- `modifiers` <[Array]<"Alt"|"Control"|"Meta"|"Shift">> Modifier keys to press. Ensures that only these modifiers are pressed during the hover, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
@ -2499,7 +2499,7 @@ This method expects `elementHandle` to point to an [input element](https://devel
- `options` <[Object]>
- `button` <"left"|"right"|"middle"> Defaults to `left`.
- `delay` <[number]> Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0.
- `relativePoint` <[Object]> A point to triple click relative to the top-left corner of element padding box. If not specified, triple clicks to some visible point of the element.
- `offset` <[Object]> A point to triple click relative to the top-left corner of element padding box. If not specified, triple clicks to some visible point of the element.
- x <[number]>
- y <[number]>
- `modifiers` <[Array]<"Alt"|"Control"|"Meta"|"Shift">> Modifier keys to press. Ensures that only these modifiers are pressed during the triple click, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
@ -2840,10 +2840,6 @@ await page.mouse.up();
- `button` <"left"|"right"|"middle"> Defaults to `left`.
- `clickCount` <[number]> defaults to 1. See [UIEvent.detail].
- `delay` <[number]> Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0.
- `modifiers` <[Array]<"Alt"|"Control"|"Meta"|"Shift">>
- `relativePoint` <[Object]> Optional relative point
- `x` <[number]> x coordinate
- `y` <[number]> y coordinate
- returns: <[Promise]>
Shortcut for [`mouse.move`](#mousemovex-y-options), [`mouse.down`](#mousedownoptions) and [`mouse.up`](#mouseupoptions).
@ -2854,10 +2850,6 @@ Shortcut for [`mouse.move`](#mousemovex-y-options), [`mouse.down`](#mousedownopt
- `options` <[Object]>
- `button` <"left"|"right"|"middle"> Defaults to `left`.
- `delay` <[number]> Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0.
- `modifiers` <[Array]<"Alt"|"Control"|"Meta"|"Shift">>
- `relativePoint` <[Object]> Optional relative point
- `x` <[number]> x coordinate
- `y` <[number]> y coordinate
- returns: <[Promise]>
Shortcut for [`mouse.move`](#mousemovex-y-options), [`mouse.down`](#mousedownoptions), [`mouse.up`](#mouseupoptions), [`mouse.down`](#mousedownoptions) and [`mouse.up`](#mouseupoptions).
@ -2885,10 +2877,6 @@ Dispatches a `mousemove` event.
- `options` <[Object]>
- `button` <"left"|"right"|"middle"> Defaults to `left`.
- `delay` <[number]> Time to wait between `mousedown` and `mouseup` in milliseconds. Defaults to 0.
- `modifiers` <[Array]<"Alt"|"Control"|"Meta"|"Shift">>
- `relativePoint` <[Object]> Optional relative point
- `x` <[number]> x coordinate
- `y` <[number]> y coordinate
- returns: <[Promise]>
Shortcut for [`mouse.move`](#mousemovex-y-options), [`mouse.down`](#mousedownoptions), [`mouse.up`](#mouseupoptions), [`mouse.down`](#mousedownoptions), [`mouse.up`](#mouseupoptions), [`mouse.down`](#mousedownoptions) and [`mouse.up`](#mouseupoptions).

View File

@ -25,6 +25,15 @@ import { Page } from './page';
import * as platform from './platform';
import { Selectors } from './selectors';
export type PointerActionOptions = {
modifiers?: input.Modifier[];
offset?: types.Point;
};
export type ClickOptions = PointerActionOptions & input.MouseClickOptions;
export type MultiClickOptions = PointerActionOptions & input.MouseMultiClickOptions;
export class FrameExecutionContext extends js.ExecutionContext {
readonly frame: frames.Frame;
@ -207,7 +216,7 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {
return result;
}
private async _relativePoint(relativePoint: types.Point): Promise<types.Point> {
private async _offsetPoint(offset: types.Point): Promise<types.Point> {
const [box, border] = await Promise.all([
this.boundingBox(),
this._evaluateInUtility((node: Node) => {
@ -217,7 +226,7 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {
return { x: parseInt(style.borderLeftWidth || '', 10), y: parseInt(style.borderTopWidth || '', 10) };
}).catch(debugError),
]);
const point = { x: relativePoint.x, y: relativePoint.y };
const point = { x: offset.x, y: offset.y };
if (box) {
point.x += box.x;
point.y += box.y;
@ -230,15 +239,15 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {
return point;
}
async _performPointerAction(action: (point: types.Point) => Promise<void>, options?: input.PointerActionOptions & types.WaitForOptions): Promise<void> {
async _performPointerAction(action: (point: types.Point) => Promise<void>, options?: PointerActionOptions & types.WaitForOptions): Promise<void> {
const { waitFor = true } = (options || {});
if (!helper.isBoolean(waitFor))
throw new Error('waitFor option should be a boolean, got "' + (typeof waitFor) + '"');
if (waitFor)
await this._waitForStablePosition(options);
const relativePoint = options ? options.relativePoint : undefined;
await this._scrollRectIntoViewIfNeeded(relativePoint ? { x: relativePoint.x, y: relativePoint.y, width: 0, height: 0 } : undefined);
const point = relativePoint ? await this._relativePoint(relativePoint) : await this._clickablePoint();
const offset = options ? options.offset : undefined;
await this._scrollRectIntoViewIfNeeded(offset ? { x: offset.x, y: offset.y, width: 0, height: 0 } : undefined);
const point = offset ? await this._offsetPoint(offset) : await this._clickablePoint();
if (waitFor)
await this._waitForHitTargetAt(point, options);
let restoreModifiers: input.Modifier[] | undefined;
@ -249,19 +258,19 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {
await this._page.keyboard._ensureModifiers(restoreModifiers);
}
hover(options?: input.PointerActionOptions & types.WaitForOptions): Promise<void> {
hover(options?: PointerActionOptions & types.WaitForOptions): Promise<void> {
return this._performPointerAction(point => this._page.mouse.move(point.x, point.y), options);
}
click(options?: input.ClickOptions & types.WaitForOptions): Promise<void> {
click(options?: ClickOptions & types.WaitForOptions): Promise<void> {
return this._performPointerAction(point => this._page.mouse.click(point.x, point.y, options), options);
}
dblclick(options?: input.MultiClickOptions & types.WaitForOptions): Promise<void> {
dblclick(options?: MultiClickOptions & types.WaitForOptions): Promise<void> {
return this._performPointerAction(point => this._page.mouse.dblclick(point.x, point.y, options), options);
}
tripleclick(options?: input.MultiClickOptions & types.WaitForOptions): Promise<void> {
tripleclick(options?: MultiClickOptions & types.WaitForOptions): Promise<void> {
return this._performPointerAction(point => this._page.mouse.tripleclick(point.x, point.y, options), options);
}

View File

@ -19,7 +19,6 @@ import * as types from './types';
import * as js from './javascript';
import * as dom from './dom';
import * as network from './network';
import * as input from './input';
import { helper, assert, RegisteredListener } from './helper';
import { TimeoutError } from './errors';
import { Events } from './events';
@ -780,19 +779,19 @@ export class Frame {
return result!;
}
async click(selector: string, options?: input.ClickOptions & types.WaitForOptions) {
async click(selector: string, options?: dom.ClickOptions & types.WaitForOptions) {
const handle = await this._optionallyWaitForSelectorInUtilityContext(selector, options);
await handle.click(options);
await handle.dispose();
}
async dblclick(selector: string, options?: input.MultiClickOptions & types.WaitForOptions) {
async dblclick(selector: string, options?: dom.MultiClickOptions & types.WaitForOptions) {
const handle = await this._optionallyWaitForSelectorInUtilityContext(selector, options);
await handle.dblclick(options);
await handle.dispose();
}
async tripleclick(selector: string, options?: input.MultiClickOptions & types.WaitForOptions) {
async tripleclick(selector: string, options?: dom.MultiClickOptions & types.WaitForOptions) {
const handle = await this._optionallyWaitForSelectorInUtilityContext(selector, options);
await handle.tripleclick(options);
await handle.dispose();
@ -810,7 +809,7 @@ export class Frame {
await handle.dispose();
}
async hover(selector: string, options?: input.PointerActionOptions & types.WaitForOptions) {
async hover(selector: string, options?: dom.PointerActionOptions & types.WaitForOptions) {
const handle = await this._optionallyWaitForSelectorInUtilityContext(selector, options);
await handle.hover(options);
await handle.dispose();

View File

@ -15,24 +15,18 @@
*/
import { assert } from './helper';
import * as types from './types';
import * as keyboardLayout from './usKeyboardLayout';
export type Modifier = 'Alt' | 'Control' | 'Meta' | 'Shift';
export type Button = 'left' | 'right' | 'middle';
export type PointerActionOptions = {
modifiers?: Modifier[];
relativePoint?: types.Point;
};
export type ClickOptions = PointerActionOptions & {
export type MouseClickOptions = {
delay?: number;
button?: Button;
clickCount?: number;
};
export type MultiClickOptions = PointerActionOptions & {
export type MouseMultiClickOptions = {
delay?: number;
button?: Button;
};
@ -227,7 +221,7 @@ export class Mouse {
await this._raw.up(this._x, this._y, button, this._buttons, this._keyboard._modifiers(), clickCount);
}
async click(x: number, y: number, options: ClickOptions = {}) {
async click(x: number, y: number, options: MouseClickOptions = {}) {
const {delay = null} = options;
if (delay !== null) {
await Promise.all([
@ -245,7 +239,7 @@ export class Mouse {
}
}
async dblclick(x: number, y: number, options: MultiClickOptions = {}) {
async dblclick(x: number, y: number, options: MouseMultiClickOptions = {}) {
const { delay = null } = options;
if (delay !== null) {
await this.move(x, y);
@ -267,7 +261,7 @@ export class Mouse {
}
}
async tripleclick(x: number, y: number, options: MultiClickOptions = {}) {
async tripleclick(x: number, y: number, options: MouseMultiClickOptions = {}) {
const { delay = null } = options;
if (delay !== null) {
await this.move(x, y);

View File

@ -485,15 +485,15 @@ export class Page extends platform.EventEmitter {
return this._closed;
}
async click(selector: string, options?: input.ClickOptions & types.WaitForOptions) {
async click(selector: string, options?: dom.ClickOptions & types.WaitForOptions) {
return this.mainFrame().click(selector, options);
}
async dblclick(selector: string, options?: input.MultiClickOptions & types.WaitForOptions) {
async dblclick(selector: string, options?: dom.MultiClickOptions & types.WaitForOptions) {
return this.mainFrame().dblclick(selector, options);
}
async tripleclick(selector: string, options?: input.MultiClickOptions & types.WaitForOptions) {
async tripleclick(selector: string, options?: dom.MultiClickOptions & types.WaitForOptions) {
return this.mainFrame().tripleclick(selector, options);
}
@ -505,7 +505,7 @@ export class Page extends platform.EventEmitter {
return this.mainFrame().focus(selector, options);
}
async hover(selector: string, options?: input.PointerActionOptions & types.WaitForOptions) {
async hover(selector: string, options?: dom.PointerActionOptions & types.WaitForOptions) {
return this.mainFrame().hover(selector, options);
}

View File

@ -80,7 +80,7 @@ module.exports.describe = function({testRunner, expect, defaultBrowserOptions, p
await page.goto(server.PREFIX + '/grid.html');
const oldBufferConcat = Buffer.concat;
Buffer.concat = bufs => {
throw 'error';
throw new Error('Buffer.concat fake error, should be caught by playwright');
};
const trace = await browser.stopTracing();
expect(trace).toEqual(null);

View File

@ -162,7 +162,7 @@ module.exports.describe = function({testRunner, expect, playwright, FFOX, CHROMI
let done = false;
await page.goto(server.PREFIX + '/input/button.html');
await page.$eval('button', b => b.style.display = 'none');
const clicked = page.click('button').then(() => done = true);
const clicked = page.click('button', { timeout: 0 }).then(() => done = true);
for (let i = 0; i < 5; i++)
await page.evaluate('1'); // Do a round trip.
expect(done).toBe(false);
@ -307,36 +307,36 @@ module.exports.describe = function({testRunner, expect, playwright, FFOX, CHROMI
expect(await frame.evaluate(() => window.result)).toBe('Clicked');
await context.close();
});
it('should click the button with px border with relative point', async({page, server}) => {
it('should click the button with px border with offset', async({page, server}) => {
await page.goto(server.PREFIX + '/input/button.html');
await page.$eval('button', button => button.style.borderWidth = '8px');
await page.click('button', { relativePoint: { x: 20, y: 10 } });
await page.click('button', { offset: { x: 20, y: 10 } });
expect(await page.evaluate(() => result)).toBe('Clicked');
// Safari reports border-relative offsetX/offsetY.
expect(await page.evaluate(() => offsetX)).toBe(WEBKIT ? 20 + 8 : 20);
expect(await page.evaluate(() => offsetY)).toBe(WEBKIT ? 10 + 8 : 10);
});
it('should click the button with em border with relative point', async({page, server}) => {
it('should click the button with em border with offset', async({page, server}) => {
await page.goto(server.PREFIX + '/input/button.html');
await page.$eval('button', button => button.style.borderWidth = '2em');
await page.$eval('button', button => button.style.fontSize = '12px');
await page.click('button', { relativePoint: { x: 20, y: 10 } });
await page.click('button', { offset: { x: 20, y: 10 } });
expect(await page.evaluate(() => result)).toBe('Clicked');
// Safari reports border-relative offsetX/offsetY.
expect(await page.evaluate(() => offsetX)).toBe(WEBKIT ? 12 * 2 + 20 : 20);
expect(await page.evaluate(() => offsetY)).toBe(WEBKIT ? 12 * 2 + 10 : 10);
});
it.skip(FFOX)('should click a very large button with relative point', async({page, server}) => {
it.skip(FFOX)('should click a very large button with offset', async({page, server}) => {
await page.goto(server.PREFIX + '/input/button.html');
await page.$eval('button', button => button.style.borderWidth = '8px');
await page.$eval('button', button => button.style.height = button.style.width = '2000px');
await page.click('button', { relativePoint: { x: 1900, y: 1910 } });
await page.click('button', { offset: { x: 1900, y: 1910 } });
expect(await page.evaluate(() => window.result)).toBe('Clicked');
// Safari reports border-relative offsetX/offsetY.
expect(await page.evaluate(() => offsetX)).toBe(WEBKIT ? 1900 + 8 : 1900);
expect(await page.evaluate(() => offsetY)).toBe(WEBKIT ? 1910 + 8 : 1910);
});
it.skip(FFOX)('should click a button in scrolling container with relative point', async({page, server}) => {
it.skip(FFOX)('should click a button in scrolling container with offset', async({page, server}) => {
await page.goto(server.PREFIX + '/input/button.html');
await page.$eval('button', button => {
const container = document.createElement('div');
@ -349,13 +349,13 @@ module.exports.describe = function({testRunner, expect, playwright, FFOX, CHROMI
button.style.width = '2000px';
button.style.borderWidth = '8px';
});
await page.click('button', { relativePoint: { x: 1900, y: 1910 } });
await page.click('button', { offset: { x: 1900, y: 1910 } });
expect(await page.evaluate(() => window.result)).toBe('Clicked');
// Safari reports border-relative offsetX/offsetY.
expect(await page.evaluate(() => offsetX)).toBe(WEBKIT ? 1900 + 8 : 1900);
expect(await page.evaluate(() => offsetY)).toBe(WEBKIT ? 1910 + 8 : 1910);
});
it('should click the button with relative point with page scale', async({browser, server}) => {
it('should click the button with offset with page scale', async({browser, server}) => {
const context = await browser.newContext({ viewport: { width: 400, height: 400, isMobile: true} });
const page = await context.newPage();
await page.goto(server.PREFIX + '/input/button.html');
@ -363,7 +363,7 @@ module.exports.describe = function({testRunner, expect, playwright, FFOX, CHROMI
button.style.borderWidth = '8px';
document.body.style.margin = '0';
});
await page.click('button', { relativePoint: { x: 20, y: 10 } });
await page.click('button', { offset: { x: 20, y: 10 } });
expect(await page.evaluate(() => result)).toBe('Clicked');
let expected = { x: 28, y: 18 }; // 20;10 + 8px of border in each direction
if (WEBKIT) {