From c8bb11adfcf1537032730a91baa3c36a6e324926 Mon Sep 17 00:00:00 2001
From: charlieinitialdigital
<122505548+charlieinitialdigital@users.noreply.github.com>
Date: Fri, 3 Feb 2023 18:59:21 +0800
Subject: [PATCH] feat: add touchstart, touchmove and touchend methods (#9622)
---
docs/api/puppeteer.elementhandle.md | 3 +
docs/api/puppeteer.elementhandle.touchend.md | 23 +++++++
docs/api/puppeteer.elementhandle.touchmove.md | 23 +++++++
.../api/puppeteer.elementhandle.touchstart.md | 23 +++++++
docs/api/puppeteer.touchscreen.md | 9 ++-
docs/api/puppeteer.touchscreen.touchend.md | 19 ++++++
docs/api/puppeteer.touchscreen.touchmove.md | 26 ++++++++
docs/api/puppeteer.touchscreen.touchstart.md | 26 ++++++++
.../src/common/ElementHandle.ts | 20 +++++-
packages/puppeteer-core/src/common/Input.ts | 28 ++++++++
test/TestExpectations.json | 6 ++
test/assets/input/touches-move.html | 65 +++++++++++++++++++
test/src/touchscreen.spec.ts | 27 +++++++-
13 files changed, 293 insertions(+), 5 deletions(-)
create mode 100644 docs/api/puppeteer.elementhandle.touchend.md
create mode 100644 docs/api/puppeteer.elementhandle.touchmove.md
create mode 100644 docs/api/puppeteer.elementhandle.touchstart.md
create mode 100644 docs/api/puppeteer.touchscreen.touchend.md
create mode 100644 docs/api/puppeteer.touchscreen.touchmove.md
create mode 100644 docs/api/puppeteer.touchscreen.touchstart.md
create mode 100644 test/assets/input/touches-move.html
diff --git a/docs/api/puppeteer.elementhandle.md b/docs/api/puppeteer.elementhandle.md
index 74e574b1..0fdeb068 100644
--- a/docs/api/puppeteer.elementhandle.md
+++ b/docs/api/puppeteer.elementhandle.md
@@ -73,6 +73,9 @@ The constructor for this class is marked as internal. Third-party code should no
| [select(values)](./puppeteer.elementhandle.select.md) | | Triggers a change
and input
event once all the provided options have been selected. If there's no <select>
element matching selector
, the method throws an error. |
| [tap(this)](./puppeteer.elementhandle.tap.md) | | This method scrolls element into view if needed, and then uses [Touchscreen.tap()](./puppeteer.touchscreen.tap.md) to tap in the center of the element. If the element is detached from DOM, the method throws an error. |
| [toElement(tagName)](./puppeteer.elementhandle.toelement.md) | | Converts the current handle to the given element type. |
+| [touchEnd(this)](./puppeteer.elementhandle.touchend.md) | | |
+| [touchMove(this)](./puppeteer.elementhandle.touchmove.md) | | |
+| [touchStart(this)](./puppeteer.elementhandle.touchstart.md) | | |
| [type(text, options)](./puppeteer.elementhandle.type.md) | |
Focuses the element, and then sends a keydown
, keypress
/input
, and keyup
event for each character in the text.
To press a special key, like Control
or ArrowDown
, use [ElementHandle.press()](./puppeteer.elementhandle.press.md).
elementHandle
to point to an [input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input). |
| [waitForSelector(selector, options)](./puppeteer.elementhandle.waitforselector.md) | | Wait for an element matching the given selector to appear in the current element.
Unlike [Frame.waitForSelector()](./puppeteer.frame.waitforselector.md), this method does not work across navigations or if the element is detached from DOM.
| diff --git a/docs/api/puppeteer.elementhandle.touchend.md b/docs/api/puppeteer.elementhandle.touchend.md new file mode 100644 index 00000000..037605aa --- /dev/null +++ b/docs/api/puppeteer.elementhandle.touchend.md @@ -0,0 +1,23 @@ +--- +sidebar_label: ElementHandle.touchEnd +--- + +# ElementHandle.touchEnd() method + +#### Signature: + +```typescript +class ElementHandle { + touchEnd(this: ElementHandletouchstart
and touchend
event. |
+| Method | Modifiers | Description |
+| --------------------------------------------------------- | --------- | --------------------------------------------------------------------- |
+| [tap(x, y)](./puppeteer.touchscreen.tap.md) | | Dispatches a touchstart
and touchend
event. |
+| [touchEnd()](./puppeteer.touchscreen.touchend.md) | | Dispatches a touchend
event. |
+| [touchMove(x, y)](./puppeteer.touchscreen.touchmove.md) | | Dispatches a touchMove
event. |
+| [touchStart(x, y)](./puppeteer.touchscreen.touchstart.md) | | Dispatches a touchstart
event. |
diff --git a/docs/api/puppeteer.touchscreen.touchend.md b/docs/api/puppeteer.touchscreen.touchend.md
new file mode 100644
index 00000000..2f94f4b0
--- /dev/null
+++ b/docs/api/puppeteer.touchscreen.touchend.md
@@ -0,0 +1,19 @@
+---
+sidebar_label: Touchscreen.touchEnd
+---
+
+# Touchscreen.touchEnd() method
+
+Dispatches a `touchend` event.
+
+#### Signature:
+
+```typescript
+class Touchscreen {
+ touchEnd(): Promise