Skip to content

Commit f2b3aee

Browse files
authored
Merge pull request #2611 from seleniumbase/fix-binary-location-option-on-windows
Fix the `binary_location` option on Windows
2 parents 1903536 + 4ecee76 commit f2b3aee

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

seleniumbase/__version__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# seleniumbase package
2-
__version__ = "4.24.8"
2+
__version__ = "4.24.9"

seleniumbase/core/detect_b_ver.py

+11
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ def get_binary_location(browser_type, prefer_chromium=False):
231231

232232
def get_browser_version_from_binary(binary_location):
233233
try:
234+
path = binary_location
234235
if binary_location.count(r"\ ") != binary_location.count(" "):
235236
binary_location = binary_location.replace(" ", r"\ ")
236237
cmd_mapping = binary_location + " --version"
@@ -240,6 +241,16 @@ def get_browser_version_from_binary(binary_location):
240241
if quad_version and len(str(quad_version)) >= 9: # Eg. 115.0.0.0
241242
return quad_version
242243
version = read_version_from_cmd(cmd_mapping, pattern)
244+
if not version and os_name() == OSType.WIN and os.path.exists(path):
245+
path = path.replace(r"\ ", r" ").replace("\\", "\\\\")
246+
cmd_mapping = (
247+
'''powershell -command "&{(Get-Item '%s')'''
248+
'''.VersionInfo.ProductVersion}"''' % path
249+
)
250+
quad_version = read_version_from_cmd(cmd_mapping, quad_pattern)
251+
if quad_version and len(str(quad_version)) >= 9:
252+
return quad_version
253+
version = read_version_from_cmd(cmd_mapping, pattern)
243254
return version
244255
except Exception:
245256
return None

0 commit comments

Comments
 (0)