From ba29470cc125eafa88e64d9b846153cd4b4fce3b Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Mon, 24 Feb 2020 21:12:02 -0800 Subject: [PATCH] fix(api): rename relativePoint to offset, remove unused parameters from input (#1092) --- docs/api.md | 36 ++++++++++++----------------------- src/dom.ts | 29 ++++++++++++++++++---------- src/frames.ts | 9 ++++----- src/input.ts | 16 +++++----------- src/page.ts | 8 ++++---- test/chromium/tracing.spec.js | 2 +- test/click.spec.js | 22 ++++++++++----------- 7 files changed, 56 insertions(+), 66 deletions(-) diff --git a/docs/api.md b/docs/api.md index cba744f15a..85cf77b52b 100644 --- a/docs/api.md +++ b/docs/api.md @@ -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). diff --git a/src/dom.ts b/src/dom.ts index 11ec858a4a..83673a8313 100644 --- a/src/dom.ts +++ b/src/dom.ts @@ -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 extends js.JSHandle { return result; } - private async _relativePoint(relativePoint: types.Point): Promise { + private async _offsetPoint(offset: types.Point): Promise { const [box, border] = await Promise.all([ this.boundingBox(), this._evaluateInUtility((node: Node) => { @@ -217,7 +226,7 @@ export class ElementHandle extends js.JSHandle { 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 extends js.JSHandle { return point; } - async _performPointerAction(action: (point: types.Point) => Promise, options?: input.PointerActionOptions & types.WaitForOptions): Promise { + async _performPointerAction(action: (point: types.Point) => Promise, options?: PointerActionOptions & types.WaitForOptions): Promise { 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 extends js.JSHandle { await this._page.keyboard._ensureModifiers(restoreModifiers); } - hover(options?: input.PointerActionOptions & types.WaitForOptions): Promise { + hover(options?: PointerActionOptions & types.WaitForOptions): Promise { return this._performPointerAction(point => this._page.mouse.move(point.x, point.y), options); } - click(options?: input.ClickOptions & types.WaitForOptions): Promise { + click(options?: ClickOptions & types.WaitForOptions): Promise { return this._performPointerAction(point => this._page.mouse.click(point.x, point.y, options), options); } - dblclick(options?: input.MultiClickOptions & types.WaitForOptions): Promise { + dblclick(options?: MultiClickOptions & types.WaitForOptions): Promise { return this._performPointerAction(point => this._page.mouse.dblclick(point.x, point.y, options), options); } - tripleclick(options?: input.MultiClickOptions & types.WaitForOptions): Promise { + tripleclick(options?: MultiClickOptions & types.WaitForOptions): Promise { return this._performPointerAction(point => this._page.mouse.tripleclick(point.x, point.y, options), options); } diff --git a/src/frames.ts b/src/frames.ts index c784a1c49a..6306458f5a 100644 --- a/src/frames.ts +++ b/src/frames.ts @@ -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(); diff --git a/src/input.ts b/src/input.ts index dd5864262c..5a351cc719 100644 --- a/src/input.ts +++ b/src/input.ts @@ -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); diff --git a/src/page.ts b/src/page.ts index 572b2a9ece..033ad57487 100644 --- a/src/page.ts +++ b/src/page.ts @@ -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); } diff --git a/test/chromium/tracing.spec.js b/test/chromium/tracing.spec.js index d242af429b..d5beebba2b 100644 --- a/test/chromium/tracing.spec.js +++ b/test/chromium/tracing.spec.js @@ -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); diff --git a/test/click.spec.js b/test/click.spec.js index 515b328505..fbdaf3de18 100644 --- a/test/click.spec.js +++ b/test/click.spec.js @@ -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) {