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 not working when is not focused

See original GitHub issue

Environment:

  • Puppeteer version: 1.8.0
  • Platform / OS version: Win 10 64b and Ubuntu 18.04.1 LTS
  • URLs (if applicable): No
  • Node.js version: v10.6.0

I am using puppeteer for testing my pages. When I run the app and hide it into background then puppeteer is paused (or freeze). When I move puppeteer into foreground is running normally.

I think that its problem “when window is not focused, its not working”.

This behavior is on windows and linux too.

Set up code:

			const args = []
			args.push('--start-maximized')
			args.push('--disable-gpu')
			args.push('--disable-setuid-sandbox')
			args.push('--force-device-scale-factor')
			args.push('--ignore-certificate-errors')
			args.push('--no-sandbox')

			this.driver = await puppeteer.launch({
				headless: false,
				args,
				userDataDir: `puppeteer_profile`,
			})


i happen only “sometimes” I don’t know when.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:27
  • Comments:78 (11 by maintainers)

github_iconTop GitHub Comments

22reactions
entrptahercommented, Nov 8, 2018

Nope you are not only one, I have same problem above.

17reactions
david-littlefieldcommented, Sep 12, 2019

[Solution]:

Add the following values to the array you assign to the args property in the options object. Now, you should be able to run Puppeteer while your window is in the foreground, background, or minimized.

Update: I’m running parallel instances of Puppeteer using the same script in multiple windows with one tab per window. Each window completed successfully whether it was in the foreground, background, or minimized. And, it worked in both headless and headful mode.

const chromeArgs = [
  '--disable-background-timer-throttling',
  '--disable-backgrounding-occluded-windows',
  '--disable-renderer-backgrounding'
];

Solution and explanation available in an article written by Rohit Kumar, @rkr090 at Big Binary:

Debugging failing tests in puppeteer because of background tab

Read more comments on GitHub >

github_iconTop Results From Across the Web

Puppeteer not working as excepted (pause/freeze when ...
I'm using the default Chromium browser of Puppeteer. All is working well, but the problem is, that when I run the crawling script,...
Read more >
Puppeteer documentation - DevDocs
Puppeteer is a Node library which provides a high-level API to control Chromium or Chrome over the DevTools Protocol. The Puppeteer API is...
Read more >
FAQ | Puppeteer
No. Both projects are valuable for very different reasons: Selenium/WebDriver focuses on cross-browser automation; its value proposition is a single standard ...
Read more >
Overview of Puppeteer and puppeteer-core in Node.js
Puppeteer is a Node library which provides a high-level API to control Chrome or Chromium over the DevTools Protocol. Here is an overview...
Read more >
Puppeteer overview - Microsoft Edge Development
Headless browsers don't display a user interface (UI), so you must use the command line. You can also configure Puppeteer to run full...
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