chore: remove touchscreen API (#41)
This commit is contained in:
Родитель
206cf7b83f
Коммит
e869b12f46
56
docs/api.md
56
docs/api.md
|
@ -136,10 +136,8 @@
|
|||
* [page.setRequestInterception(value)](#pagesetrequestinterceptionvalue)
|
||||
* [page.setUserAgent(userAgent)](#pagesetuseragentuseragent)
|
||||
* [page.setViewport(viewport)](#pagesetviewportviewport)
|
||||
* [page.tap(selector[, options])](#pagetapselector-options)
|
||||
* [page.target()](#pagetarget)
|
||||
* [page.title()](#pagetitle)
|
||||
* [page.touchscreen](#pagetouchscreen)
|
||||
* [page.tracing](#pagetracing)
|
||||
* [page.tripleclick(selector[, options])](#pagetripleclickselector-options)
|
||||
* [page.type(selector, text[, options])](#pagetypeselector-text-options)
|
||||
|
@ -180,8 +178,6 @@
|
|||
* [mouse.up([options])](#mouseupoptions)
|
||||
- [class: PDF](#class-pdf)
|
||||
* [pdf.generate([options])](#pdfgenerateoptions)
|
||||
- [class: Touchscreen](#class-touchscreen)
|
||||
* [touchscreen.tap(x, y)](#touchscreentapx-y)
|
||||
- [class: Tracing](#class-tracing)
|
||||
* [tracing.start([options])](#tracingstartoptions)
|
||||
* [tracing.stop()](#tracingstop)
|
||||
|
@ -224,7 +220,6 @@
|
|||
* [frame.parentFrame()](#frameparentframe)
|
||||
* [frame.select(selector, ...values)](#frameselectselector-values)
|
||||
* [frame.setContent(html[, options])](#framesetcontenthtml-options)
|
||||
* [frame.tap(selector[, options])](#frametapselector-options)
|
||||
* [frame.title()](#frametitle)
|
||||
* [frame.tripleclick(selector[, options])](#frametripleclickselector-options)
|
||||
* [frame.type(selector, text[, options])](#frametypeselector-text-options)
|
||||
|
@ -272,7 +267,6 @@
|
|||
* [elementHandle.press(key[, options])](#elementhandlepresskey-options)
|
||||
* [elementHandle.screenshot([options])](#elementhandlescreenshotoptions)
|
||||
* [elementHandle.select(...values)](#elementhandleselectvalues)
|
||||
* [elementHandle.tap([options])](#elementhandletapoptions)
|
||||
* [elementHandle.toString()](#elementhandletostring)
|
||||
* [elementHandle.tripleclick([options])](#elementhandletripleclickoptions)
|
||||
* [elementHandle.type(text[, options])](#elementhandletypetext-options)
|
||||
|
@ -1829,20 +1823,6 @@ await page.setViewport({
|
|||
await page.goto('https://example.com');
|
||||
```
|
||||
|
||||
#### page.tap(selector[, options])
|
||||
- `selector` <[string]> A [selector] to search for element to tap. If there are multiple elements satisfying the selector, the first will be tapped.
|
||||
- `options` <[Object]>
|
||||
- `relativePoint` <[Object]> A point to tap relative to the top-left corner of element padding box. If not specified, taps 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 tap, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
|
||||
- returns: <[Promise]>
|
||||
|
||||
This method fetches an element with `selector`, scrolls it into view if needed, and then uses [page.touchscreen](#pagetouchscreen) to tap in the center of the element.
|
||||
If there's no element matching `selector`, the method throws an error.
|
||||
|
||||
Shortcut for [page.mainFrame().tap(selector)](#frametapselector).
|
||||
|
||||
#### page.target()
|
||||
- returns: <[Target]> a target this page was created from.
|
||||
|
||||
|
@ -1851,9 +1831,6 @@ Shortcut for [page.mainFrame().tap(selector)](#frametapselector).
|
|||
|
||||
Shortcut for [page.mainFrame().title()](#frametitle).
|
||||
|
||||
#### page.touchscreen
|
||||
- returns: <[Touchscreen]>
|
||||
|
||||
#### page.tracing
|
||||
- returns: <[Tracing]>
|
||||
|
||||
|
@ -2489,15 +2466,6 @@ The `format` options are:
|
|||
> 2. Page styles are not visible inside templates.
|
||||
|
||||
|
||||
### class: Touchscreen
|
||||
|
||||
#### touchscreen.tap(x, y)
|
||||
- `x` <[number]>
|
||||
- `y` <[number]>
|
||||
- returns: <[Promise]>
|
||||
|
||||
Dispatches a `touchstart` and `touchend` event.
|
||||
|
||||
### class: Tracing
|
||||
|
||||
You can use [`tracing.start`](#tracingstartoptions) and [`tracing.stop`](#tracingstop) to create a trace file which can be opened in Chrome DevTools or [timeline viewer](https://chromedevtools.github.io/timeline-viewer/).
|
||||
|
@ -2922,18 +2890,6 @@ frame.select('select#colors', 'red', 'green', 'blue'); // multiple selections
|
|||
- `networkidle2` - consider setting content to be finished when there are no more than 2 network connections for at least `500` ms.
|
||||
- returns: <[Promise]>
|
||||
|
||||
#### frame.tap(selector[, options])
|
||||
- `selector` <[string]> A [selector] to search for element to tap. If there are multiple elements satisfying the selector, the first will be tapped.
|
||||
- `options` <[Object]>
|
||||
- `relativePoint` <[Object]> A point to tap relative to the top-left corner of element padding box. If not specified, taps 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 tap, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
|
||||
- returns: <[Promise]>
|
||||
|
||||
This method fetches an element with `selector`, scrolls it into view if needed, and then uses [page.touchscreen](#pagetouchscreen) to tap in the center of the element.
|
||||
If there's no element matching `selector`, the method throws an error.
|
||||
|
||||
#### frame.title()
|
||||
- returns: <[Promise]<[string]>> The page's title.
|
||||
|
||||
|
@ -3527,17 +3483,6 @@ handle.select('blue'); // single selection
|
|||
handle.select('red', 'green', 'blue'); // multiple selections
|
||||
```
|
||||
|
||||
#### elementHandle.tap([options])
|
||||
- `options` <[Object]>
|
||||
- `relativePoint` <[Object]> A point to tap relative to the top-left corner of element padding box. If not specified, taps 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 tap, and then restores current modifiers back. If not specified, currently pressed modifiers are used.
|
||||
- returns: <[Promise]> Promise which resolves when the element is successfully tapped. Promise gets rejected if the element is detached from DOM.
|
||||
|
||||
This method scrolls element into view if needed, and then uses [touchscreen.tap](#touchscreentapx-y) to tap in the center of the element.
|
||||
If the element is detached from DOM, the method throws an error.
|
||||
|
||||
#### elementHandle.toString()
|
||||
- returns: <[string]>
|
||||
|
||||
|
@ -3972,7 +3917,6 @@ TimeoutError is emitted whenever certain operations are terminated due to timeou
|
|||
[Serializable]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#Description "Serializable"
|
||||
[Target]: #class-target "Target"
|
||||
[TimeoutError]: #class-timeouterror "TimeoutError"
|
||||
[Touchscreen]: #class-touchscreen "Touchscreen"
|
||||
[Tracing]: #class-tracing "Tracing"
|
||||
[UIEvent.detail]: https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/detail "UIEvent.detail"
|
||||
[USKeyboardLayout]: ../lib/USKeyboardLayout.js "USKeyboardLayout"
|
||||
|
|
|
@ -330,13 +330,6 @@ export class DOMWorld {
|
|||
return result;
|
||||
}
|
||||
|
||||
async tap(selector: string, options?: PointerActionOptions) {
|
||||
const handle = await this.$(selector);
|
||||
assert(handle, 'No node found for selector: ' + selector);
|
||||
await handle.tap(options);
|
||||
await handle.dispose();
|
||||
}
|
||||
|
||||
async type(selector: string, text: string, options: { delay: (number | undefined); } | undefined) {
|
||||
const handle = await this.$(selector);
|
||||
assert(handle, 'No node found for selector: ' + selector);
|
||||
|
|
|
@ -168,10 +168,6 @@ export class Frame {
|
|||
return this._secondaryWorld.select(selector, ...values);
|
||||
}
|
||||
|
||||
async tap(selector: string, options?: PointerActionOptions) {
|
||||
return this._secondaryWorld.tap(selector, options);
|
||||
}
|
||||
|
||||
async type(selector: string, text: string, options: { delay: (number | undefined); } | undefined) {
|
||||
return this._mainWorld.type(selector, text, options);
|
||||
}
|
||||
|
|
|
@ -303,35 +303,3 @@ export class Mouse {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class Touchscreen {
|
||||
private _client: CDPSession;
|
||||
private _keyboard: Keyboard;
|
||||
|
||||
constructor(client: CDPSession, keyboard: Keyboard) {
|
||||
this._client = client;
|
||||
this._keyboard = keyboard;
|
||||
}
|
||||
|
||||
async tap(x: number, y: number) {
|
||||
// Touches appear to be lost during the first frame after navigation.
|
||||
// This waits a frame before sending the tap.
|
||||
// @see https://crbug.com/613219
|
||||
await this._client.send('Runtime.evaluate', {
|
||||
expression: 'new Promise(x => requestAnimationFrame(() => requestAnimationFrame(x)))',
|
||||
awaitPromise: true
|
||||
});
|
||||
|
||||
const touchPoints = [{x: Math.round(x), y: Math.round(y)}];
|
||||
await this._client.send('Input.dispatchTouchEvent', {
|
||||
type: 'touchStart',
|
||||
touchPoints,
|
||||
modifiers: this._keyboard._modifiers
|
||||
});
|
||||
await this._client.send('Input.dispatchTouchEvent', {
|
||||
type: 'touchEnd',
|
||||
touchPoints: [],
|
||||
modifiers: this._keyboard._modifiers
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -379,10 +379,6 @@ export class ElementHandle extends JSHandle {
|
|||
await this._client.send('DOM.setFileInputFiles', { objectId, files });
|
||||
}
|
||||
|
||||
tap(options?: PointerActionOptions): Promise<void> {
|
||||
return this._performPointerAction(point => this._page.touchscreen.tap(point.x, point.y), options);
|
||||
}
|
||||
|
||||
async focus() {
|
||||
await this.evaluate(element => element.focus());
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ import { EmulationManager } from './EmulationManager';
|
|||
import { PDF } from './features/pdf';
|
||||
import { Frame } from './Frame';
|
||||
import { FrameManager, FrameManagerEvents } from './FrameManager';
|
||||
import { Keyboard, Mouse, Touchscreen } from './Input';
|
||||
import { Keyboard, Mouse } from './Input';
|
||||
import { ClickOptions, createJSHandle, ElementHandle, JSHandle, MultiClickOptions, PointerActionOptions } from './JSHandle';
|
||||
import { NetworkManagerEvents, Response } from './NetworkManager';
|
||||
import { Protocol } from './protocol';
|
||||
|
@ -61,7 +61,6 @@ export class Page extends EventEmitter {
|
|||
private _keyboard: Keyboard;
|
||||
private _mouse: Mouse;
|
||||
private _timeoutSettings: TimeoutSettings;
|
||||
private _touchscreen: Touchscreen;
|
||||
private _frameManager: FrameManager;
|
||||
private _emulationManager: EmulationManager;
|
||||
readonly accessibility: Accessibility;
|
||||
|
@ -93,7 +92,6 @@ export class Page extends EventEmitter {
|
|||
this._keyboard = new Keyboard(client);
|
||||
this._mouse = new Mouse(client, this._keyboard);
|
||||
this._timeoutSettings = new TimeoutSettings();
|
||||
this._touchscreen = new Touchscreen(client, this._keyboard);
|
||||
this.accessibility = new Accessibility(client);
|
||||
this._frameManager = new FrameManager(client, this, ignoreHTTPSErrors, this._timeoutSettings);
|
||||
this._emulationManager = new EmulationManager(client);
|
||||
|
@ -211,10 +209,6 @@ export class Page extends EventEmitter {
|
|||
return this._keyboard;
|
||||
}
|
||||
|
||||
get touchscreen(): Touchscreen {
|
||||
return this._touchscreen;
|
||||
}
|
||||
|
||||
frames(): Frame[] {
|
||||
return this._frameManager.frames();
|
||||
}
|
||||
|
@ -729,10 +723,6 @@ export class Page extends EventEmitter {
|
|||
return this.mainFrame().select(selector, ...values);
|
||||
}
|
||||
|
||||
tap(selector: string, options?: PointerActionOptions) {
|
||||
return this.mainFrame().tap(selector, options);
|
||||
}
|
||||
|
||||
type(selector: string, text: string, options: { delay: (number | undefined); } | undefined) {
|
||||
return this.mainFrame().type(selector, text, options);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ export { Permissions } from './features/permissions';
|
|||
export { Tracing } from './features/tracing';
|
||||
export { Worker, Workers } from './features/workers';
|
||||
export { Frame } from './Frame';
|
||||
export { Keyboard, Mouse, Touchscreen } from './Input';
|
||||
export { Keyboard, Mouse } from './Input';
|
||||
export { ElementHandle, JSHandle } from './JSHandle';
|
||||
export { Request, Response } from './NetworkManager';
|
||||
export { ConsoleMessage, FileChooser, Page } from './Page';
|
||||
|
|
|
@ -259,13 +259,6 @@ export class DOMWorld {
|
|||
}, values) as Promise<string[]>;
|
||||
}
|
||||
|
||||
async tap(selector: string) {
|
||||
const handle = await this.$(selector);
|
||||
assert(handle, 'No node found for selector: ' + selector);
|
||||
await handle.tap();
|
||||
await handle.dispose();
|
||||
}
|
||||
|
||||
async type(selector: string, text: string, options: { delay: (number | undefined); } | undefined) {
|
||||
const handle = await this.$(selector);
|
||||
assert(handle, 'No node found for selector: ' + selector);
|
||||
|
|
|
@ -252,10 +252,6 @@ export class Frame {
|
|||
return this._mainWorld.click(selector, options);
|
||||
}
|
||||
|
||||
async tap(selector: string) {
|
||||
return this._mainWorld.tap(selector);
|
||||
}
|
||||
|
||||
async type(selector: string, text: string, options: { delay: (number | undefined); } | undefined) {
|
||||
return this._mainWorld.type(selector, text, options);
|
||||
}
|
||||
|
|
|
@ -257,36 +257,3 @@ export class Mouse {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class Touchscreen {
|
||||
_client: JugglerSession;
|
||||
_keyboard: Keyboard;
|
||||
_mouse: Mouse;
|
||||
constructor(client: JugglerSession, keyboard: Keyboard, mouse: Mouse) {
|
||||
this._client = client;
|
||||
this._keyboard = keyboard;
|
||||
this._mouse = mouse;
|
||||
}
|
||||
|
||||
async tap(x: number, y: number) {
|
||||
const touchPoints = [{x: Math.round(x), y: Math.round(y)}];
|
||||
let {defaultPrevented} = (await this._client.send('Page.dispatchTouchEvent', {
|
||||
type: 'touchStart',
|
||||
touchPoints,
|
||||
modifiers: this._keyboard._modifiers
|
||||
}));
|
||||
defaultPrevented = (await this._client.send('Page.dispatchTouchEvent', {
|
||||
type: 'touchEnd',
|
||||
touchPoints,
|
||||
modifiers: this._keyboard._modifiers
|
||||
})).defaultPrevented || defaultPrevented;
|
||||
// Do not dispatch related mouse events if either of touch events
|
||||
// were prevented.
|
||||
// See https://developer.mozilla.org/en-US/docs/Web/API/Touch_events/Supporting_both_TouchEvent_and_MouseEvent#Event_order
|
||||
if (defaultPrevented)
|
||||
return;
|
||||
await this._mouse.move(x, y);
|
||||
await this._mouse.down();
|
||||
await this._mouse.up();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -274,12 +274,6 @@ export class ElementHandle extends JSHandle {
|
|||
await this._frame._page.mouse.click(x, y, options);
|
||||
}
|
||||
|
||||
async tap() {
|
||||
await this._scrollIntoViewIfNeeded();
|
||||
const {x, y} = await this._clickablePoint();
|
||||
await this._frame._page.touchscreen.tap(x, y);
|
||||
}
|
||||
|
||||
async uploadFile(...filePaths: Array<string>) {
|
||||
const files = filePaths.map(filePath => path.resolve(filePath));
|
||||
await this._session.send('Page.setFileInputFiles', {
|
||||
|
|
|
@ -1,21 +1,20 @@
|
|||
import { JSHandle, ElementHandle } from './JSHandle';
|
||||
|
||||
import {RegisteredListener, helper, debugError, assert} from '../helper';
|
||||
import {Keyboard, Mouse, Touchscreen} from './Input';
|
||||
import {Dialog} from './Dialog';
|
||||
import {TimeoutError} from '../Errors';
|
||||
import { EventEmitter } from 'events';
|
||||
import * as fs from 'fs';
|
||||
import * as mime from 'mime';
|
||||
import {EventEmitter} from 'events';
|
||||
import {createHandle} from './JSHandle';
|
||||
import {Connection, JugglerSession, JugglerSessionEvents} from './Connection';
|
||||
import {FrameManager, normalizeWaitUntil, FrameManagerEvents} from './FrameManager';
|
||||
import {NetworkManager, Request, Response, NetworkManagerEvents} from './NetworkManager';
|
||||
import { TimeoutError } from '../Errors';
|
||||
import { assert, debugError, helper, RegisteredListener } from '../helper';
|
||||
import { TimeoutSettings } from '../TimeoutSettings';
|
||||
import {NavigationWatchdog} from './NavigationWatchdog';
|
||||
import {Accessibility} from './features/accessibility';
|
||||
import { Target, BrowserContext } from './Browser';
|
||||
import { BrowserContext, Target } from './Browser';
|
||||
import { Connection, JugglerSession, JugglerSessionEvents } from './Connection';
|
||||
import { Dialog } from './Dialog';
|
||||
import { Events } from './events';
|
||||
import { Accessibility } from './features/accessibility';
|
||||
import { FrameManager, FrameManagerEvents, normalizeWaitUntil } from './FrameManager';
|
||||
import { Keyboard, Mouse } from './Input';
|
||||
import { createHandle, ElementHandle, JSHandle } from './JSHandle';
|
||||
import { NavigationWatchdog } from './NavigationWatchdog';
|
||||
import { NetworkManager, NetworkManagerEvents, Request, Response } from './NetworkManager';
|
||||
|
||||
|
||||
const writeFileAsync = helper.promisify(fs.writeFile);
|
||||
|
||||
|
@ -25,7 +24,6 @@ export class Page extends EventEmitter {
|
|||
private _target: Target;
|
||||
private _keyboard: Keyboard;
|
||||
private _mouse: Mouse;
|
||||
private _touchscreen: Touchscreen;
|
||||
readonly accessibility: Accessibility;
|
||||
private _closed: boolean;
|
||||
private _pageBindings: Map<string, Function>;
|
||||
|
@ -34,7 +32,7 @@ export class Page extends EventEmitter {
|
|||
private _eventListeners: RegisteredListener[];
|
||||
private _viewport: Viewport;
|
||||
private _disconnectPromise: Promise<Error>;
|
||||
emulateMedia: (type: string) => Promise<void>;
|
||||
|
||||
static async create(session, target: Target, defaultViewport: Viewport | null) {
|
||||
const page = new Page(session, target);
|
||||
await Promise.all([
|
||||
|
@ -55,7 +53,6 @@ export class Page extends EventEmitter {
|
|||
this._target = target;
|
||||
this._keyboard = new Keyboard(session);
|
||||
this._mouse = new Mouse(session, this._keyboard);
|
||||
this._touchscreen = new Touchscreen(session, this._keyboard, this._mouse);
|
||||
this.accessibility = new Accessibility(session);
|
||||
this._closed = false;
|
||||
this._pageBindings = new Map();
|
||||
|
@ -148,6 +145,10 @@ export class Page extends EventEmitter {
|
|||
await this._networkManager.setExtraHTTPHeaders(headers);
|
||||
}
|
||||
|
||||
async emulateMedia(type: string): Promise<void> {
|
||||
await this.emulateMediaType(type);
|
||||
}
|
||||
|
||||
async emulateMediaType(type: string | null) {
|
||||
assert(type === 'screen' || type === 'print' || type === null, 'Unsupported media type: ' + type);
|
||||
await this._session.send('Page.setEmulatedMedia', {media: type || ''});
|
||||
|
@ -342,10 +343,6 @@ export class Page extends EventEmitter {
|
|||
return this._mouse;
|
||||
}
|
||||
|
||||
get touchscreen(){
|
||||
return this._touchscreen;
|
||||
}
|
||||
|
||||
async waitForNavigation(options: { timeout?: number; waitUntil?: string | Array<string>; } = {}) {
|
||||
return this._frameManager.mainFrame().waitForNavigation(options);
|
||||
}
|
||||
|
@ -482,10 +479,6 @@ export class Page extends EventEmitter {
|
|||
return await this._frameManager.mainFrame().click(selector, options);
|
||||
}
|
||||
|
||||
tap(selector: string) {
|
||||
return this.mainFrame().tap(selector);
|
||||
}
|
||||
|
||||
async type(selector: string, text: string, options: { delay: (number | undefined); } | undefined) {
|
||||
return await this._frameManager.mainFrame().type(selector, text, options);
|
||||
}
|
||||
|
@ -573,9 +566,6 @@ export class Page extends EventEmitter {
|
|||
}
|
||||
}
|
||||
|
||||
// Expose alias for deprecated method.
|
||||
Page.prototype.emulateMedia = Page.prototype.emulateMediaType;
|
||||
|
||||
export class ConsoleMessage {
|
||||
private _type: string;
|
||||
private _args: any[];
|
||||
|
|
|
@ -9,7 +9,7 @@ export { ExecutionContext } from './ExecutionContext';
|
|||
export { Accessibility } from './features/accessibility';
|
||||
export { Permissions } from './features/permissions';
|
||||
export { Frame } from './FrameManager';
|
||||
export { Keyboard, Mouse, Touchscreen } from './Input';
|
||||
export { Keyboard, Mouse } from './Input';
|
||||
export { ElementHandle, JSHandle } from './JSHandle';
|
||||
export { Request, Response } from './NetworkManager';
|
||||
export { ConsoleMessage, Page } from './Page';
|
||||
|
|
|
@ -134,7 +134,7 @@ export class Keyboard {
|
|||
key: description.key,
|
||||
windowsVirtualKeyCode: description.keyCode,
|
||||
code: description.code,
|
||||
isKeypad: description.location === 3
|
||||
isKeypad: description.isKeypad
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -154,7 +154,6 @@ module.exports.addTests = ({testRunner, product, playwrightPath}) => {
|
|||
require('./screenshot.spec.js').addTests(testOptions);
|
||||
require('./queryselector.spec.js').addTests(testOptions);
|
||||
require('./target.spec.js').addTests(testOptions);
|
||||
require('./touchscreen.spec.js').addTests(testOptions);
|
||||
require('./waittask.spec.js').addTests(testOptions);
|
||||
if (CHROME) {
|
||||
require('./CDPSession.spec.js').addTests(testOptions);
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
/**
|
||||
* Copyright 2018 Google Inc. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
module.exports.addTests = function({testRunner, expect, playwright, FFOX, CHROME, WEBKIT}) {
|
||||
const {describe, xdescribe, fdescribe} = testRunner;
|
||||
const {it, fit, xit} = testRunner;
|
||||
const iPhone = playwright.devices['iPhone 6'];
|
||||
const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;
|
||||
describe.skip(WEBKIT)('Touchscreen', function() {
|
||||
it('should tap the button', async({page, server}) => {
|
||||
await page.emulate(iPhone);
|
||||
await page.goto(server.PREFIX + '/input/button.html');
|
||||
await page.tap('button');
|
||||
expect(await page.evaluate(() => result)).toBe('Clicked');
|
||||
});
|
||||
it('should report touches', async({page, server}) => {
|
||||
await page.emulate(iPhone);
|
||||
await page.goto(server.PREFIX + '/input/touches.html');
|
||||
const button = await page.$('button');
|
||||
await button.tap();
|
||||
expect(await page.evaluate(() => getResult())).toEqual(['Touchstart: 0', 'Touchend: 0']);
|
||||
});
|
||||
});
|
||||
};
|
Загрузка…
Ссылка в новой задаче