feat: implement long press and double tap gestures
This commit is contained in:
@@ -97,4 +97,28 @@ export class GestureSimulator {
|
||||
await this.page.touchscreen.touchEnd();
|
||||
await this.page.touchscreen.touchEnd();
|
||||
}
|
||||
|
||||
async longPress(element: Locator, duration: number = 1000): Promise<void> {
|
||||
const box = await element.boundingBox();
|
||||
if (!box) throw new Error('Element not visible');
|
||||
|
||||
const x = box.x + box.width / 2;
|
||||
const y = box.y + box.height / 2;
|
||||
|
||||
await this.page.touchscreen.tap(x, y);
|
||||
await this.page.waitForTimeout(duration);
|
||||
await this.page.touchscreen.touchEnd();
|
||||
}
|
||||
|
||||
async doubleTap(element: Locator): Promise<void> {
|
||||
const box = await element.boundingBox();
|
||||
if (!box) throw new Error('Element not visible');
|
||||
|
||||
const x = box.x + box.width / 2;
|
||||
const y = box.y + box.height / 2;
|
||||
|
||||
await this.page.touchscreen.tap(x, y);
|
||||
await this.page.waitForTimeout(100);
|
||||
await this.page.touchscreen.tap(x, y);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user