Skip to content

Commit

Permalink
Merge pull request #2611 from seleniumbase/fix-binary-location-option…
Browse files Browse the repository at this point in the history
…-on-windows

Fix the `binary_location` option on Windows
  • Loading branch information
mdmintz authored Mar 16, 2024
2 parents 1903536 + 4ecee76 commit f2b3aee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
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.8"
__version__ = "4.24.9"
11 changes: 11 additions & 0 deletions seleniumbase/core/detect_b_ver.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ 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"
Expand All @@ -240,6 +241,16 @@ def get_browser_version_from_binary(binary_location):
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):
path = path.replace(r"\ ", r" ").replace("\\", "\\\\")
cmd_mapping = (
'''powershell -command "&{(Get-Item '%s')'''
'''.VersionInfo.ProductVersion}"''' % path
)
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 f2b3aee

Please sign in to comment.