17
17
from seleniumbase import extensions # browser extensions storage folder
18
18
19
19
urllib3 .disable_warnings ()
20
- selenium4 = False
20
+ selenium4_or_newer = False
21
21
if sys .version_info [0 ] == 3 and sys .version_info [1 ] >= 7 :
22
- selenium4 = True
22
+ selenium4_or_newer = True
23
23
from selenium .webdriver .common .options import ArgOptions
24
24
25
25
DRIVER_DIR = os .path .dirname (os .path .realpath (drivers .__file__ ))
@@ -130,7 +130,7 @@ def _repair_chromedriver(chrome_options, headless_options, mcv=None):
130
130
"sbase install chromedriver 72.0.3626.69" , shell = True
131
131
)
132
132
try :
133
- if selenium4 :
133
+ if selenium4_or_newer :
134
134
service = ChromeService (executable_path = LOCAL_CHROMEDRIVER )
135
135
driver = webdriver .Chrome (
136
136
service = service ,
@@ -1058,7 +1058,7 @@ def get_remote_driver(
1058
1058
device_pixel_ratio ,
1059
1059
)
1060
1060
capabilities = None
1061
- if selenium4 :
1061
+ if selenium4_or_newer :
1062
1062
capabilities = webdriver .ChromeOptions ().to_capabilities ()
1063
1063
else :
1064
1064
capabilities = chrome_options .to_capabilities ()
@@ -1082,7 +1082,7 @@ def get_remote_driver(
1082
1082
platform_name = desired_caps [key ]
1083
1083
elif re .match ("[a-zA-Z0-9]*:[a-zA-Z0-9]*" , key ):
1084
1084
extension_capabilities [key ] = desired_caps [key ]
1085
- if selenium4 :
1085
+ if selenium4_or_newer :
1086
1086
chrome_options .set_capability ("cloud:options" , capabilities )
1087
1087
if selenoid :
1088
1088
snops = selenoid_options
@@ -1126,7 +1126,7 @@ def get_remote_driver(
1126
1126
firefox_pref ,
1127
1127
)
1128
1128
capabilities = None
1129
- if selenium4 :
1129
+ if selenium4_or_newer :
1130
1130
capabilities = webdriver .FirefoxOptions ().to_capabilities ()
1131
1131
else :
1132
1132
capabilities = firefox_options .to_capabilities ()
@@ -1154,7 +1154,7 @@ def get_remote_driver(
1154
1154
platform_name = desired_caps [key ]
1155
1155
elif re .match ("[a-zA-Z0-9]*:[a-zA-Z0-9]*" , key ):
1156
1156
extension_capabilities [key ] = desired_caps [key ]
1157
- if selenium4 :
1157
+ if selenium4_or_newer :
1158
1158
firefox_options .set_capability ("cloud:options" , capabilities )
1159
1159
if selenoid :
1160
1160
snops = selenoid_options
@@ -1186,7 +1186,7 @@ def get_remote_driver(
1186
1186
)
1187
1187
elif browser_name == constants .Browser .INTERNET_EXPLORER :
1188
1188
capabilities = webdriver .DesiredCapabilities .INTERNETEXPLORER
1189
- if selenium4 :
1189
+ if selenium4_or_newer :
1190
1190
remote_options = ArgOptions ()
1191
1191
remote_options .set_capability ("cloud:options" , desired_caps )
1192
1192
return webdriver .Remote (
@@ -1205,7 +1205,7 @@ def get_remote_driver(
1205
1205
)
1206
1206
elif browser_name == constants .Browser .EDGE :
1207
1207
capabilities = webdriver .DesiredCapabilities .EDGE
1208
- if selenium4 :
1208
+ if selenium4_or_newer :
1209
1209
remote_options = ArgOptions ()
1210
1210
remote_options .set_capability ("cloud:options" , desired_caps )
1211
1211
return webdriver .Remote (
@@ -1224,7 +1224,7 @@ def get_remote_driver(
1224
1224
)
1225
1225
elif browser_name == constants .Browser .SAFARI :
1226
1226
capabilities = webdriver .DesiredCapabilities .SAFARI
1227
- if selenium4 :
1227
+ if selenium4_or_newer :
1228
1228
remote_options = ArgOptions ()
1229
1229
remote_options .set_capability ("cloud:options" , desired_caps )
1230
1230
return webdriver .Remote (
@@ -1281,7 +1281,7 @@ def get_remote_driver(
1281
1281
device_pixel_ratio ,
1282
1282
)
1283
1283
capabilities = None
1284
- if selenium4 :
1284
+ if selenium4_or_newer :
1285
1285
capabilities = webdriver .DesiredCapabilities .OPERA
1286
1286
else :
1287
1287
opera_options = webdriver .opera .options .Options ()
@@ -1306,7 +1306,7 @@ def get_remote_driver(
1306
1306
platform_name = desired_caps [key ]
1307
1307
elif re .match ("[a-zA-Z0-9]*:[a-zA-Z0-9]*" , key ):
1308
1308
extension_capabilities [key ] = desired_caps [key ]
1309
- if selenium4 :
1309
+ if selenium4_or_newer :
1310
1310
opera_options .set_capability ("cloud:options" , capabilities )
1311
1311
if selenoid :
1312
1312
snops = selenoid_options
@@ -1337,7 +1337,7 @@ def get_remote_driver(
1337
1337
keep_alive = True ,
1338
1338
)
1339
1339
elif browser_name == constants .Browser .PHANTOM_JS :
1340
- if selenium4 :
1340
+ if selenium4_or_newer :
1341
1341
message = (
1342
1342
"\n "
1343
1343
"PhantomJS is no longer available for Selenium 4!\n "
@@ -1357,7 +1357,7 @@ def get_remote_driver(
1357
1357
)
1358
1358
elif browser_name == constants .Browser .ANDROID :
1359
1359
capabilities = webdriver .DesiredCapabilities .ANDROID
1360
- if selenium4 :
1360
+ if selenium4_or_newer :
1361
1361
remote_options = ArgOptions ()
1362
1362
remote_options .set_capability ("cloud:options" , desired_caps )
1363
1363
return webdriver .Remote (
@@ -1376,7 +1376,7 @@ def get_remote_driver(
1376
1376
)
1377
1377
elif browser_name == constants .Browser .IPHONE :
1378
1378
capabilities = webdriver .DesiredCapabilities .IPHONE
1379
- if selenium4 :
1379
+ if selenium4_or_newer :
1380
1380
remote_options = ArgOptions ()
1381
1381
remote_options .set_capability ("cloud:options" , desired_caps )
1382
1382
return webdriver .Remote (
@@ -1395,7 +1395,7 @@ def get_remote_driver(
1395
1395
)
1396
1396
elif browser_name == constants .Browser .IPAD :
1397
1397
capabilities = webdriver .DesiredCapabilities .IPAD
1398
- if selenium4 :
1398
+ if selenium4_or_newer :
1399
1399
remote_options = ArgOptions ()
1400
1400
remote_options .set_capability ("cloud:options" , desired_caps )
1401
1401
return webdriver .Remote (
@@ -1413,7 +1413,7 @@ def get_remote_driver(
1413
1413
keep_alive = True ,
1414
1414
)
1415
1415
elif browser_name == constants .Browser .REMOTE :
1416
- if selenium4 :
1416
+ if selenium4_or_newer :
1417
1417
remote_options = ArgOptions ()
1418
1418
# shovel caps into remote options.
1419
1419
for cap_name , cap_value in desired_caps .items ():
@@ -1528,7 +1528,7 @@ def get_local_driver(
1528
1528
sys .argv = sys_args # Put back original sys args
1529
1529
# Launch Firefox
1530
1530
if os .path .exists (LOCAL_GECKODRIVER ):
1531
- if selenium4 :
1531
+ if selenium4_or_newer :
1532
1532
service = FirefoxService (
1533
1533
executable_path = LOCAL_GECKODRIVER ,
1534
1534
log_path = os .devnull ,
@@ -1568,7 +1568,7 @@ def get_local_driver(
1568
1568
options = firefox_options ,
1569
1569
)
1570
1570
else :
1571
- if selenium4 :
1571
+ if selenium4_or_newer :
1572
1572
service = FirefoxService (log_path = os .devnull )
1573
1573
try :
1574
1574
return webdriver .Firefox (
@@ -1715,7 +1715,7 @@ def get_local_driver(
1715
1715
sys .argv = sys_args # Put back original sys args
1716
1716
1717
1717
# For Microsoft Edge (Chromium) version 80 or higher
1718
- if selenium4 :
1718
+ if selenium4_or_newer :
1719
1719
Edge = webdriver .edge .webdriver .WebDriver
1720
1720
EdgeOptions = webdriver .edge .webdriver .Options
1721
1721
else :
@@ -1863,7 +1863,7 @@ def get_local_driver(
1863
1863
chromium_arg_item = "--" + chromium_arg_item
1864
1864
if len (chromium_arg_item ) >= 3 :
1865
1865
edge_options .add_argument (chromium_arg_item )
1866
- if selenium4 :
1866
+ if selenium4_or_newer :
1867
1867
try :
1868
1868
service = EdgeService (
1869
1869
executable_path = LOCAL_EDGEDRIVER , log_path = os .devnull
@@ -2038,7 +2038,7 @@ def get_local_driver(
2038
2038
except Exception :
2039
2039
return webdriver .Opera ()
2040
2040
elif browser_name == constants .Browser .PHANTOM_JS :
2041
- if selenium4 :
2041
+ if selenium4_or_newer :
2042
2042
message = (
2043
2043
"\n "
2044
2044
"PhantomJS is no longer available for Selenium 4!\n "
@@ -2125,7 +2125,7 @@ def get_local_driver(
2125
2125
if not headless or "linux" not in PLATFORM :
2126
2126
try :
2127
2127
if os .path .exists (LOCAL_CHROMEDRIVER ):
2128
- if selenium4 :
2128
+ if selenium4_or_newer :
2129
2129
service = ChromeService (
2130
2130
executable_path = LOCAL_CHROMEDRIVER ,
2131
2131
log_path = os .devnull ,
@@ -2141,7 +2141,7 @@ def get_local_driver(
2141
2141
options = chrome_options ,
2142
2142
)
2143
2143
else :
2144
- if selenium4 :
2144
+ if selenium4_or_newer :
2145
2145
service = ChromeService (log_path = os .devnull )
2146
2146
driver = webdriver .Chrome (
2147
2147
service = service , options = chrome_options
@@ -2230,7 +2230,7 @@ def get_local_driver(
2230
2230
)
2231
2231
_mark_driver_repaired ()
2232
2232
if os .path .exists (LOCAL_CHROMEDRIVER ):
2233
- if selenium4 :
2233
+ if selenium4_or_newer :
2234
2234
service = ChromeService (
2235
2235
executable_path = LOCAL_CHROMEDRIVER
2236
2236
)
0 commit comments