playwright icon indicating copy to clipboard operation
playwright copied to clipboard

[Feature] Support for touch events/gestures

Open arjunattam opened this issue 5 years ago • 43 comments

Web apps running on touch devices (e.g, mobile and Surface) rely on touch gestures like swiping and pinching to zoom. While page.dispatchEvent can manufacture synthetic touch points, having a simpler API would improve the dev experience.

Scenarios

  1. Two-finger pinch to zoom in/out on a particular element (e.g., canvas in Azure ML designer)
  2. Verify that two-finger left/right swipe is not leading to go back/forward

arjunattam avatar Jul 10 '20 02:07 arjunattam

It would also be interesting a feature to tap on certain elements or coordinates as Puppeteer allowed. Simple code as: await page.tap('div.example) await element.tap()

roune avatar Aug 14 '20 14:08 roune

+swipe

olexandr13 avatar Feb 04 '21 13:02 olexandr13

+for swipe

bonkalol avatar Mar 22 '21 10:03 bonkalol

+1 swipe

sergioariveros avatar Aug 03 '21 23:08 sergioariveros

is there some quick-access to achieve touch move in mobile, etc popup picker

eJayYoung avatar Aug 06 '21 08:08 eJayYoung

Having the ability to swipe, dragto, or even replicate the mouse class for touchscreen would be great. If I could use the touchscreen class to move, press down, move, and unpress, it would take care of a lot of issues that I'm currently having with dragging elements.

egreen0 avatar Mar 04 '22 00:03 egreen0

I found this issue because I wanted to be able to drag an element using touch events as described in https://github.com/microsoft/playwright/issues/12599. It looks like I might be able to dispatch the events (see https://github.com/microsoft/playwright/issues/6072) but it'd be nice to just say "dragto" and have it do the proper touchstart, touchmove and touchend behaviors for me.

blimmer avatar Mar 15 '22 19:03 blimmer

+1 for swipe action

dk-carma avatar May 10 '22 01:05 dk-carma

+1 for overall possibility to automate touch

sijakret avatar May 12 '22 10:05 sijakret

+1 for overall possibility to automate touch

mapau avatar May 12 '22 10:05 mapau

+1 for native mobile gestures like swipe

nnson0310 avatar Mar 06 '23 09:03 nnson0310

Is this experimental API (https://playwright.dev/docs/api/class-androidinput) an attempt to implement this feature? I didn't test it yet.

MRamonLeon avatar Mar 07 '23 12:03 MRamonLeon

+swipe

Tried a workaround with Touchevent, but I'm getting two touch points on the start and the end coordinates. Probably I messed up something.

        await page.evaluate(
            ([startX, startY, endX, endY]) => {
                const touchStartEvent = new TouchEvent("touchstart", {
                    bubbles: true,
                    cancelable: true,
                    composed: true,
                    touches: [new Touch({ identifier: 1, target: document.documentElement, clientX: startX, clientY: startY })],
                });
                document.elementFromPoint(startX, startY).dispatchEvent(touchStartEvent);

                const touchMoveEvent = new TouchEvent("touchmove", {
                    bubbles: true,
                    cancelable: true,
                    composed: true,
                    touches: [
                        new Touch({ identifier: 1, target: document.documentElement, clientX: startX, clientY: startY }),
                        new Touch({ identifier: 2, target: document.documentElement, clientX: endX, clientY: endY }),
                    ],
                });
                document.elementFromPoint(startX, startY).dispatchEvent(touchMoveEvent);

                const touchEndEvent = new TouchEvent("touchend", {
                    bubbles: true,
                    cancelable: true,
                    composed: true,
                    touches: [],
                });
                document.elementFromPoint(startX, startY).dispatchEvent(touchEndEvent);
            },
            [startX, startY, endX, endY]
        );

Orbisti avatar May 26 '23 13:05 Orbisti

+1 for swipe / dragTo / touch move 🙏

mfschieber avatar Jul 05 '23 14:07 mfschieber

+1 for swipe / dragTo / touch move

ghaiat avatar Jul 05 '23 17:07 ghaiat

+1 for swipe / dragTo / touch move

daoxiaonoodles avatar Jul 06 '23 07:07 daoxiaonoodles

+1 for swipe, pinch and dragTo.

awierda avatar Jul 10 '23 08:07 awierda

+1 for swipe

dariavan avatar Jul 19 '23 13:07 dariavan

+1 for swipe

mark1to avatar Aug 01 '23 10:08 mark1to

+1 for multi touch / simulating touch events

marwie avatar Aug 08 '23 13:08 marwie

+1 for simulating long press on mobile device

RatexMak avatar Nov 20 '23 14:11 RatexMak

damn this is really needed. Please implement this :)

Exordio avatar Dec 14 '23 12:12 Exordio

+1 for swipe/touch events please :)

cctui-dev avatar Dec 19 '23 15:12 cctui-dev

+1 for swipe

ant0d0v avatar Dec 25 '23 10:12 ant0d0v

+1 for swipe

Mark-770 avatar Jan 11 '24 06:01 Mark-770

+1 for swipe

artus9033 avatar Jan 28 '24 18:01 artus9033

+1 for all mobile gestures

Kostya4ki avatar Jan 31 '24 10:01 Kostya4ki

+1 swipe!

agray avatar Feb 18 '24 19:02 agray

playwright devs lazy as fuk, still not added after 3 years

dr3adx avatar Feb 19 '24 03:02 dr3adx

+1

MillerSvt avatar Mar 04 '24 13:03 MillerSvt