Skip to content Skip to sidebar Skip to footer

Unable To Click Button Using Puppeteer

I'm trying to click on a button that's in a frame element. I know I'm selecting the right button because I can print its textContent: let buttonText = await frame.evaluate( button

Solution 1:

Sometimes elementHandle.click() does not work due to complicated click emulation algorithm, but the web API variant in evaluated function works. Try this:

const [ button ] = await frame.$x( '/html/body/form/div[7]/div[2]/table[1]/tbody/tr/td/table/tbody/tr/td[2]/table/tbody/tr/td[2]' );

    await frame.evaluate(element => { element.click(); }, button);

    awaitnewPromise( resolve =>setTimeout( resolve, 2000 ) ); // Delay 2 seconds.

Solution 2:

I'm no expert but I think you should have something like

await page.click(button)

instead of

button.click()

Would have commented instead of answered (but I don't have 50 rep yet) hence if it's not the right answer, I'm sorry!

For example, in my code for a similar action, I have:

await page.click('.sc-kAzzGY',{delay: 10});

Solution 3:

You need to switch the context to the iframe, and then click to selector.

https://pptr.dev/#?product=Puppeteer&version=v9.0.0&show=api-class-frame

Post a Comment for "Unable To Click Button Using Puppeteer"