JS disabled in Puppeteer even after `page.setJavaScriptEnabled(true);`
See original GitHub issueSteps to reproduce
Tell us about your environment:
- Puppeteer version: 1.18.1-next.1562564221866
- Platform / OS version: Mac OSX Mojave 10.14.5
- URLs (if applicable): https://www.youtube.com/
- Node.js version: 11.13.0
What steps will reproduce the problem?
const puppeteer = require('puppeteer');
(async() => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
//Allow JS.
await page.setJavaScriptEnabled(true);
//Go to YouTube homepage.
await page.goto('https://www.youtube.com/', {
waituntil: 'domcontentloaded',
});
//Click the sign in button at the top.
await page.click('#buttons #text');
//Fill out the username and click 'Next' (submit form).
await page.waitForSelector('input[type="email"]');
await page.type('input[type="email"]', USERNAME)
await page.$eval('form', form => form.submit());
//Fill out the password click 'SignIn' (submit form).
await page.waitForSelector('input[type="password"]');
await page.type('input[type="password"]', PASSWORD);
await page.$eval('form', form => form.submit());
//Take a screenshot of the page.
await await page.screenshot({
path: `test.png`,
fullPage: true
});
await browser.close()
})();
I have also tried launching browser with args: ['--no-sandbox', '--disable-setuid-sandbox']
with no success.
Here is what my code does:
- Goto https://www.youtube.com/.
- Click SignIn (top right).
- Fill in username and click Next.
- Fill in password and click Submit.
What is the expected result? A redirection back to YouTube homepage.
What happens instead? I get an error saying:
Couldn't sign you in
The browser you are using doesn't support JavaScript, or has JavaScript turned off.
I seem to have no issues when doing the listed steps manually on my Browser.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:6 (1 by maintainers)
Top Results From Across the Web
How can I disable javascript in puppeteer? - Stack Overflow
Try the following: page.setJavaScriptEnabled(false). Set this before navigating to the website. More information to read on this you can ...
Read more >Puppeteer documentation - DevDocs
Returns a list of devices to be used with page.emulate(options) . Actual list of devices can be found in src/common/DeviceDescriptors.ts . const puppeteer...
Read more >puppeteer.Page.setJavaScriptEnabled JavaScript and Node ...
Determines whether JavaScript is enabled on the page. Most used puppeteer functions. launch. The method launches a browser instance with given arguments. The ......
Read more >Avoiding Puppeteer Antipatterns - SerpApi
When possible, consider disabling JS with page.setJavaScriptEnabled(false) , stopping the browser with page.evaluate(() => window.stop()) or ...
Read more >Troubleshooting - Puppeteer
Chrome headless doesn't launch on Windows ... Some chrome policies might enforce running Chrome/Chromium with certain extensions. Puppeteer passes --disable- ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
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
Any updates on this. I tried all the possible solutions as mentioned by the author of this post but can’t make it work👍
Here is my code:
To change this behavior for puppeteer you have to set the user-agent in your args-options when launching. For example: