Skip to content

Commit

Permalink
Merge pull request #274 from vbanos/headless-new
Browse files Browse the repository at this point in the history
Use --headless=new or --headless=chrome if supported
  • Loading branch information
galgeek authored Jul 18, 2024
2 parents 8d7507f + 7d58042 commit 008b71e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion brozzler/chrome.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def check_version(chrome_exe):
"brozzler requires chrome/chromium version 64 or "
"later but %s reports version %s" % (chrome_exe, version_str)
)
return major_version


class Chrome:
Expand Down Expand Up @@ -182,7 +183,6 @@ def start(
chrome_args = [
self.chrome_exe,
"-v",
"--headless",
"--remote-debugging-port=%s" % self.port,
"--use-mock-keychain", # mac thing
"--user-data-dir=%s" % self._chrome_user_data_dir,
Expand All @@ -205,6 +205,13 @@ def start(
"--disable-save-password-bubble",
"--disable-sync",
]
major_version = check_version(self.chrome_exe)
if major_version >= 109:
chrome_args.append("--headless=new")
elif 96 <= major_version <= 108:
chrome_args.append("--headless=chrome")
else:
chrome_args.append("--headless")

extra_chrome_args = os.environ.get("BROZZLER_EXTRA_CHROME_ARGS")
if extra_chrome_args:
Expand Down

0 comments on commit 008b71e

Please sign in to comment.