question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Puppeteer Won't Click on Element

See original GitHub issue

Trying to get Puppeteer to navigate through my login page which will bring the automated test to the main page of my site. It all works until it reaches ‘waitFor(’#idSIButton9’);'. Puppeteer successfully enters the password and username but can’t seem to select the submit button(#idSIButton9). Any idea what might be going wrong here? Let me know if you guys need more info. Thanks 😃

const puppeteer = require('puppeteer');
    const { defineSupportCode } = require('cucumber')

    defineSupportCode(({ Before, Given, When, Then }) => {
        Before({ timeout: 60 * 1000 }, async function testCase() {

            this.browser = await puppeteer.launch({ headless: false });

            this.page = await this.browser.newPage();

            await this.page.setViewport({width: 1024, height: 768});

            await this.page.goto('http://localhost:3000', {waitUntil: 'networkidle2'});

            await this.page.screenshot({ path: 'test_artifacts/img/load.png', fullPage: true });

            await this.page.waitFor('button');

            await this.page.click('button');

            await this.page.waitFor('#i0116');

            await this.page.type('#i0116', 'username');

            await this.page.waitFor('#i0118');

            await this.page.type('#i0118', 'password');

            await this.page.waitFor('#idSIButton9');

            await this.page.click('#idSIButton9');

        })

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:39 (2 by maintainers)

github_iconTop GitHub Comments

102reactions
fran0254commented, Jan 16, 2018

Try to set a time before clicking…

await this.page.waitFor(2000);
await this.page.click('#idSIButton9');
75reactions
pgunsolleycommented, Feb 18, 2019

In my case, I’m able to use this reliably:

page.$eval(selectorStr, elem => elem.click());

Read more comments on GitHub >

github_iconTop Results From Across the Web

puppeteer element.click() not working and not throwing an error
The problem is that because the view (div) is animating the element's boundingBox() is changing, and between the time of asking for the...
Read more >
7 solutions for page.click() is not working in puppeteer
1. Focus and Enter - First Focus on the element and then press enter. · 2. using $eval - you can try as...
Read more >
Page.click() method - Puppeteer
This method fetches an element with selector , scrolls it into view if needed, and then uses Page.mouse to click in the center...
Read more >
Error - Click not executed | Checkly
Not-so-obvious: the element we are trying to click is on the page, but is not the one receiving the click; there might be...
Read more >
How to Click on Element with Puppeteer and Chrome
How to Click on Element with Puppeteer and Chrome · button left, right, or middle, defaults to left. · clickCount defaults to 1....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found