Background:
When taking screenshots of web pages with a headless browser, I kept finding that on pages with lots of images, some images wouldn't load.
No matter how long I waited, they still wouldn't load.
Troubleshooting steps:
- After turning off headless mode, I found that everything loaded normally.
- At first I suspected the headless browser's resource limits were causing a per-domain concurrency cap.
- But forcing the h2 protocol didn't solve it either.
- Searching online, I found that the old headless browser and the headed browser didn't share the same codebase.
- I then discovered that Chrome had introduced a new mode that merged the codebases.
Background:
When taking screenshots of web pages with a headless browser, I kept finding that on pages with lots of images, some images wouldn't load.
No matter how long I waited, they still wouldn't load.
Troubleshooting steps:
- After turning off headless mode, I found that everything loaded normally.
- At first I suspected the headless browser's resource limits were causing a per-domain concurrency cap.
- But forcing the h2 protocol didn't solve it either.
- Searching online, I found that the old headless browser and the headed browser didn't share the same codebase.
- I then discovered that Chrome had introduced a new mode that merged the codebases.
If you're running into similar issues, try the new headless mode.
Chrome Headless Mode: Updates and Improvements
In Chrome 112, Headless mode got a major upgrade docs, bringing many new features and improvements. Here are the main updates:
New Features
Unified Codebase
The new Headless mode shares a codebase with regular Chrome, which fixes many issues caused by the old standalone implementation and simplifies maintenance.
Command-Line Flags
It supports new command-line flags such as --dump-dom, --screenshot, and --print-to-pdf, improving control and automation.
Debugging
With the --remote-debugging-port flag, you can remotely debug Chrome instances running in Headless mode, which makes development and debugging much easier.
Usage Examples
Puppeteer
Using the new Headless mode is easy—just specify headless: 'new' when launching the browser:
const browser = await puppeteer.launch({ headless: 'new' });
Selenium-WebDriver
In Selenium, you can enable the new Headless mode by setting Chrome options:
const driver = await env.builder().setChromeOptions(options.addArguments('--headless=new')).build();
Conclusion
This update not only simplifies automated testing but also improves the consistency and reliability of test results. The new mode gives developers more powerful tools and a more convenient way to debug.
Chrome Headless Mode: Updates and Improvements
In Chrome 112, Headless mode got a major upgrade docs, bringing many new features and improvements. Here are the main updates:
New Features
Unified Codebase
The new Headless mode shares a codebase with regular Chrome, which fixes many issues caused by the old standalone implementation and simplifies maintenance.
Command-Line Flags
It supports new command-line flags such as --dump-dom, --screenshot, and --print-to-pdf, improving control and automation.
Debugging
With the --remote-debugging-port flag, you can remotely debug Chrome instances running in Headless mode, which makes development and debugging much easier.
Usage Examples
Puppeteer
Using the new Headless mode is easy—just specify headless: 'new' when launching the browser:
Selenium-WebDriver
In Selenium, you can enable the new Headless mode by setting Chrome options:
Conclusion
This update not only simplifies automated testing but also improves the consistency and reliability of test results. The new mode gives developers more powerful tools and a more convenient way to debug.