Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TouchScreen.tap #639

Merged
merged 3 commits into from
Sep 2, 2017
Merged

TouchScreen.tap #639

merged 3 commits into from
Sep 2, 2017

Conversation

JoelEinbinder
Copy link
Contributor

@JoelEinbinder JoelEinbinder commented Aug 31, 2017

This adds a touchScreen input object with a tap method, and an equivalent tap on elementHandle. In the future touchScreen with have methods like swipe, pinch and zoom. The other methods are waiting on some backend work to make them less racy.

#568 #569 #158

Copy link
Contributor

@aslushnikov aslushnikov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall looks good!

@@ -112,6 +114,10 @@ class ElementHandle {
return await this.evaluate((element, key) => element.getAttribute(key), key);
}

async tap() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jsdoc

docs/api.md Outdated
#### elementHandle.tap()
- 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we explain what's a tap?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A concise and effective definition: https://api.jquerymobile.com/tap

docs/api.md Outdated
@@ -81,6 +82,8 @@
+ [mouse.down([options])](#mousedownoptions)
+ [mouse.move(x, y, [options])](#mousemovex-y-options)
+ [mouse.up([options])](#mouseupoptions)
* [class: TouchScreen](#class-touchscreen)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we also have page.tap() similarly to page.click()?

docs/api.md Outdated
@@ -64,6 +64,7 @@
+ [page.setUserAgent(userAgent)](#pagesetuseragentuseragent)
+ [page.setViewport(viewport)](#pagesetviewportviewport)
+ [page.title()](#pagetitle)
+ [page.touchScreen](#pagetouchscreen)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the page.touchScreen feels slightly weird. Paul, any naming ideas? @paulirish

Copy link
Contributor Author

@JoelEinbinder JoelEinbinder Aug 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can do page.touchscreen, all lowercase because apparently touchscreen is one word

<script src="mouse-helper.js"></script>
<button onclick="clicked();">Click target</button>
<script>
window.result = [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't we have the same asset for mouse? Can we unify the two, simply recording all the events for the button?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a similar one for keyboard, but it has a textarea.

@@ -1497,6 +1497,18 @@ describe('Page', function() {
[200, 300]
]);
}));
it('should tap the button', SX(async function() {
await page.goto(PREFIX + '/input/button.html');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is is actually ok to send touches to the non-touch viewport?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems fine.

Copy link
Contributor

@aslushnikov aslushnikov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great patch, thanks.

await page.goto(PREFIX + '/input/touches.html');
const button = await page.$('button');
await button.tap();
expect(await page.evaluate(() => getResult())).toEqual(['Touchstart: 0', 'Touchend: 0']);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, how's getResult() different from result? You use one in the first test and other in the second

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it clears the result

@aslushnikov aslushnikov merged commit 64124df into puppeteer:master Sep 2, 2017
@LLLLLamHo
Copy link

I am waiting for swipe function,It may only be used now evaluate function in the browser use JavaScript to simulate swipe function.

@Genuifx
Copy link

Genuifx commented Nov 20, 2017

@JoelEinbinder thanks for your payout, how about the swipe, pinch and zoom events? when are they will be released?

@KartikKumarSahoo
Copy link

@JoelEinbinder Is swipe ready yet?

@MTTTM
Copy link

MTTTM commented May 23, 2021

@JoelEinbinder Is swipe ready yet?

it looks like no yet!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants