Skip to content

Commit b640370

Browse files
Handle custom desired browser capabilities that are passed in as string:string. This is the pattern for passing extra capabilities specific to a vendor. See https://www.w3.org/TR/webdriver1/#dfn-extension-capability
1 parent c6b9d29 commit b640370

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

seleniumbase/core/browser_launcher.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,6 +1068,7 @@ def get_remote_driver(
10681068
screen_resolution = None
10691069
browser_version = None
10701070
platform_name = None
1071+
custom_caps = {}
10711072
for key in desired_caps.keys():
10721073
capabilities[key] = desired_caps[key]
10731074
if key == "selenoid:options":
@@ -1079,6 +1080,8 @@ def get_remote_driver(
10791080
browser_version = desired_caps[key]
10801081
elif key == "platform" or key == "platformName":
10811082
platform_name = desired_caps[key]
1083+
elif re.match("[a-zA-Z0-9]*:[a-zA-Z0-9]*", key):
1084+
custom_caps[key] = desired_caps[key]
10821085
if selenium4:
10831086
chrome_options.set_capability("cloud:options", capabilities)
10841087
if selenoid:
@@ -1093,6 +1096,9 @@ def get_remote_driver(
10931096
if platform_name:
10941097
plat_name = platform_name
10951098
chrome_options.set_capability("platformName", plat_name)
1099+
if custom_caps:
1100+
for key in custom_caps:
1101+
chrome_options.set_capability(key, custom_caps[key])
10961102
return webdriver.Remote(
10971103
command_executor=address,
10981104
options=chrome_options,
@@ -1133,6 +1139,7 @@ def get_remote_driver(
11331139
screen_resolution = None
11341140
browser_version = None
11351141
platform_name = None
1142+
custom_caps = {}
11361143
for key in desired_caps.keys():
11371144
capabilities[key] = desired_caps[key]
11381145
if key == "selenoid:options":
@@ -1144,6 +1151,8 @@ def get_remote_driver(
11441151
browser_version = desired_caps[key]
11451152
elif key == "platform" or key == "platformName":
11461153
platform_name = desired_caps[key]
1154+
elif re.match("[a-zA-Z0-9]*:[a-zA-Z0-9]*", key):
1155+
custom_caps[key] = desired_caps[key]
11471156
if selenium4:
11481157
firefox_options.set_capability("cloud:options", capabilities)
11491158
if selenoid:
@@ -1158,6 +1167,9 @@ def get_remote_driver(
11581167
if platform_name:
11591168
plat_name = platform_name
11601169
firefox_options.set_capability("platformName", plat_name)
1170+
if custom_caps:
1171+
for key in custom_caps:
1172+
firefox_options.set_capability(key, custom_caps[key])
11611173
return webdriver.Remote(
11621174
command_executor=address,
11631175
options=firefox_options,
@@ -1278,6 +1290,7 @@ def get_remote_driver(
12781290
screen_resolution = None
12791291
browser_version = None
12801292
platform_name = None
1293+
custom_caps = {}
12811294
for key in desired_caps.keys():
12821295
capabilities[key] = desired_caps[key]
12831296
if key == "selenoid:options":
@@ -1289,6 +1302,8 @@ def get_remote_driver(
12891302
browser_version = desired_caps[key]
12901303
elif key == "platform" or key == "platformName":
12911304
platform_name = desired_caps[key]
1305+
elif re.match("[a-zA-Z0-9]*:[a-zA-Z0-9]*", key):
1306+
custom_caps[key] = desired_caps[key]
12921307
if selenium4:
12931308
opera_options.set_capability("cloud:options", capabilities)
12941309
if selenoid:
@@ -1303,6 +1318,9 @@ def get_remote_driver(
13031318
if platform_name:
13041319
plat_name = platform_name
13051320
opera_options.set_capability("platformName", plat_name)
1321+
if custom_caps:
1322+
for key in custom_caps:
1323+
opera_options.set_capability(key, custom_caps[key])
13061324
return webdriver.Remote(
13071325
command_executor=address,
13081326
options=opera_options,

0 commit comments

Comments
 (0)