Page.click() does not work with an input selector
See original GitHub issueSteps to reproduce
Tell us about your environment:
- Puppeteer version: 1.8.0
- Platform / OS version: Windows 10
- URLs (if applicable):
- Node.js version: 8.11.4
What steps will reproduce the problem?
I am trying to use page.click() to go to the username filed in Instagram. If I use the selector input[name=‘username’] in developer console it works. However, puppeteer keeps throwing an error that no node was found
Please include code that reproduces the issue.
const puppeteer = require('puppeteer');
(async () => {
try {
const Browser = await puppeteer.launch({headless:false,
defaultViewport:{width:600,height:800},
waitUntil: ['load','domcontentloaded','networkidle0','networkidle2'],
timeout :0
});
const page=await Browser.newPage();
await page.goto('https://www.instagram.com/accounts/login/?source=auth_switcher');
await page.click('input[name="username"]');
await page.keyboard.type('NewUser');
await Browser.close();
console.log("Iam done!");
} catch(e) {console.log('main program error:' + e);
}
})();
What is the expected result?
I should be able to type my username
What happens instead?
Puppeteer can’t find the user name field
Issue Analytics
- State:
- Created 5 years ago
- Comments:27 (5 by maintainers)
Top Results From Across the Web
Puppeteer page.click CSS selector not working
I tried doing something like the examples below: await page. click("ul. select2-selection__rendered:nth-of-type(2)>li>input");
Read more ><input type="button"> - HTML: HyperText Markup Language
The script gets a reference to the HTMLInputElement object representing the <input> in the DOM, saving this reference in the variable button ....
Read more >Page.click() method
This method fetches an element with selector, scrolls it into view if needed, and then uses Page.mouse to click in the center of...
Read more >Element selectors | Playwright
Selectors are strings that point to the elements in the page. They are used to perform actions on those elements by means of...
Read more >Handling Events
Clicks on the button cause that handler to run, but clicks on the rest of the document do not. Giving a node an...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m running into the same issue. Strangely, if I use page.evaluate, it does work. For example:
I’d be curious if the same workaround works for you.
Here the same:
await page.$eval('#link', elem => elem.click()); // works
await page.click('#link'); // doesn't work
const btn= await page.waitForSelector('#link'); await btn.click(); // doesn't work