Skip to content

Commit

Permalink
Merge pull request #2614 from seleniumbase/fix-issue-with-chrome-for-…
Browse files Browse the repository at this point in the history
…testing

Fix issue with getting browser version from Chrome-for-Testing on Windows
  • Loading branch information
mdmintz authored Mar 16, 2024
2 parents f2b3aee + 2e616ad commit 36cfb20
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 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.24.9"
__version__ = "4.24.10"
24 changes: 13 additions & 11 deletions seleniumbase/core/detect_b_ver.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,25 +232,27 @@ def get_binary_location(browser_type, prefer_chromium=False):
def get_browser_version_from_binary(binary_location):
try:
path = binary_location
if binary_location.count(r"\ ") != binary_location.count(" "):
binary_location = binary_location.replace(" ", r"\ ")
cmd_mapping = binary_location + " --version"
pattern = r"\d+\.\d+\.\d+"
quad_pattern = r"\d+\.\d+\.\d+\.\d+"
quad_version = read_version_from_cmd(cmd_mapping, quad_pattern)
if quad_version and len(str(quad_version)) >= 9: # Eg. 115.0.0.0
return quad_version
version = read_version_from_cmd(cmd_mapping, pattern)
if not version and os_name() == OSType.WIN and os.path.exists(path):
if os_name() == OSType.WIN and os.path.exists(path):
path = path.replace(r"\ ", r" ").replace("\\", "\\\\")
cmd_mapping = (
'''powershell -command "&{(Get-Item '%s')'''
'''.VersionInfo.ProductVersion}"''' % path
'''powershell -command "&{(Get-Command '%s')'''
'''.Version.ToString()}"''' % path
)
quad_version = read_version_from_cmd(cmd_mapping, quad_pattern)
if quad_version and len(str(quad_version)) >= 9:
if quad_version and len(str(quad_version)) >= 9: # Eg. 122.0.0.0
return quad_version
version = read_version_from_cmd(cmd_mapping, pattern)
if version and len(str(version)) >= 7: # Eg. 122.0.0
return version
if binary_location.count(r"\ ") != binary_location.count(" "):
binary_location = binary_location.replace(" ", r"\ ")
cmd_mapping = binary_location + " --version"
quad_version = read_version_from_cmd(cmd_mapping, quad_pattern)
if quad_version and len(str(quad_version)) >= 9:
return quad_version
version = read_version_from_cmd(cmd_mapping, pattern)
return version
except Exception:
return None
Expand Down

0 comments on commit 36cfb20

Please sign in to comment.