@@ -281,6 +281,8 @@ def _set_chrome_options(
281
281
device_pixel_ratio ,
282
282
):
283
283
chrome_options = webdriver .ChromeOptions ()
284
+ if browser_name == constants .Browser .OPERA :
285
+ chrome_options = webdriver .opera .options .Options ()
284
286
prefs = {
285
287
"download.default_directory" : downloads_path ,
286
288
"local_discovery.notifications_enabled" : False ,
@@ -1058,6 +1060,7 @@ def get_remote_driver(
1058
1060
selenoid = False
1059
1061
selenoid_options = None
1060
1062
screen_resolution = None
1063
+ browser_version = None
1061
1064
platform_name = None
1062
1065
for key in desired_caps .keys ():
1063
1066
capabilities [key ] = desired_caps [key ]
@@ -1066,6 +1069,8 @@ def get_remote_driver(
1066
1069
selenoid_options = desired_caps [key ]
1067
1070
elif key == "screenResolution" :
1068
1071
screen_resolution = desired_caps [key ]
1072
+ elif key == "version" or key == "browserVersion" :
1073
+ browser_version = desired_caps [key ]
1069
1074
elif key == "platform" or key == "platformName" :
1070
1075
platform_name = desired_caps [key ]
1071
1076
if selenium4 :
@@ -1076,6 +1081,9 @@ def get_remote_driver(
1076
1081
if screen_resolution :
1077
1082
scres = screen_resolution
1078
1083
firefox_options .set_capability ("screenResolution" , scres )
1084
+ if browser_version :
1085
+ br_vers = browser_version
1086
+ firefox_options .set_capability ("browserVersion" , br_vers )
1079
1087
if platform_name :
1080
1088
plat_name = platform_name
1081
1089
firefox_options .set_capability ("platformName" , plat_name )
@@ -1149,19 +1157,86 @@ def get_remote_driver(
1149
1157
keep_alive = True ,
1150
1158
)
1151
1159
elif browser_name == constants .Browser .OPERA :
1152
- capabilities = webdriver .DesiredCapabilities .OPERA
1160
+ opera_options = _set_chrome_options (
1161
+ browser_name ,
1162
+ downloads_path ,
1163
+ headless ,
1164
+ locale_code ,
1165
+ proxy_string ,
1166
+ proxy_auth ,
1167
+ proxy_user ,
1168
+ proxy_pass ,
1169
+ proxy_bypass_list ,
1170
+ user_agent ,
1171
+ recorder_ext ,
1172
+ disable_csp ,
1173
+ enable_ws ,
1174
+ enable_sync ,
1175
+ use_auto_ext ,
1176
+ no_sandbox ,
1177
+ disable_gpu ,
1178
+ incognito ,
1179
+ guest_mode ,
1180
+ devtools ,
1181
+ remote_debug ,
1182
+ swiftshader ,
1183
+ ad_block_on ,
1184
+ block_images ,
1185
+ chromium_arg ,
1186
+ user_data_dir ,
1187
+ extension_zip ,
1188
+ extension_dir ,
1189
+ external_pdf ,
1190
+ servername ,
1191
+ mobile_emulator ,
1192
+ device_width ,
1193
+ device_height ,
1194
+ device_pixel_ratio ,
1195
+ )
1196
+ capabilities = None
1153
1197
if selenium4 :
1154
- remote_options = ArgOptions ()
1155
- remote_options .set_capability ("cloud:options" , desired_caps )
1198
+ capabilities = webdriver .DesiredCapabilities .OPERA
1199
+ else :
1200
+ opera_options = webdriver .opera .options .Options ()
1201
+ capabilities = opera_options .to_capabilities ()
1202
+ # Set custom desired capabilities
1203
+ selenoid = False
1204
+ selenoid_options = None
1205
+ screen_resolution = None
1206
+ browser_version = None
1207
+ platform_name = None
1208
+ for key in desired_caps .keys ():
1209
+ capabilities [key ] = desired_caps [key ]
1210
+ if key == "selenoid:options" :
1211
+ selenoid = True
1212
+ selenoid_options = desired_caps [key ]
1213
+ elif key == "screenResolution" :
1214
+ screen_resolution = desired_caps [key ]
1215
+ elif key == "version" or key == "browserVersion" :
1216
+ browser_version = desired_caps [key ]
1217
+ elif key == "platform" or key == "platformName" :
1218
+ platform_name = desired_caps [key ]
1219
+ if selenium4 :
1220
+ opera_options .set_capability ("cloud:options" , capabilities )
1221
+ if selenoid :
1222
+ snops = selenoid_options
1223
+ opera_options .set_capability ("selenoid:options" , snops )
1224
+ if screen_resolution :
1225
+ scres = screen_resolution
1226
+ opera_options .set_capability ("screenResolution" , scres )
1227
+ if browser_version :
1228
+ br_vers = browser_version
1229
+ opera_options .set_capability ("browserVersion" , br_vers )
1230
+ if platform_name :
1231
+ plat_name = platform_name
1232
+ opera_options .set_capability ("platformName" , plat_name )
1156
1233
return webdriver .Remote (
1157
1234
command_executor = address ,
1158
- options = remote_options ,
1235
+ options = opera_options ,
1159
1236
keep_alive = True ,
1160
1237
)
1161
1238
else :
1162
1239
warnings .simplefilter ("ignore" , category = DeprecationWarning )
1163
- for key in desired_caps .keys ():
1164
- capabilities [key ] = desired_caps [key ]
1165
1240
return webdriver .Remote (
1166
1241
command_executor = address ,
1167
1242
desired_capabilities = capabilities ,
@@ -1246,12 +1321,18 @@ def get_remote_driver(
1246
1321
selenoid = False
1247
1322
selenoid_options = None
1248
1323
screen_resolution = None
1324
+ browser_version = None
1325
+ platform_name = None
1249
1326
for key in desired_caps .keys ():
1250
1327
if key == "selenoid:options" :
1251
1328
selenoid = True
1252
1329
selenoid_options = desired_caps [key ]
1253
1330
elif key == "screenResolution" :
1254
1331
screen_resolution = desired_caps [key ]
1332
+ elif key == "version" or key == "browserVersion" :
1333
+ browser_version = desired_caps [key ]
1334
+ elif key == "platform" or key == "platformName" :
1335
+ platform_name = desired_caps [key ]
1255
1336
if selenium4 :
1256
1337
remote_options = ArgOptions ()
1257
1338
remote_options .set_capability ("cloud:options" , desired_caps )
@@ -1261,6 +1342,12 @@ def get_remote_driver(
1261
1342
if screen_resolution :
1262
1343
scres = screen_resolution
1263
1344
remote_options .set_capability ("screenResolution" , scres )
1345
+ if browser_version :
1346
+ br_vers = browser_version
1347
+ firefox_options .set_capability ("browserVersion" , br_vers )
1348
+ if platform_name :
1349
+ plat_name = platform_name
1350
+ firefox_options .set_capability ("platformName" , plat_name )
1264
1351
return webdriver .Remote (
1265
1352
command_executor = address ,
1266
1353
options = remote_options ,
0 commit comments