parent
2c27bd3b07
commit
532ca3f7b3
|
|
@ -3498,7 +3498,7 @@ When all steps combined have not finished during the specified [`option: timeout
|
||||||
[TimeoutError]. Passing zero timeout disables this.
|
[TimeoutError]. Passing zero timeout disables this.
|
||||||
|
|
||||||
:::note
|
:::note
|
||||||
[`method: Page.tap`] requires that the [`option: hasTouch`] option of the browser context be set to true.
|
[`method: Page.tap`] the method will throw if [`option: hasTouch`] option of the browser context is false.
|
||||||
:::
|
:::
|
||||||
|
|
||||||
### param: Page.tap.selector = %%-input-selector-%%
|
### param: Page.tap.selector = %%-input-selector-%%
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,10 @@ touchscreen can only be used in browser contexts that have been initialized with
|
||||||
|
|
||||||
Dispatches a `touchstart` and `touchend` event with a single touch at the position ([`param: x`],[`param: y`]).
|
Dispatches a `touchstart` and `touchend` event with a single touch at the position ([`param: x`],[`param: y`]).
|
||||||
|
|
||||||
|
:::note
|
||||||
|
[`method: Page.tap`] the method will throw if [`option: hasTouch`] option of the browser context is false.
|
||||||
|
:::
|
||||||
|
|
||||||
### param: Touchscreen.tap.x
|
### param: Touchscreen.tap.x
|
||||||
* since: v1.8
|
* since: v1.8
|
||||||
- `x` <[float]>
|
- `x` <[float]>
|
||||||
|
|
|
||||||
|
|
@ -1211,6 +1211,8 @@ export class Frame extends SdkObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
async tap(metadata: CallMetadata, selector: string, options: types.PointerActionWaitOptions & types.NavigatingActionWaitOptions) {
|
async tap(metadata: CallMetadata, selector: string, options: types.PointerActionWaitOptions & types.NavigatingActionWaitOptions) {
|
||||||
|
if (!this._page._browserContext._options.hasTouch)
|
||||||
|
throw new Error('The page does not support tap. Use hasTouch context option to enable touch support.');
|
||||||
const controller = new ProgressController(metadata, this);
|
const controller = new ProgressController(metadata, this);
|
||||||
return controller.run(async progress => {
|
return controller.run(async progress => {
|
||||||
return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, handle => handle._tap(progress, options)));
|
return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, handle => handle._tap(progress, options)));
|
||||||
|
|
|
||||||
7
packages/playwright-core/types/types.d.ts
vendored
7
packages/playwright-core/types/types.d.ts
vendored
|
|
@ -3968,8 +3968,8 @@ export interface Page {
|
||||||
* When all steps combined have not finished during the specified `timeout`, this method throws a [TimeoutError].
|
* When all steps combined have not finished during the specified `timeout`, this method throws a [TimeoutError].
|
||||||
* Passing zero timeout disables this.
|
* Passing zero timeout disables this.
|
||||||
*
|
*
|
||||||
* **NOTE** [page.tap(selector[, options])](https://playwright.dev/docs/api/class-page#page-tap) requires that the
|
* **NOTE** [page.tap(selector[, options])](https://playwright.dev/docs/api/class-page#page-tap) the method will throw
|
||||||
* `hasTouch` option of the browser context be set to true.
|
* if `hasTouch` option of the browser context is false.
|
||||||
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
|
* @param selector A selector to search for an element. If there are multiple elements satisfying the selector, the first will be
|
||||||
* used.
|
* used.
|
||||||
* @param options
|
* @param options
|
||||||
|
|
@ -18098,6 +18098,9 @@ export interface Selectors {
|
||||||
export interface Touchscreen {
|
export interface Touchscreen {
|
||||||
/**
|
/**
|
||||||
* Dispatches a `touchstart` and `touchend` event with a single touch at the position (`x`,`y`).
|
* Dispatches a `touchstart` and `touchend` event with a single touch at the position (`x`,`y`).
|
||||||
|
*
|
||||||
|
* **NOTE** [page.tap(selector[, options])](https://playwright.dev/docs/api/class-page#page-tap) the method will throw
|
||||||
|
* if `hasTouch` option of the browser context is false.
|
||||||
* @param x
|
* @param x
|
||||||
* @param y
|
* @param y
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,20 @@ it('should not have touch by default', async ({ page, server }) => {
|
||||||
expect(await page.evaluate(() => document.body.textContent.trim())).toBe('NO');
|
expect(await page.evaluate(() => document.body.textContent.trim())).toBe('NO');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should throw on tap if hasTouch is not enabled', async ({ page }) => {
|
||||||
|
await page.setContent(`<div>a</div>`);
|
||||||
|
{
|
||||||
|
const error = await page.tap('div').catch(e => e);
|
||||||
|
expect(error).toBeTruthy();
|
||||||
|
expect(error.message).toContain('The page does not support tap');
|
||||||
|
}
|
||||||
|
{
|
||||||
|
const error = await page.locator('div').tap().catch(e => e);
|
||||||
|
expect(error).toBeTruthy();
|
||||||
|
expect(error.message).toContain('The page does not support tap');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
browserTest('should support touch with null viewport', async ({ browser, server }) => {
|
browserTest('should support touch with null viewport', async ({ browser, server }) => {
|
||||||
const context = await browser.newContext({ viewport: null, hasTouch: true });
|
const context = await browser.newContext({ viewport: null, hasTouch: true });
|
||||||
const page = await context.newPage();
|
const page = await context.newPage();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue