seleniumbase 4.39.6a2__py3-none-any.whl → 4.40.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- seleniumbase/__version__.py +1 -1
- seleniumbase/behave/behave_sb.py +16 -0
- seleniumbase/console_scripts/sb_install.py +15 -0
- seleniumbase/core/browser_launcher.py +161 -61
- seleniumbase/core/log_helper.py +5 -1
- seleniumbase/core/sb_cdp.py +144 -0
- seleniumbase/drivers/cft_drivers/__init__.py +0 -0
- seleniumbase/drivers/chs_drivers/__init__.py +0 -0
- seleniumbase/fixtures/base_case.py +166 -4
- seleniumbase/fixtures/page_actions.py +149 -0
- seleniumbase/plugins/pytest_plugin.py +2 -0
- seleniumbase/plugins/selenium_plugin.py +3 -0
- {seleniumbase-4.39.6a2.dist-info → seleniumbase-4.40.0.dist-info}/METADATA +6 -6
- {seleniumbase-4.39.6a2.dist-info → seleniumbase-4.40.0.dist-info}/RECORD +18 -16
- {seleniumbase-4.39.6a2.dist-info → seleniumbase-4.40.0.dist-info}/WHEEL +0 -0
- {seleniumbase-4.39.6a2.dist-info → seleniumbase-4.40.0.dist-info}/entry_points.txt +0 -0
- {seleniumbase-4.39.6a2.dist-info → seleniumbase-4.40.0.dist-info}/licenses/LICENSE +0 -0
- {seleniumbase-4.39.6a2.dist-info → seleniumbase-4.40.0.dist-info}/top_level.txt +0 -0
seleniumbase/__version__.py
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
# seleniumbase package
|
2
|
-
__version__ = "4.
|
2
|
+
__version__ = "4.40.0"
|
seleniumbase/behave/behave_sb.py
CHANGED
@@ -11,6 +11,8 @@ behave -D agent="User Agent String" -D demo
|
|
11
11
|
-D edge (Shortcut for "-D browser=edge".)
|
12
12
|
-D firefox (Shortcut for "-D browser=firefox".)
|
13
13
|
-D safari (Shortcut for "-D browser=safari".)
|
14
|
+
-D cft (Shortcut for using `Chrome for Testing`)
|
15
|
+
-D chs (Shortcut for using `Chrome-Headless-Shell`)
|
14
16
|
-D settings-file=FILE (Override default SeleniumBase settings.)
|
15
17
|
-D env=ENV (Set the test env. Access with "self.env" in tests.)
|
16
18
|
-D account=STR (Set account. Access with "self.account" in tests.)
|
@@ -176,6 +178,7 @@ def get_configured_sb(context):
|
|
176
178
|
sb.extension_zip = None
|
177
179
|
sb.extension_dir = None
|
178
180
|
sb.binary_location = None
|
181
|
+
sb_config.binary_location = None
|
179
182
|
sb.driver_version = None
|
180
183
|
sb.page_load_strategy = None
|
181
184
|
sb.database_env = "test"
|
@@ -488,6 +491,19 @@ def get_configured_sb(context):
|
|
488
491
|
if binary_location == "true":
|
489
492
|
binary_location = sb.binary_location # revert to default
|
490
493
|
sb.binary_location = binary_location
|
494
|
+
sb_config.binary_location = binary_location
|
495
|
+
continue
|
496
|
+
# Handle: -D cft
|
497
|
+
if low_key in ["cft"] and not sb_config.binary_location:
|
498
|
+
binary_location = "cft"
|
499
|
+
sb.binary_location = binary_location
|
500
|
+
sb_config.binary_location = binary_location
|
501
|
+
continue
|
502
|
+
# Handle: -D chs
|
503
|
+
if low_key in ["chs"] and not sb_config.binary_location:
|
504
|
+
binary_location = "chs"
|
505
|
+
sb.binary_location = binary_location
|
506
|
+
sb_config.binary_location = binary_location
|
491
507
|
continue
|
492
508
|
# Handle: -D driver-version=VER / driver_version=VER
|
493
509
|
if low_key in ["driver-version", "driver_version"]:
|
@@ -44,6 +44,8 @@ from seleniumbase.fixtures import constants
|
|
44
44
|
from seleniumbase.fixtures import shared_utils
|
45
45
|
from seleniumbase import config as sb_config
|
46
46
|
from seleniumbase import drivers # webdriver storage folder for SeleniumBase
|
47
|
+
from seleniumbase.drivers import cft_drivers # chrome-for-testing
|
48
|
+
from seleniumbase.drivers import chs_drivers # chrome-headless-shell
|
47
49
|
|
48
50
|
urllib3.disable_warnings()
|
49
51
|
ARCH = platform.architecture()[0]
|
@@ -52,6 +54,8 @@ IS_MAC = shared_utils.is_mac()
|
|
52
54
|
IS_LINUX = shared_utils.is_linux()
|
53
55
|
IS_WINDOWS = shared_utils.is_windows()
|
54
56
|
DRIVER_DIR = os.path.dirname(os.path.realpath(drivers.__file__))
|
57
|
+
DRIVER_DIR_CFT = os.path.dirname(os.path.realpath(cft_drivers.__file__))
|
58
|
+
DRIVER_DIR_CHS = os.path.dirname(os.path.realpath(chs_drivers.__file__))
|
55
59
|
LOCAL_PATH = "/usr/local/bin/" # On Mac and Linux systems
|
56
60
|
DEFAULT_CHROMEDRIVER_VERSION = "114.0.5735.90" # (If can't find LATEST_STABLE)
|
57
61
|
DEFAULT_GECKODRIVER_VERSION = "v0.36.0"
|
@@ -305,6 +309,17 @@ def main(override=None, intel_for_uc=None, force_uc=None):
|
|
305
309
|
headless_ie_exists = False
|
306
310
|
headless_ie_file_name = None
|
307
311
|
downloads_folder = DRIVER_DIR
|
312
|
+
if (
|
313
|
+
hasattr(sb_config, "settings")
|
314
|
+
and hasattr(sb_config.settings, "NEW_DRIVER_DIR")
|
315
|
+
and sb_config.settings.NEW_DRIVER_DIR
|
316
|
+
and os.path.exists(sb_config.settings.NEW_DRIVER_DIR)
|
317
|
+
):
|
318
|
+
downloads_folder = sb_config.settings.NEW_DRIVER_DIR
|
319
|
+
elif override == "cft" or name == "cft":
|
320
|
+
downloads_folder = DRIVER_DIR_CFT
|
321
|
+
elif override == "chs" or name == "chs":
|
322
|
+
downloads_folder = DRIVER_DIR_CHS
|
308
323
|
expected_contents = None
|
309
324
|
platform_code = None
|
310
325
|
copy_to_path = False
|
@@ -25,6 +25,8 @@ from selenium.webdriver.safari.service import Service as SafariService
|
|
25
25
|
from seleniumbase import config as sb_config
|
26
26
|
from seleniumbase import decorators
|
27
27
|
from seleniumbase import drivers # webdriver storage folder for SeleniumBase
|
28
|
+
from seleniumbase.drivers import cft_drivers # chrome-for-testing
|
29
|
+
from seleniumbase.drivers import chs_drivers # chrome-headless-shell
|
28
30
|
from seleniumbase import extensions # browser extensions storage folder
|
29
31
|
from seleniumbase.config import settings
|
30
32
|
from seleniumbase.core import detect_b_ver
|
@@ -39,6 +41,8 @@ from seleniumbase.fixtures import shared_utils
|
|
39
41
|
|
40
42
|
urllib3.disable_warnings()
|
41
43
|
DRIVER_DIR = os.path.dirname(os.path.realpath(drivers.__file__))
|
44
|
+
DRIVER_DIR_CFT = os.path.dirname(os.path.realpath(cft_drivers.__file__))
|
45
|
+
DRIVER_DIR_CHS = os.path.dirname(os.path.realpath(chs_drivers.__file__))
|
42
46
|
# Make sure that the SeleniumBase DRIVER_DIR is at the top of the System PATH
|
43
47
|
# (Changes to the System PATH with os.environ only last during the test run)
|
44
48
|
if not os.environ["PATH"].startswith(DRIVER_DIR):
|
@@ -100,6 +104,38 @@ def log_d(message):
|
|
100
104
|
print(message)
|
101
105
|
|
102
106
|
|
107
|
+
def override_driver_dir(driver_dir):
|
108
|
+
if (
|
109
|
+
driver_dir
|
110
|
+
and isinstance(driver_dir, str)
|
111
|
+
and os.path.exists(driver_dir)
|
112
|
+
):
|
113
|
+
driver_dir = os.path.realpath(driver_dir)
|
114
|
+
sb_config.settings.NEW_DRIVER_DIR = driver_dir
|
115
|
+
if (
|
116
|
+
not os.environ["PATH"].startswith(driver_dir)
|
117
|
+
and len(driver_dir) >= 4
|
118
|
+
):
|
119
|
+
os.environ["PATH"] = os.environ["PATH"].replace(driver_dir, "")
|
120
|
+
os.environ["PATH"] = os.environ["PATH"].replace(
|
121
|
+
os.pathsep + os.pathsep, os.pathsep
|
122
|
+
)
|
123
|
+
os.environ["PATH"] = driver_dir + os.pathsep + os.environ["PATH"]
|
124
|
+
elif (
|
125
|
+
not driver_dir
|
126
|
+
or not isinstance(driver_dir, str)
|
127
|
+
or not os.path.exists(driver_dir)
|
128
|
+
):
|
129
|
+
bad_dir = ""
|
130
|
+
if driver_dir and isinstance(driver_dir, str):
|
131
|
+
bad_dir = os.path.realpath(driver_dir)
|
132
|
+
log_d(
|
133
|
+
"\n* Warning: Cannot set driver_dir to nonexistent directory:\n%s"
|
134
|
+
"\n* Will use the default folder instead:\n%s)"
|
135
|
+
% (bad_dir, DRIVER_DIR)
|
136
|
+
)
|
137
|
+
|
138
|
+
|
103
139
|
def make_driver_executable_if_not(driver_path):
|
104
140
|
# Verify driver has executable permissions. If not, add them.
|
105
141
|
permissions = oct(os.stat(driver_path)[0])[-3:]
|
@@ -301,12 +337,14 @@ def chromedriver_on_path():
|
|
301
337
|
return None
|
302
338
|
|
303
339
|
|
304
|
-
def get_uc_driver_version(full=False):
|
340
|
+
def get_uc_driver_version(full=False, local_uc_driver=None):
|
341
|
+
if not local_uc_driver:
|
342
|
+
local_uc_driver = LOCAL_UC_DRIVER
|
305
343
|
uc_driver_version = None
|
306
|
-
if os.path.exists(
|
344
|
+
if os.path.exists(local_uc_driver):
|
307
345
|
with suppress(Exception):
|
308
346
|
output = subprocess.check_output(
|
309
|
-
'"%s" --version' %
|
347
|
+
'"%s" --version' % local_uc_driver, shell=True
|
310
348
|
)
|
311
349
|
if IS_WINDOWS:
|
312
350
|
output = output.decode("latin1")
|
@@ -543,11 +581,6 @@ def uc_open_with_cdp_mode(driver, url=None, **kwargs):
|
|
543
581
|
driver.connect()
|
544
582
|
current_url = driver.current_url
|
545
583
|
url_protocol = current_url.split(":")[0]
|
546
|
-
if url_protocol not in ["about", "data", "chrome"]:
|
547
|
-
script = 'window.open("data:,","_blank");'
|
548
|
-
js_utils.call_me_later(driver, script, 3)
|
549
|
-
time.sleep(0.012)
|
550
|
-
driver.close()
|
551
584
|
driver.disconnect()
|
552
585
|
|
553
586
|
cdp_details = driver._get_cdp_details()
|
@@ -792,6 +825,14 @@ def uc_open_with_cdp_mode(driver, url=None, **kwargs):
|
|
792
825
|
cdp.wait_for_element_visible = CDPM.wait_for_element_visible
|
793
826
|
cdp.wait_for_element_not_visible = CDPM.wait_for_element_not_visible
|
794
827
|
cdp.wait_for_element_absent = CDPM.wait_for_element_absent
|
828
|
+
cdp.wait_for_any_of_elements_visible = (
|
829
|
+
CDPM.wait_for_any_of_elements_visible
|
830
|
+
)
|
831
|
+
cdp.wait_for_any_of_elements_present = (
|
832
|
+
CDPM.wait_for_any_of_elements_present
|
833
|
+
)
|
834
|
+
cdp.assert_any_of_elements_visible = CDPM.assert_any_of_elements_visible
|
835
|
+
cdp.assert_any_of_elements_present = CDPM.assert_any_of_elements_present
|
795
836
|
cdp.assert_element = CDPM.assert_element
|
796
837
|
cdp.assert_element_visible = CDPM.assert_element_visible
|
797
838
|
cdp.assert_element_present = CDPM.assert_element_present
|
@@ -2838,6 +2879,24 @@ def get_driver(
|
|
2838
2879
|
device_pixel_ratio=None,
|
2839
2880
|
browser=None, # A duplicate of browser_name to avoid confusion
|
2840
2881
|
):
|
2882
|
+
driver_dir = DRIVER_DIR
|
2883
|
+
if (
|
2884
|
+
hasattr(sb_config, "binary_location")
|
2885
|
+
and sb_config.binary_location == "cft"
|
2886
|
+
):
|
2887
|
+
driver_dir = DRIVER_DIR_CFT
|
2888
|
+
if (
|
2889
|
+
hasattr(sb_config, "binary_location")
|
2890
|
+
and sb_config.binary_location == "chs"
|
2891
|
+
):
|
2892
|
+
driver_dir = DRIVER_DIR_CHS
|
2893
|
+
if (
|
2894
|
+
hasattr(sb_config, "settings")
|
2895
|
+
and hasattr(sb_config.settings, "NEW_DRIVER_DIR")
|
2896
|
+
and sb_config.settings.NEW_DRIVER_DIR
|
2897
|
+
and os.path.exists(sb_config.settings.NEW_DRIVER_DIR)
|
2898
|
+
):
|
2899
|
+
driver_dir = sb_config.settings.NEW_DRIVER_DIR
|
2841
2900
|
if not browser_name:
|
2842
2901
|
if browser:
|
2843
2902
|
browser_name = browser
|
@@ -2882,7 +2941,7 @@ def get_driver(
|
|
2882
2941
|
else:
|
2883
2942
|
binary_folder = "chrome-win32"
|
2884
2943
|
if binary_folder:
|
2885
|
-
binary_location = os.path.join(
|
2944
|
+
binary_location = os.path.join(driver_dir, binary_folder)
|
2886
2945
|
if not os.path.exists(binary_location):
|
2887
2946
|
from seleniumbase.console_scripts import sb_install
|
2888
2947
|
args = " ".join(sys.argv)
|
@@ -2936,7 +2995,7 @@ def get_driver(
|
|
2936
2995
|
else:
|
2937
2996
|
binary_folder = "chrome-headless-shell-win32"
|
2938
2997
|
if binary_folder:
|
2939
|
-
binary_location = os.path.join(
|
2998
|
+
binary_location = os.path.join(driver_dir, binary_folder)
|
2940
2999
|
if not os.path.exists(binary_location):
|
2941
3000
|
from seleniumbase.console_scripts import sb_install
|
2942
3001
|
args = " ".join(sys.argv)
|
@@ -3772,6 +3831,41 @@ def get_local_driver(
|
|
3772
3831
|
"""Spins up a new web browser and returns the driver.
|
3773
3832
|
Can also be used to spin up additional browsers for the same test."""
|
3774
3833
|
downloads_path = DOWNLOADS_FOLDER
|
3834
|
+
driver_dir = DRIVER_DIR
|
3835
|
+
special_chrome = False
|
3836
|
+
if (
|
3837
|
+
hasattr(sb_config, "binary_location")
|
3838
|
+
and sb_config.binary_location == "cft"
|
3839
|
+
):
|
3840
|
+
special_chrome = True
|
3841
|
+
driver_dir = DRIVER_DIR_CFT
|
3842
|
+
if (
|
3843
|
+
hasattr(sb_config, "binary_location")
|
3844
|
+
and sb_config.binary_location == "chs"
|
3845
|
+
):
|
3846
|
+
special_chrome = True
|
3847
|
+
driver_dir = DRIVER_DIR_CHS
|
3848
|
+
if (
|
3849
|
+
hasattr(sb_config, "settings")
|
3850
|
+
and hasattr(sb_config.settings, "NEW_DRIVER_DIR")
|
3851
|
+
and sb_config.settings.NEW_DRIVER_DIR
|
3852
|
+
and os.path.exists(sb_config.settings.NEW_DRIVER_DIR)
|
3853
|
+
):
|
3854
|
+
driver_dir = sb_config.settings.NEW_DRIVER_DIR
|
3855
|
+
elif special_chrome:
|
3856
|
+
override_driver_dir(driver_dir)
|
3857
|
+
if IS_MAC or IS_LINUX:
|
3858
|
+
local_chromedriver = driver_dir + "/chromedriver"
|
3859
|
+
local_geckodriver = driver_dir + "/geckodriver"
|
3860
|
+
local_edgedriver = driver_dir + "/msedgedriver"
|
3861
|
+
local_uc_driver = driver_dir + "/uc_driver"
|
3862
|
+
elif IS_WINDOWS:
|
3863
|
+
local_edgedriver = driver_dir + "/msedgedriver.exe"
|
3864
|
+
local_iedriver = driver_dir + "/IEDriverServer.exe"
|
3865
|
+
local_headless_iedriver = driver_dir + "/headless_ie_selenium.exe"
|
3866
|
+
local_chromedriver = driver_dir + "/chromedriver.exe"
|
3867
|
+
local_geckodriver = driver_dir + "/geckodriver.exe"
|
3868
|
+
local_uc_driver = driver_dir + "/uc_driver.exe"
|
3775
3869
|
b_path = binary_location
|
3776
3870
|
use_uc = is_using_uc(undetectable, browser_name)
|
3777
3871
|
if use_wire:
|
@@ -3819,9 +3913,9 @@ def get_local_driver(
|
|
3819
3913
|
firefox_pref,
|
3820
3914
|
external_pdf,
|
3821
3915
|
)
|
3822
|
-
if
|
3916
|
+
if local_geckodriver and os.path.exists(local_geckodriver):
|
3823
3917
|
try:
|
3824
|
-
make_driver_executable_if_not(
|
3918
|
+
make_driver_executable_if_not(local_geckodriver)
|
3825
3919
|
except Exception as e:
|
3826
3920
|
logging.debug(
|
3827
3921
|
"\nWarning: Could not make geckodriver"
|
@@ -3857,9 +3951,9 @@ def get_local_driver(
|
|
3857
3951
|
sb_install.main(override="geckodriver")
|
3858
3952
|
sys.argv = sys_args # Put back original sys args
|
3859
3953
|
# Launch Firefox
|
3860
|
-
if os.path.exists(
|
3954
|
+
if os.path.exists(local_geckodriver):
|
3861
3955
|
service = FirefoxService(
|
3862
|
-
executable_path=
|
3956
|
+
executable_path=local_geckodriver,
|
3863
3957
|
log_output=os.devnull,
|
3864
3958
|
)
|
3865
3959
|
try:
|
@@ -3960,9 +4054,9 @@ def get_local_driver(
|
|
3960
4054
|
ie_options.native_events = True
|
3961
4055
|
ie_options.full_page_screenshot = True
|
3962
4056
|
ie_options.persistent_hover = True
|
3963
|
-
if
|
4057
|
+
if local_iedriver and os.path.exists(local_iedriver):
|
3964
4058
|
try:
|
3965
|
-
make_driver_executable_if_not(
|
4059
|
+
make_driver_executable_if_not(local_iedriver)
|
3966
4060
|
except Exception as e:
|
3967
4061
|
logging.debug(
|
3968
4062
|
"\nWarning: Could not make IEDriver executable: %s" % e
|
@@ -3976,9 +4070,9 @@ def get_local_driver(
|
|
3976
4070
|
log_d("\nWarning: IEDriver not found. Getting it now:")
|
3977
4071
|
sb_install.main(override="iedriver")
|
3978
4072
|
sys.argv = sys_args # Put back the original sys args
|
3979
|
-
if
|
4073
|
+
if local_headless_iedriver and os.path.exists(local_headless_iedriver):
|
3980
4074
|
try:
|
3981
|
-
make_driver_executable_if_not(
|
4075
|
+
make_driver_executable_if_not(local_headless_iedriver)
|
3982
4076
|
except Exception as e:
|
3983
4077
|
logging.debug(
|
3984
4078
|
"\nWarning: Could not make HeadlessIEDriver executable: %s"
|
@@ -4004,7 +4098,7 @@ def get_local_driver(
|
|
4004
4098
|
else:
|
4005
4099
|
warnings.simplefilter("ignore", category=DeprecationWarning)
|
4006
4100
|
service = Service(
|
4007
|
-
executable_path=
|
4101
|
+
executable_path=local_iedriver,
|
4008
4102
|
service_args=[d_b_c],
|
4009
4103
|
log_output=os.devnull,
|
4010
4104
|
)
|
@@ -4087,10 +4181,10 @@ def get_local_driver(
|
|
4087
4181
|
use_version = major_edge_version
|
4088
4182
|
edge_driver_version = None
|
4089
4183
|
edgedriver_upgrade_needed = False
|
4090
|
-
if os.path.exists(
|
4184
|
+
if os.path.exists(local_edgedriver):
|
4091
4185
|
with suppress(Exception):
|
4092
4186
|
output = subprocess.check_output(
|
4093
|
-
'"%s" --version' %
|
4187
|
+
'"%s" --version' % local_edgedriver, shell=True
|
4094
4188
|
)
|
4095
4189
|
if IS_WINDOWS:
|
4096
4190
|
output = output.decode("latin1")
|
@@ -4118,7 +4212,7 @@ def get_local_driver(
|
|
4118
4212
|
use_version, driver_version
|
4119
4213
|
)
|
4120
4214
|
local_edgedriver_exists = False
|
4121
|
-
if
|
4215
|
+
if local_edgedriver and os.path.exists(local_edgedriver):
|
4122
4216
|
local_edgedriver_exists = True
|
4123
4217
|
if (
|
4124
4218
|
use_version != "latest"
|
@@ -4128,7 +4222,7 @@ def get_local_driver(
|
|
4128
4222
|
edgedriver_upgrade_needed = True
|
4129
4223
|
else:
|
4130
4224
|
try:
|
4131
|
-
make_driver_executable_if_not(
|
4225
|
+
make_driver_executable_if_not(local_edgedriver)
|
4132
4226
|
except Exception as e:
|
4133
4227
|
logging.debug(
|
4134
4228
|
"\nWarning: Could not make edgedriver"
|
@@ -4166,9 +4260,9 @@ def get_local_driver(
|
|
4166
4260
|
# For Microsoft Edge (Chromium) version 80 or higher
|
4167
4261
|
Edge = webdriver.edge.webdriver.WebDriver
|
4168
4262
|
EdgeOptions = webdriver.edge.webdriver.Options
|
4169
|
-
if
|
4263
|
+
if local_edgedriver and os.path.exists(local_edgedriver):
|
4170
4264
|
try:
|
4171
|
-
make_driver_executable_if_not(
|
4265
|
+
make_driver_executable_if_not(local_edgedriver)
|
4172
4266
|
except Exception as e:
|
4173
4267
|
logging.debug(
|
4174
4268
|
"\nWarning: Could not make edgedriver"
|
@@ -4499,7 +4593,7 @@ def get_local_driver(
|
|
4499
4593
|
if binary_location:
|
4500
4594
|
edge_options.binary_location = binary_location
|
4501
4595
|
service = EdgeService(
|
4502
|
-
executable_path=
|
4596
|
+
executable_path=local_edgedriver,
|
4503
4597
|
log_output=os.devnull,
|
4504
4598
|
service_args=["--disable-build-check"],
|
4505
4599
|
)
|
@@ -4711,10 +4805,10 @@ def get_local_driver(
|
|
4711
4805
|
use_version = major_chrome_version
|
4712
4806
|
ch_driver_version = None
|
4713
4807
|
path_chromedriver = chromedriver_on_path()
|
4714
|
-
if os.path.exists(
|
4808
|
+
if os.path.exists(local_chromedriver):
|
4715
4809
|
with suppress(Exception):
|
4716
4810
|
output = subprocess.check_output(
|
4717
|
-
'"%s" --version' %
|
4811
|
+
'"%s" --version' % local_chromedriver, shell=True
|
4718
4812
|
)
|
4719
4813
|
if IS_WINDOWS:
|
4720
4814
|
output = output.decode("latin1")
|
@@ -4752,10 +4846,14 @@ def get_local_driver(
|
|
4752
4846
|
uc_driver_version = None
|
4753
4847
|
if use_uc:
|
4754
4848
|
if use_br_version_for_uc or driver_version == "mlatest":
|
4755
|
-
uc_driver_version = get_uc_driver_version(
|
4849
|
+
uc_driver_version = get_uc_driver_version(
|
4850
|
+
full=True, local_uc_driver=local_uc_driver
|
4851
|
+
)
|
4756
4852
|
full_ch_driver_version = uc_driver_version
|
4757
4853
|
else:
|
4758
|
-
uc_driver_version = get_uc_driver_version(
|
4854
|
+
uc_driver_version = get_uc_driver_version(
|
4855
|
+
local_uc_driver=local_uc_driver
|
4856
|
+
)
|
4759
4857
|
if multi_proxy:
|
4760
4858
|
sb_config.multi_proxy = True
|
4761
4859
|
if uc_driver_version and driver_version == "keep":
|
@@ -4803,9 +4901,9 @@ def get_local_driver(
|
|
4803
4901
|
chrome_options.add_argument("--headless=old")
|
4804
4902
|
else:
|
4805
4903
|
chrome_options.add_argument("--headless")
|
4806
|
-
if
|
4904
|
+
if local_chromedriver and os.path.exists(local_chromedriver):
|
4807
4905
|
try:
|
4808
|
-
make_driver_executable_if_not(
|
4906
|
+
make_driver_executable_if_not(local_chromedriver)
|
4809
4907
|
except Exception as e:
|
4810
4908
|
logging.debug(
|
4811
4909
|
"\nWarning: Could not make chromedriver"
|
@@ -4813,9 +4911,9 @@ def get_local_driver(
|
|
4813
4911
|
)
|
4814
4912
|
make_uc_driver_from_chromedriver = False
|
4815
4913
|
local_ch_exists = (
|
4816
|
-
|
4914
|
+
local_chromedriver and os.path.exists(local_chromedriver)
|
4817
4915
|
)
|
4818
|
-
"""If no
|
4916
|
+
"""If no local_chromedriver, but path_chromedriver, and the
|
4819
4917
|
browser version nearly matches the driver version, then use
|
4820
4918
|
the path_chromedriver instead of downloading a new driver.
|
4821
4919
|
Eg. 116.0.* for both is close, but not 116.0.* and 116.1.*"""
|
@@ -4843,20 +4941,20 @@ def get_local_driver(
|
|
4843
4941
|
(local_ch_exists or path_chromedriver)
|
4844
4942
|
and use_version == ch_driver_version
|
4845
4943
|
and (
|
4846
|
-
not os.path.exists(
|
4944
|
+
not os.path.exists(local_uc_driver)
|
4847
4945
|
or uc_driver_version != use_version
|
4848
4946
|
)
|
4849
4947
|
)
|
4850
4948
|
or (
|
4851
4949
|
local_ch_exists
|
4852
4950
|
and use_version == "latest"
|
4853
|
-
and not os.path.exists(
|
4951
|
+
and not os.path.exists(local_uc_driver)
|
4854
4952
|
)
|
4855
4953
|
)
|
4856
4954
|
):
|
4857
4955
|
make_uc_driver_from_chromedriver = True
|
4858
4956
|
elif (
|
4859
|
-
(use_uc and not os.path.exists(
|
4957
|
+
(use_uc and not os.path.exists(local_uc_driver))
|
4860
4958
|
or (not use_uc and not path_chromedriver)
|
4861
4959
|
or (
|
4862
4960
|
not use_uc
|
@@ -4893,9 +4991,9 @@ def get_local_driver(
|
|
4893
4991
|
msg = "chromedriver update needed. Getting it now:"
|
4894
4992
|
if not path_chromedriver:
|
4895
4993
|
msg = "chromedriver not found. Getting it now:"
|
4896
|
-
if use_uc and not os.path.exists(
|
4994
|
+
if use_uc and not os.path.exists(local_uc_driver):
|
4897
4995
|
msg = "uc_driver not found. Getting it now:"
|
4898
|
-
if use_uc and os.path.exists(
|
4996
|
+
if use_uc and os.path.exists(local_uc_driver):
|
4899
4997
|
msg = "uc_driver update needed. Getting it now:"
|
4900
4998
|
log_d("\nWarning: %s" % msg)
|
4901
4999
|
force_uc = False
|
@@ -4944,9 +5042,9 @@ def get_local_driver(
|
|
4944
5042
|
msg = "chromedriver update needed. Getting it now:"
|
4945
5043
|
if not path_chromedriver:
|
4946
5044
|
msg = "chromedriver not found. Getting it now:"
|
4947
|
-
if use_uc and not os.path.exists(
|
5045
|
+
if use_uc and not os.path.exists(local_uc_driver):
|
4948
5046
|
msg = "uc_driver not found. Getting it now:"
|
4949
|
-
if use_uc and os.path.exists(
|
5047
|
+
if use_uc and os.path.exists(local_uc_driver):
|
4950
5048
|
msg = "uc_driver update needed. Getting it now:"
|
4951
5049
|
force_uc = False
|
4952
5050
|
intel_for_uc = False
|
@@ -4954,10 +5052,10 @@ def get_local_driver(
|
|
4954
5052
|
force_uc = True
|
4955
5053
|
if IS_ARM_MAC and use_uc:
|
4956
5054
|
intel_for_uc = True # Use Intel driver for UC Mode
|
4957
|
-
if os.path.exists(
|
5055
|
+
if os.path.exists(local_chromedriver):
|
4958
5056
|
with suppress(Exception):
|
4959
5057
|
output = subprocess.check_output(
|
4960
|
-
'"%s" --version' %
|
5058
|
+
'"%s" --version' % local_chromedriver,
|
4961
5059
|
shell=True,
|
4962
5060
|
)
|
4963
5061
|
if IS_WINDOWS:
|
@@ -4971,9 +5069,9 @@ def get_local_driver(
|
|
4971
5069
|
if (
|
4972
5070
|
(
|
4973
5071
|
not use_uc
|
4974
|
-
and not os.path.exists(
|
5072
|
+
and not os.path.exists(local_chromedriver)
|
4975
5073
|
)
|
4976
|
-
or (use_uc and not os.path.exists(
|
5074
|
+
or (use_uc and not os.path.exists(local_uc_driver))
|
4977
5075
|
or (
|
4978
5076
|
not use_uc
|
4979
5077
|
and (
|
@@ -4985,7 +5083,9 @@ def get_local_driver(
|
|
4985
5083
|
use_uc
|
4986
5084
|
and (
|
4987
5085
|
use_version.split(".")[0]
|
4988
|
-
!= get_uc_driver_version(
|
5086
|
+
!= get_uc_driver_version(
|
5087
|
+
local_uc_driver=local_uc_driver
|
5088
|
+
)
|
4989
5089
|
)
|
4990
5090
|
)
|
4991
5091
|
):
|
@@ -5037,20 +5137,20 @@ def get_local_driver(
|
|
5037
5137
|
constants.MultiBrowser.DRIVER_FIXING_LOCK
|
5038
5138
|
)
|
5039
5139
|
if make_uc_driver_from_chromedriver:
|
5040
|
-
if os.path.exists(
|
5140
|
+
if os.path.exists(local_chromedriver):
|
5041
5141
|
with suppress(Exception):
|
5042
5142
|
make_driver_executable_if_not(
|
5043
|
-
|
5143
|
+
local_chromedriver
|
5044
5144
|
)
|
5045
|
-
shutil.copy2(
|
5145
|
+
shutil.copy2(local_chromedriver, local_uc_driver)
|
5046
5146
|
elif os.path.exists(path_chromedriver):
|
5047
5147
|
with suppress(Exception):
|
5048
5148
|
make_driver_executable_if_not(
|
5049
5149
|
path_chromedriver
|
5050
5150
|
)
|
5051
|
-
shutil.copy2(path_chromedriver,
|
5151
|
+
shutil.copy2(path_chromedriver, local_uc_driver)
|
5052
5152
|
try:
|
5053
|
-
make_driver_executable_if_not(
|
5153
|
+
make_driver_executable_if_not(local_uc_driver)
|
5054
5154
|
except Exception as e:
|
5055
5155
|
logging.debug(
|
5056
5156
|
"\nWarning: Could not make uc_driver"
|
@@ -5059,7 +5159,7 @@ def get_local_driver(
|
|
5059
5159
|
if not headless or not IS_LINUX or use_uc:
|
5060
5160
|
uc_activated = False
|
5061
5161
|
try:
|
5062
|
-
if os.path.exists(
|
5162
|
+
if os.path.exists(local_chromedriver) or use_uc:
|
5063
5163
|
if headless and not IS_LINUX:
|
5064
5164
|
undetectable = False # No support for headless
|
5065
5165
|
use_uc = is_using_uc(undetectable, browser_name)
|
@@ -5204,9 +5304,9 @@ def get_local_driver(
|
|
5204
5304
|
force_uc=False,
|
5205
5305
|
)
|
5206
5306
|
d_b_c = "--disable-build-check"
|
5207
|
-
if os.path.exists(
|
5307
|
+
if os.path.exists(local_chromedriver):
|
5208
5308
|
service = ChromeService(
|
5209
|
-
executable_path=
|
5309
|
+
executable_path=local_chromedriver,
|
5210
5310
|
log_output=os.devnull,
|
5211
5311
|
service_args=[d_b_c],
|
5212
5312
|
)
|
@@ -5247,8 +5347,8 @@ def get_local_driver(
|
|
5247
5347
|
sb_config.uc_agent_cache = user_agent
|
5248
5348
|
driver.quit()
|
5249
5349
|
uc_path = None
|
5250
|
-
if os.path.exists(
|
5251
|
-
uc_path =
|
5350
|
+
if os.path.exists(local_uc_driver):
|
5351
|
+
uc_path = local_uc_driver
|
5252
5352
|
uc_path = os.path.realpath(uc_path)
|
5253
5353
|
try:
|
5254
5354
|
driver = undetected.Chrome(
|
@@ -5326,7 +5426,7 @@ def get_local_driver(
|
|
5326
5426
|
"w3c", True
|
5327
5427
|
)
|
5328
5428
|
service = ChromeService(
|
5329
|
-
executable_path=
|
5429
|
+
executable_path=local_chromedriver,
|
5330
5430
|
log_output=os.devnull,
|
5331
5431
|
service_args=service_args,
|
5332
5432
|
)
|
@@ -5461,9 +5561,9 @@ def get_local_driver(
|
|
5461
5561
|
chrome_options, headless_options, mcv
|
5462
5562
|
)
|
5463
5563
|
_mark_driver_repaired()
|
5464
|
-
if os.path.exists(
|
5564
|
+
if os.path.exists(local_chromedriver):
|
5465
5565
|
service = ChromeService(
|
5466
|
-
executable_path=
|
5566
|
+
executable_path=local_chromedriver,
|
5467
5567
|
log_output=os.devnull,
|
5468
5568
|
service_args=["--disable-build-check"],
|
5469
5569
|
)
|
@@ -5740,9 +5840,9 @@ def get_local_driver(
|
|
5740
5840
|
elif headless or headless2 or IS_LINUX or proxy_string or use_wire:
|
5741
5841
|
raise
|
5742
5842
|
# Try running without any options (bare bones Chrome launch)
|
5743
|
-
if
|
5843
|
+
if local_chromedriver and os.path.exists(local_chromedriver):
|
5744
5844
|
try:
|
5745
|
-
make_driver_executable_if_not(
|
5845
|
+
make_driver_executable_if_not(local_chromedriver)
|
5746
5846
|
except Exception as e:
|
5747
5847
|
logging.debug(
|
5748
5848
|
"\nWarning: Could not make chromedriver"
|
seleniumbase/core/log_helper.py
CHANGED
@@ -228,7 +228,11 @@ def log_test_failure_data(test, test_logpath, driver, browser, url=None):
|
|
228
228
|
traceback_message = None
|
229
229
|
if hasattr(test, "is_behave") and test.is_behave:
|
230
230
|
if sb_config.behave_scenario.status.name == "failed":
|
231
|
-
if
|
231
|
+
if (
|
232
|
+
hasattr(sb_config, "behave_step")
|
233
|
+
and hasattr(sb_config.behave_step, "error_message")
|
234
|
+
and sb_config.behave_step.error_message
|
235
|
+
):
|
232
236
|
traceback_message = sb_config.behave_step.error_message
|
233
237
|
else:
|
234
238
|
format_exception = traceback.format_exception(
|