Trouble selecting login button with Puppeteer: 'No node found' error

I’m trying to automate a login process using Puppeteer, but I’m running into a problem. When I try to click the login button, I get a ‘no node found’ error. Here’s what the login button looks like in the HTML:

<input type="submit" value="Log In" class="buttonss" style="font-size:19px">

I’ve tried using this selector:

input[name="Log In"]

But it’s not working. Here’s the code I’m using:

await Promise.all([
  page.click('input[name="Log In"]'),
  page.waitForNavigation({ waitUntil: "networkidle0" }),
]);

Can anyone help me figure out the right way to select this login button? I’m not sure if I’m using the wrong selector or if there’s another issue. Thanks!

hey samuel, have u tried using the value attribute instead? somthing like this might work:

await Promise.all([
  page.click('input[value="Log In"]'),
  page.waitForNavigation({ waitUntil: "networkidle0" }),
]);

also make sure the button is visible and not hidden by any overlays. good luck!

Having dealt with similar Puppeteer challenges, I’d suggest a different approach. Instead of relying on attributes, try using XPath. It’s often more robust for complex DOM structures.

Here’s an example:

await Promise.all([
  page.$x('//input[@type="submit" and @value="Log In"]').then(el => el[0].click()),
  page.waitForNavigation({ waitUntil: 'networkidle0' })
]);

This XPath selector targets the input element based on its type and value, which should be more reliable. If you’re still having issues, consider adding a small delay before the click action to ensure the page has fully loaded. Also, double-check that you’re on the correct frame or page when executing the script.

I encountered a similar issue with Puppeteer. The error occurs because the selector is targeting a non-existent ‘name’ attribute, while the login button only has a class and a value.

One effective solution is to use a selector based on the class and value attributes. For example, use:

await Promise.all([
  page.click('input.buttonss[value="Log In"]'),
  page.waitForNavigation({ waitUntil: "networkidle0" })
]);

If this doesn’t work, check if the element is inside an iframe or if multiple elements match the selector. This technique resolved the issue for me previously.