Skip to content

Commit c522c23

Browse files
committed
Fix the "binary_location" option on Windows
1 parent 1903536 commit c522c23

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

seleniumbase/core/detect_b_ver.py

Lines changed: 11 additions & 0 deletions
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)