seleniumbase 4.39.6a1__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 +165 -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 +167 -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.6a1.dist-info → seleniumbase-4.40.0.dist-info}/METADATA +6 -6
- {seleniumbase-4.39.6a1.dist-info → seleniumbase-4.40.0.dist-info}/RECORD +18 -16
- {seleniumbase-4.39.6a1.dist-info → seleniumbase-4.40.0.dist-info}/WHEEL +0 -0
- {seleniumbase-4.39.6a1.dist-info → seleniumbase-4.40.0.dist-info}/entry_points.txt +0 -0
- {seleniumbase-4.39.6a1.dist-info → seleniumbase-4.40.0.dist-info}/licenses/LICENSE +0 -0
- {seleniumbase-4.39.6a1.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()
|
@@ -580,6 +613,7 @@ def uc_open_with_cdp_mode(driver, url=None, **kwargs):
|
|
580
613
|
headless = False
|
581
614
|
headed = None
|
582
615
|
xvfb = None
|
616
|
+
xvfb_metrics = None
|
583
617
|
binary_location = None
|
584
618
|
if hasattr(sb_config, "headless"):
|
585
619
|
headless = sb_config.headless
|
@@ -587,6 +621,8 @@ def uc_open_with_cdp_mode(driver, url=None, **kwargs):
|
|
587
621
|
headed = sb_config.headed
|
588
622
|
if hasattr(sb_config, "xvfb"):
|
589
623
|
xvfb = sb_config.xvfb
|
624
|
+
if hasattr(sb_config, "xvfb_metrics"):
|
625
|
+
xvfb_metrics = sb_config.xvfb_metrics
|
590
626
|
if hasattr(sb_config, "binary_location"):
|
591
627
|
binary_location = sb_config.binary_location
|
592
628
|
|
@@ -599,6 +635,7 @@ def uc_open_with_cdp_mode(driver, url=None, **kwargs):
|
|
599
635
|
headless=headless,
|
600
636
|
headed=headed,
|
601
637
|
xvfb=xvfb,
|
638
|
+
xvfb_metrics=xvfb_metrics,
|
602
639
|
browser_executable_path=binary_location,
|
603
640
|
)
|
604
641
|
)
|
@@ -788,6 +825,14 @@ def uc_open_with_cdp_mode(driver, url=None, **kwargs):
|
|
788
825
|
cdp.wait_for_element_visible = CDPM.wait_for_element_visible
|
789
826
|
cdp.wait_for_element_not_visible = CDPM.wait_for_element_not_visible
|
790
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
|
791
836
|
cdp.assert_element = CDPM.assert_element
|
792
837
|
cdp.assert_element_visible = CDPM.assert_element_visible
|
793
838
|
cdp.assert_element_present = CDPM.assert_element_present
|
@@ -2834,6 +2879,24 @@ def get_driver(
|
|
2834
2879
|
device_pixel_ratio=None,
|
2835
2880
|
browser=None, # A duplicate of browser_name to avoid confusion
|
2836
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
|
2837
2900
|
if not browser_name:
|
2838
2901
|
if browser:
|
2839
2902
|
browser_name = browser
|
@@ -2878,7 +2941,7 @@ def get_driver(
|
|
2878
2941
|
else:
|
2879
2942
|
binary_folder = "chrome-win32"
|
2880
2943
|
if binary_folder:
|
2881
|
-
binary_location = os.path.join(
|
2944
|
+
binary_location = os.path.join(driver_dir, binary_folder)
|
2882
2945
|
if not os.path.exists(binary_location):
|
2883
2946
|
from seleniumbase.console_scripts import sb_install
|
2884
2947
|
args = " ".join(sys.argv)
|
@@ -2932,7 +2995,7 @@ def get_driver(
|
|
2932
2995
|
else:
|
2933
2996
|
binary_folder = "chrome-headless-shell-win32"
|
2934
2997
|
if binary_folder:
|
2935
|
-
binary_location = os.path.join(
|
2998
|
+
binary_location = os.path.join(driver_dir, binary_folder)
|
2936
2999
|
if not os.path.exists(binary_location):
|
2937
3000
|
from seleniumbase.console_scripts import sb_install
|
2938
3001
|
args = " ".join(sys.argv)
|
@@ -3768,6 +3831,41 @@ def get_local_driver(
|
|
3768
3831
|
"""Spins up a new web browser and returns the driver.
|
3769
3832
|
Can also be used to spin up additional browsers for the same test."""
|
3770
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"
|
3771
3869
|
b_path = binary_location
|
3772
3870
|
use_uc = is_using_uc(undetectable, browser_name)
|
3773
3871
|
if use_wire:
|
@@ -3815,9 +3913,9 @@ def get_local_driver(
|
|
3815
3913
|
firefox_pref,
|
3816
3914
|
external_pdf,
|
3817
3915
|
)
|
3818
|
-
if
|
3916
|
+
if local_geckodriver and os.path.exists(local_geckodriver):
|
3819
3917
|
try:
|
3820
|
-
make_driver_executable_if_not(
|
3918
|
+
make_driver_executable_if_not(local_geckodriver)
|
3821
3919
|
except Exception as e:
|
3822
3920
|
logging.debug(
|
3823
3921
|
"\nWarning: Could not make geckodriver"
|
@@ -3853,9 +3951,9 @@ def get_local_driver(
|
|
3853
3951
|
sb_install.main(override="geckodriver")
|
3854
3952
|
sys.argv = sys_args # Put back original sys args
|
3855
3953
|
# Launch Firefox
|
3856
|
-
if os.path.exists(
|
3954
|
+
if os.path.exists(local_geckodriver):
|
3857
3955
|
service = FirefoxService(
|
3858
|
-
executable_path=
|
3956
|
+
executable_path=local_geckodriver,
|
3859
3957
|
log_output=os.devnull,
|
3860
3958
|
)
|
3861
3959
|
try:
|
@@ -3956,9 +4054,9 @@ def get_local_driver(
|
|
3956
4054
|
ie_options.native_events = True
|
3957
4055
|
ie_options.full_page_screenshot = True
|
3958
4056
|
ie_options.persistent_hover = True
|
3959
|
-
if
|
4057
|
+
if local_iedriver and os.path.exists(local_iedriver):
|
3960
4058
|
try:
|
3961
|
-
make_driver_executable_if_not(
|
4059
|
+
make_driver_executable_if_not(local_iedriver)
|
3962
4060
|
except Exception as e:
|
3963
4061
|
logging.debug(
|
3964
4062
|
"\nWarning: Could not make IEDriver executable: %s" % e
|
@@ -3972,9 +4070,9 @@ def get_local_driver(
|
|
3972
4070
|
log_d("\nWarning: IEDriver not found. Getting it now:")
|
3973
4071
|
sb_install.main(override="iedriver")
|
3974
4072
|
sys.argv = sys_args # Put back the original sys args
|
3975
|
-
if
|
4073
|
+
if local_headless_iedriver and os.path.exists(local_headless_iedriver):
|
3976
4074
|
try:
|
3977
|
-
make_driver_executable_if_not(
|
4075
|
+
make_driver_executable_if_not(local_headless_iedriver)
|
3978
4076
|
except Exception as e:
|
3979
4077
|
logging.debug(
|
3980
4078
|
"\nWarning: Could not make HeadlessIEDriver executable: %s"
|
@@ -4000,7 +4098,7 @@ def get_local_driver(
|
|
4000
4098
|
else:
|
4001
4099
|
warnings.simplefilter("ignore", category=DeprecationWarning)
|
4002
4100
|
service = Service(
|
4003
|
-
executable_path=
|
4101
|
+
executable_path=local_iedriver,
|
4004
4102
|
service_args=[d_b_c],
|
4005
4103
|
log_output=os.devnull,
|
4006
4104
|
)
|
@@ -4083,10 +4181,10 @@ def get_local_driver(
|
|
4083
4181
|
use_version = major_edge_version
|
4084
4182
|
edge_driver_version = None
|
4085
4183
|
edgedriver_upgrade_needed = False
|
4086
|
-
if os.path.exists(
|
4184
|
+
if os.path.exists(local_edgedriver):
|
4087
4185
|
with suppress(Exception):
|
4088
4186
|
output = subprocess.check_output(
|
4089
|
-
'"%s" --version' %
|
4187
|
+
'"%s" --version' % local_edgedriver, shell=True
|
4090
4188
|
)
|
4091
4189
|
if IS_WINDOWS:
|
4092
4190
|
output = output.decode("latin1")
|
@@ -4114,7 +4212,7 @@ def get_local_driver(
|
|
4114
4212
|
use_version, driver_version
|
4115
4213
|
)
|
4116
4214
|
local_edgedriver_exists = False
|
4117
|
-
if
|
4215
|
+
if local_edgedriver and os.path.exists(local_edgedriver):
|
4118
4216
|
local_edgedriver_exists = True
|
4119
4217
|
if (
|
4120
4218
|
use_version != "latest"
|
@@ -4124,7 +4222,7 @@ def get_local_driver(
|
|
4124
4222
|
edgedriver_upgrade_needed = True
|
4125
4223
|
else:
|
4126
4224
|
try:
|
4127
|
-
make_driver_executable_if_not(
|
4225
|
+
make_driver_executable_if_not(local_edgedriver)
|
4128
4226
|
except Exception as e:
|
4129
4227
|
logging.debug(
|
4130
4228
|
"\nWarning: Could not make edgedriver"
|
@@ -4162,9 +4260,9 @@ def get_local_driver(
|
|
4162
4260
|
# For Microsoft Edge (Chromium) version 80 or higher
|
4163
4261
|
Edge = webdriver.edge.webdriver.WebDriver
|
4164
4262
|
EdgeOptions = webdriver.edge.webdriver.Options
|
4165
|
-
if
|
4263
|
+
if local_edgedriver and os.path.exists(local_edgedriver):
|
4166
4264
|
try:
|
4167
|
-
make_driver_executable_if_not(
|
4265
|
+
make_driver_executable_if_not(local_edgedriver)
|
4168
4266
|
except Exception as e:
|
4169
4267
|
logging.debug(
|
4170
4268
|
"\nWarning: Could not make edgedriver"
|
@@ -4495,7 +4593,7 @@ def get_local_driver(
|
|
4495
4593
|
if binary_location:
|
4496
4594
|
edge_options.binary_location = binary_location
|
4497
4595
|
service = EdgeService(
|
4498
|
-
executable_path=
|
4596
|
+
executable_path=local_edgedriver,
|
4499
4597
|
log_output=os.devnull,
|
4500
4598
|
service_args=["--disable-build-check"],
|
4501
4599
|
)
|
@@ -4707,10 +4805,10 @@ def get_local_driver(
|
|
4707
4805
|
use_version = major_chrome_version
|
4708
4806
|
ch_driver_version = None
|
4709
4807
|
path_chromedriver = chromedriver_on_path()
|
4710
|
-
if os.path.exists(
|
4808
|
+
if os.path.exists(local_chromedriver):
|
4711
4809
|
with suppress(Exception):
|
4712
4810
|
output = subprocess.check_output(
|
4713
|
-
'"%s" --version' %
|
4811
|
+
'"%s" --version' % local_chromedriver, shell=True
|
4714
4812
|
)
|
4715
4813
|
if IS_WINDOWS:
|
4716
4814
|
output = output.decode("latin1")
|
@@ -4748,10 +4846,14 @@ def get_local_driver(
|
|
4748
4846
|
uc_driver_version = None
|
4749
4847
|
if use_uc:
|
4750
4848
|
if use_br_version_for_uc or driver_version == "mlatest":
|
4751
|
-
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
|
+
)
|
4752
4852
|
full_ch_driver_version = uc_driver_version
|
4753
4853
|
else:
|
4754
|
-
uc_driver_version = get_uc_driver_version(
|
4854
|
+
uc_driver_version = get_uc_driver_version(
|
4855
|
+
local_uc_driver=local_uc_driver
|
4856
|
+
)
|
4755
4857
|
if multi_proxy:
|
4756
4858
|
sb_config.multi_proxy = True
|
4757
4859
|
if uc_driver_version and driver_version == "keep":
|
@@ -4799,9 +4901,9 @@ def get_local_driver(
|
|
4799
4901
|
chrome_options.add_argument("--headless=old")
|
4800
4902
|
else:
|
4801
4903
|
chrome_options.add_argument("--headless")
|
4802
|
-
if
|
4904
|
+
if local_chromedriver and os.path.exists(local_chromedriver):
|
4803
4905
|
try:
|
4804
|
-
make_driver_executable_if_not(
|
4906
|
+
make_driver_executable_if_not(local_chromedriver)
|
4805
4907
|
except Exception as e:
|
4806
4908
|
logging.debug(
|
4807
4909
|
"\nWarning: Could not make chromedriver"
|
@@ -4809,9 +4911,9 @@ def get_local_driver(
|
|
4809
4911
|
)
|
4810
4912
|
make_uc_driver_from_chromedriver = False
|
4811
4913
|
local_ch_exists = (
|
4812
|
-
|
4914
|
+
local_chromedriver and os.path.exists(local_chromedriver)
|
4813
4915
|
)
|
4814
|
-
"""If no
|
4916
|
+
"""If no local_chromedriver, but path_chromedriver, and the
|
4815
4917
|
browser version nearly matches the driver version, then use
|
4816
4918
|
the path_chromedriver instead of downloading a new driver.
|
4817
4919
|
Eg. 116.0.* for both is close, but not 116.0.* and 116.1.*"""
|
@@ -4839,20 +4941,20 @@ def get_local_driver(
|
|
4839
4941
|
(local_ch_exists or path_chromedriver)
|
4840
4942
|
and use_version == ch_driver_version
|
4841
4943
|
and (
|
4842
|
-
not os.path.exists(
|
4944
|
+
not os.path.exists(local_uc_driver)
|
4843
4945
|
or uc_driver_version != use_version
|
4844
4946
|
)
|
4845
4947
|
)
|
4846
4948
|
or (
|
4847
4949
|
local_ch_exists
|
4848
4950
|
and use_version == "latest"
|
4849
|
-
and not os.path.exists(
|
4951
|
+
and not os.path.exists(local_uc_driver)
|
4850
4952
|
)
|
4851
4953
|
)
|
4852
4954
|
):
|
4853
4955
|
make_uc_driver_from_chromedriver = True
|
4854
4956
|
elif (
|
4855
|
-
(use_uc and not os.path.exists(
|
4957
|
+
(use_uc and not os.path.exists(local_uc_driver))
|
4856
4958
|
or (not use_uc and not path_chromedriver)
|
4857
4959
|
or (
|
4858
4960
|
not use_uc
|
@@ -4889,9 +4991,9 @@ def get_local_driver(
|
|
4889
4991
|
msg = "chromedriver update needed. Getting it now:"
|
4890
4992
|
if not path_chromedriver:
|
4891
4993
|
msg = "chromedriver not found. Getting it now:"
|
4892
|
-
if use_uc and not os.path.exists(
|
4994
|
+
if use_uc and not os.path.exists(local_uc_driver):
|
4893
4995
|
msg = "uc_driver not found. Getting it now:"
|
4894
|
-
if use_uc and os.path.exists(
|
4996
|
+
if use_uc and os.path.exists(local_uc_driver):
|
4895
4997
|
msg = "uc_driver update needed. Getting it now:"
|
4896
4998
|
log_d("\nWarning: %s" % msg)
|
4897
4999
|
force_uc = False
|
@@ -4940,9 +5042,9 @@ def get_local_driver(
|
|
4940
5042
|
msg = "chromedriver update needed. Getting it now:"
|
4941
5043
|
if not path_chromedriver:
|
4942
5044
|
msg = "chromedriver not found. Getting it now:"
|
4943
|
-
if use_uc and not os.path.exists(
|
5045
|
+
if use_uc and not os.path.exists(local_uc_driver):
|
4944
5046
|
msg = "uc_driver not found. Getting it now:"
|
4945
|
-
if use_uc and os.path.exists(
|
5047
|
+
if use_uc and os.path.exists(local_uc_driver):
|
4946
5048
|
msg = "uc_driver update needed. Getting it now:"
|
4947
5049
|
force_uc = False
|
4948
5050
|
intel_for_uc = False
|
@@ -4950,10 +5052,10 @@ def get_local_driver(
|
|
4950
5052
|
force_uc = True
|
4951
5053
|
if IS_ARM_MAC and use_uc:
|
4952
5054
|
intel_for_uc = True # Use Intel driver for UC Mode
|
4953
|
-
if os.path.exists(
|
5055
|
+
if os.path.exists(local_chromedriver):
|
4954
5056
|
with suppress(Exception):
|
4955
5057
|
output = subprocess.check_output(
|
4956
|
-
'"%s" --version' %
|
5058
|
+
'"%s" --version' % local_chromedriver,
|
4957
5059
|
shell=True,
|
4958
5060
|
)
|
4959
5061
|
if IS_WINDOWS:
|
@@ -4967,9 +5069,9 @@ def get_local_driver(
|
|
4967
5069
|
if (
|
4968
5070
|
(
|
4969
5071
|
not use_uc
|
4970
|
-
and not os.path.exists(
|
5072
|
+
and not os.path.exists(local_chromedriver)
|
4971
5073
|
)
|
4972
|
-
or (use_uc and not os.path.exists(
|
5074
|
+
or (use_uc and not os.path.exists(local_uc_driver))
|
4973
5075
|
or (
|
4974
5076
|
not use_uc
|
4975
5077
|
and (
|
@@ -4981,7 +5083,9 @@ def get_local_driver(
|
|
4981
5083
|
use_uc
|
4982
5084
|
and (
|
4983
5085
|
use_version.split(".")[0]
|
4984
|
-
!= get_uc_driver_version(
|
5086
|
+
!= get_uc_driver_version(
|
5087
|
+
local_uc_driver=local_uc_driver
|
5088
|
+
)
|
4985
5089
|
)
|
4986
5090
|
)
|
4987
5091
|
):
|
@@ -5033,20 +5137,20 @@ def get_local_driver(
|
|
5033
5137
|
constants.MultiBrowser.DRIVER_FIXING_LOCK
|
5034
5138
|
)
|
5035
5139
|
if make_uc_driver_from_chromedriver:
|
5036
|
-
if os.path.exists(
|
5140
|
+
if os.path.exists(local_chromedriver):
|
5037
5141
|
with suppress(Exception):
|
5038
5142
|
make_driver_executable_if_not(
|
5039
|
-
|
5143
|
+
local_chromedriver
|
5040
5144
|
)
|
5041
|
-
shutil.copy2(
|
5145
|
+
shutil.copy2(local_chromedriver, local_uc_driver)
|
5042
5146
|
elif os.path.exists(path_chromedriver):
|
5043
5147
|
with suppress(Exception):
|
5044
5148
|
make_driver_executable_if_not(
|
5045
5149
|
path_chromedriver
|
5046
5150
|
)
|
5047
|
-
shutil.copy2(path_chromedriver,
|
5151
|
+
shutil.copy2(path_chromedriver, local_uc_driver)
|
5048
5152
|
try:
|
5049
|
-
make_driver_executable_if_not(
|
5153
|
+
make_driver_executable_if_not(local_uc_driver)
|
5050
5154
|
except Exception as e:
|
5051
5155
|
logging.debug(
|
5052
5156
|
"\nWarning: Could not make uc_driver"
|
@@ -5055,7 +5159,7 @@ def get_local_driver(
|
|
5055
5159
|
if not headless or not IS_LINUX or use_uc:
|
5056
5160
|
uc_activated = False
|
5057
5161
|
try:
|
5058
|
-
if os.path.exists(
|
5162
|
+
if os.path.exists(local_chromedriver) or use_uc:
|
5059
5163
|
if headless and not IS_LINUX:
|
5060
5164
|
undetectable = False # No support for headless
|
5061
5165
|
use_uc = is_using_uc(undetectable, browser_name)
|
@@ -5200,9 +5304,9 @@ def get_local_driver(
|
|
5200
5304
|
force_uc=False,
|
5201
5305
|
)
|
5202
5306
|
d_b_c = "--disable-build-check"
|
5203
|
-
if os.path.exists(
|
5307
|
+
if os.path.exists(local_chromedriver):
|
5204
5308
|
service = ChromeService(
|
5205
|
-
executable_path=
|
5309
|
+
executable_path=local_chromedriver,
|
5206
5310
|
log_output=os.devnull,
|
5207
5311
|
service_args=[d_b_c],
|
5208
5312
|
)
|
@@ -5243,8 +5347,8 @@ def get_local_driver(
|
|
5243
5347
|
sb_config.uc_agent_cache = user_agent
|
5244
5348
|
driver.quit()
|
5245
5349
|
uc_path = None
|
5246
|
-
if os.path.exists(
|
5247
|
-
uc_path =
|
5350
|
+
if os.path.exists(local_uc_driver):
|
5351
|
+
uc_path = local_uc_driver
|
5248
5352
|
uc_path = os.path.realpath(uc_path)
|
5249
5353
|
try:
|
5250
5354
|
driver = undetected.Chrome(
|
@@ -5322,7 +5426,7 @@ def get_local_driver(
|
|
5322
5426
|
"w3c", True
|
5323
5427
|
)
|
5324
5428
|
service = ChromeService(
|
5325
|
-
executable_path=
|
5429
|
+
executable_path=local_chromedriver,
|
5326
5430
|
log_output=os.devnull,
|
5327
5431
|
service_args=service_args,
|
5328
5432
|
)
|
@@ -5457,9 +5561,9 @@ def get_local_driver(
|
|
5457
5561
|
chrome_options, headless_options, mcv
|
5458
5562
|
)
|
5459
5563
|
_mark_driver_repaired()
|
5460
|
-
if os.path.exists(
|
5564
|
+
if os.path.exists(local_chromedriver):
|
5461
5565
|
service = ChromeService(
|
5462
|
-
executable_path=
|
5566
|
+
executable_path=local_chromedriver,
|
5463
5567
|
log_output=os.devnull,
|
5464
5568
|
service_args=["--disable-build-check"],
|
5465
5569
|
)
|
@@ -5736,9 +5840,9 @@ def get_local_driver(
|
|
5736
5840
|
elif headless or headless2 or IS_LINUX or proxy_string or use_wire:
|
5737
5841
|
raise
|
5738
5842
|
# Try running without any options (bare bones Chrome launch)
|
5739
|
-
if
|
5843
|
+
if local_chromedriver and os.path.exists(local_chromedriver):
|
5740
5844
|
try:
|
5741
|
-
make_driver_executable_if_not(
|
5845
|
+
make_driver_executable_if_not(local_chromedriver)
|
5742
5846
|
except Exception as e:
|
5743
5847
|
logging.debug(
|
5744
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(
|