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

Page.click() does not work with an input selector #6462

Closed
pauloacosta opened this issue Oct 1, 2020 · 3 comments
Closed

Page.click() does not work with an input selector #6462

pauloacosta opened this issue Oct 1, 2020 · 3 comments

Comments

@pauloacosta
Copy link

Ps.: View the issue #3347 - The problem continues.

Steps to reproduce
Tell us about your environment:

Puppeteer version: 5.3.0
Platform / OS version: Windows 10
URLs (if applicable):
Node.js version: v12.18.3
What steps will reproduce the problem?

I am trying to use page.click() to click at a Button . If I use the selector button[type='button'] in developer console it works. However, puppeteer keeps throwing an error that no node was found.

This issue is the same problem related at: #3347

I am using a workaround:

    selector = 'button[type="button"]';
    await youtube.page.waitForSelector (selector);
    await youtube.page.evaluate((selector) => document.querySelector(selector).click(), selector); 
@gidztech
Copy link

I just ran into this and for me it was because the element wasn't in view. According to #2190 (comment), Puppeteer will attempt to scroll the element into view before clicking, but it can fail sometimes, like if you have custom scrolling behavior.

I was able to get it working for me with:

await page.evaluate(selector => document.querySelector(selector).scrollIntoView(), [mySelector]);
await page.click(mySelector);

I think Puppeteer should be throwing an error if it fails to get the element in view itself, as part of the click function, because right now it thinks it's successfully clicked the element but it didn't. This is misleading.

I know it errors if you click an element that has no height.

mathiasbynens added a commit that referenced this issue Apr 19, 2021
The `Page#click` method relies on `Mouse#click` for execution. `Mouse#click` triggers the `move`, `down`, and `up` methods in parallel waiting for all of them to finish, when they should be called sequentially instead.

Issue: #6462, #3347
Co-authored-by: Mathias Bynens <mathias@qiwi.be>
@stale
Copy link

stale bot commented Jun 25, 2022

We're marking this issue as unconfirmed because it has not had recent activity and we weren't able to confirm it yet. It will be closed if no further activity occurs within the next 30 days.

@stale stale bot added the unconfirmed label Jun 25, 2022
@stale
Copy link

stale bot commented Jul 25, 2022

We are closing this issue. If the issue still persists in the latest version of Puppeteer, please reopen the issue and update the description. We will try our best to accomodate it!

@stale stale bot closed this as completed Jul 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants