Skip to content

Commit

Permalink
Merge pull request #2524 from seleniumbase/fix-ua-string-in-headless-…
Browse files Browse the repository at this point in the history
…uc-mode

Fix user-agent string in headless UC Mode
  • Loading branch information
mdmintz authored Feb 20, 2024
2 parents 6b1c993 + 0fb3367 commit b2ec928
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion seleniumbase/__version__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# seleniumbase package
__version__ = "4.23.6"
__version__ = "4.23.7"
16 changes: 15 additions & 1 deletion seleniumbase/core/browser_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -3460,7 +3460,21 @@ def get_local_driver(
try:
user_agent = driver.execute_script(
"return navigator.userAgent;"
).replace("Headless", "")
)
if (
major_chrome_version
and full_ch_version
and full_ch_version.count(".") == 3
and full_ch_version in user_agent
):
mcv = major_chrome_version
user_agent = user_agent.replace(
"Chrome/%s" % full_ch_version,
"Chrome/%s.0.0.0" % mcv
)
user_agent = user_agent.replace(
"Headless", ""
)
chrome_options.add_argument(
"--user-agent=%s" % user_agent
)
Expand Down

0 comments on commit b2ec928

Please sign in to comment.