Skip to content

Commit

Permalink
Use --headless=new or --headless=chrome if supported
Browse files Browse the repository at this point in the history
  • Loading branch information
Vangelis Banos committed Apr 15, 2024
1 parent 376f313 commit 1c0c385
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 1c0c385

Please sign in to comment.