How to fix empty HTML responses in Chrome headless mode when using BrowserMob Proxy?

I’m having trouble with BrowserMob Proxy in my UI automation tests. It works fine with regular Chrome, but I’m getting empty HTML responses in headless mode. Here’s what I’ve tried:

  • Set up proxy settings for both regular and headless Chrome
  • Added various Chrome options like --allow-insecure-localhost and --ignore-certificate-errors
  • Used dynamic ports for BrowserMob Proxy
  • Applied implicit waits and even added static sleep

Still, I only get a blank page with this HTML:

<html><head></head><body></body></html>

I’m using BrowserMob Proxy 2.1.5 and ChromeDriver 92.0.4515.159 on a remote Linux system. I’ve also tried tweaking proxy bypass lists and SSL settings, but no luck.

Any ideas on how to get BrowserMob Proxy working with Chrome headless? I’m really stuck and could use some help. Thanks!

hey, have u tried clearing browser cache and cookies? sometimes that can help with weird proxy issues. also, make sure ur using the latest chromedriver version that matches ur chrome. if nothing else works, maybe try a different proxy tool like mitmproxy? it might handle headless mode better.

Have you tried updating your BrowserMob Proxy and ChromeDriver versions? Sometimes compatibility issues can cause these problems. I had a similar issue and found that using the latest stable versions of both tools resolved it.

Another thing to check is your network configuration. Make sure your firewall or antivirus isn’t interfering with the proxy connection in headless mode. I once spent hours debugging only to find out my firewall was the culprit.

If those don’t work, you might want to try using a different proxy solution temporarily, like Selenium Wire, to see if the issue is specific to BrowserMob. This can help narrow down whether it’s a proxy problem or something else in your setup.

Lastly, double-check that your test environment variables and paths are correctly set for headless mode. Sometimes these can differ from regular browser mode and cause unexpected behavior.

I’ve encountered similar issues with BrowserMob Proxy and Chrome headless. One thing that worked for me was adjusting the proxy configuration to handle SSL properly. Make sure your proxy is set up to intercept HTTPS traffic correctly. You might need to generate and install custom SSL certificates.

Another approach that helped was tweaking the Chrome options. Try adding ‘–no-sandbox’ and ‘–disable-setuid-sandbox’ to your existing options. These can sometimes resolve issues with headless mode on Linux systems.

If you’re still getting blank pages, it might be worth checking your test’s timing. Headless browsers can sometimes load content differently. Try implementing a custom wait condition that checks for specific elements on the page rather than relying solely on implicit waits.

Lastly, if all else fails, consider using a tool like mitmproxy instead of BrowserMob. It’s more actively maintained and might handle headless Chrome better. Just remember to update your test scripts accordingly if you switch proxies.