seleniumbase 4.33.1__py3-none-any.whl → 4.33.3__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- seleniumbase/__version__.py +1 -1
- seleniumbase/core/browser_launcher.py +9 -5
- seleniumbase/core/sb_cdp.py +37 -21
- seleniumbase/fixtures/base_case.py +26 -13
- seleniumbase/fixtures/js_utils.py +94 -86
- seleniumbase/undetected/cdp_driver/tab.py +4 -0
- {seleniumbase-4.33.1.dist-info → seleniumbase-4.33.3.dist-info}/METADATA +2 -2
- {seleniumbase-4.33.1.dist-info → seleniumbase-4.33.3.dist-info}/RECORD +12 -12
- {seleniumbase-4.33.1.dist-info → seleniumbase-4.33.3.dist-info}/LICENSE +0 -0
- {seleniumbase-4.33.1.dist-info → seleniumbase-4.33.3.dist-info}/WHEEL +0 -0
- {seleniumbase-4.33.1.dist-info → seleniumbase-4.33.3.dist-info}/entry_points.txt +0 -0
- {seleniumbase-4.33.1.dist-info → seleniumbase-4.33.3.dist-info}/top_level.txt +0 -0
seleniumbase/__version__.py
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
# seleniumbase package
|
2
|
-
__version__ = "4.33.
|
2
|
+
__version__ = "4.33.3"
|
@@ -606,6 +606,9 @@ def uc_open_with_cdp_mode(driver, url=None):
|
|
606
606
|
cdp.click_nth_element = CDPM.click_nth_element
|
607
607
|
cdp.click_nth_visible_element = CDPM.click_nth_visible_element
|
608
608
|
cdp.click_link = CDPM.click_link
|
609
|
+
cdp.go_back = CDPM.go_back
|
610
|
+
cdp.go_forward = CDPM.go_forward
|
611
|
+
cdp.get_navigation_history = CDPM.get_navigation_history
|
609
612
|
cdp.tile_windows = CDPM.tile_windows
|
610
613
|
cdp.get_all_cookies = CDPM.get_all_cookies
|
611
614
|
cdp.set_all_cookies = CDPM.set_all_cookies
|
@@ -703,6 +706,10 @@ def uc_open_with_cdp_mode(driver, url=None):
|
|
703
706
|
cdp.assert_exact_text = CDPM.assert_exact_text
|
704
707
|
cdp.assert_true = CDPM.assert_true
|
705
708
|
cdp.assert_false = CDPM.assert_false
|
709
|
+
cdp.assert_equal = CDPM.assert_equal
|
710
|
+
cdp.assert_not_equal = CDPM.assert_not_equal
|
711
|
+
cdp.assert_in = CDPM.assert_in
|
712
|
+
cdp.assert_not_in = CDPM.assert_not_in
|
706
713
|
cdp.scroll_into_view = CDPM.scroll_into_view
|
707
714
|
cdp.scroll_to_y = CDPM.scroll_to_y
|
708
715
|
cdp.scroll_to_top = CDPM.scroll_to_top
|
@@ -1415,11 +1422,8 @@ def _uc_gui_handle_captcha_(driver, frame="iframe", ctype=None):
|
|
1415
1422
|
page_actions.switch_to_window(
|
1416
1423
|
driver, driver.current_window_handle, 2, uc_lock=False
|
1417
1424
|
)
|
1418
|
-
if (
|
1419
|
-
|
1420
|
-
and hasattr(pyautogui, "getActiveWindowTitle")
|
1421
|
-
):
|
1422
|
-
py_a_g_title = pyautogui.getActiveWindowTitle()
|
1425
|
+
if IS_WINDOWS and hasattr(pyautogui, "getActiveWindowTitle"):
|
1426
|
+
py_a_g_title = pyautogui.getActiveWindowTitle() or ""
|
1423
1427
|
window_title = driver.get_title()
|
1424
1428
|
if not py_a_g_title.startswith(window_title):
|
1425
1429
|
window_rect = driver.get_window_rect()
|
seleniumbase/core/sb_cdp.py
CHANGED
@@ -135,23 +135,10 @@ class CDPMethods():
|
|
135
135
|
self.__add_light_pause()
|
136
136
|
selector = self.__convert_to_css_if_xpath(selector)
|
137
137
|
early_failure = False
|
138
|
-
if (":contains(" in selector
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
self.loop.run_until_complete(
|
143
|
-
self.page.select(tag_name, timeout=timeout)
|
144
|
-
)
|
145
|
-
self.loop.run_until_complete(
|
146
|
-
self.page.find(text, timeout=timeout)
|
147
|
-
)
|
148
|
-
elements = []
|
149
|
-
with suppress(Exception):
|
150
|
-
elements = self.find_elements_by_text(text, tag_name=tag_name)
|
151
|
-
if elements:
|
152
|
-
return self.__add_sync_methods(elements[0])
|
153
|
-
else:
|
154
|
-
early_failure = True
|
138
|
+
if (":contains(") in selector:
|
139
|
+
selector, _ = page_utils.recalculate_selector(
|
140
|
+
selector, by="css selector", xp_ok=True
|
141
|
+
)
|
155
142
|
failure = False
|
156
143
|
try:
|
157
144
|
if early_failure:
|
@@ -302,6 +289,15 @@ class CDPMethods():
|
|
302
289
|
def click_link(self, link_text):
|
303
290
|
self.find_elements_by_text(link_text, "a")[0].click()
|
304
291
|
|
292
|
+
def go_back(self):
|
293
|
+
self.loop.run_until_complete(self.page.back())
|
294
|
+
|
295
|
+
def go_forward(self):
|
296
|
+
self.loop.run_until_complete(self.page.forward())
|
297
|
+
|
298
|
+
def get_navigation_history(self):
|
299
|
+
return self.loop.run_until_complete(self.page.get_navigation_history())
|
300
|
+
|
305
301
|
def __clear_input(self, element):
|
306
302
|
return (
|
307
303
|
self.loop.run_until_complete(element.clear_input_async())
|
@@ -726,12 +722,16 @@ class CDPMethods():
|
|
726
722
|
|
727
723
|
def evaluate(self, expression):
|
728
724
|
"""Run a JavaScript expression and return the result."""
|
725
|
+
if expression.startswith("return "):
|
726
|
+
expression = expression[len("return "):]
|
729
727
|
return self.loop.run_until_complete(
|
730
728
|
self.page.evaluate(expression)
|
731
729
|
)
|
732
730
|
|
733
731
|
def js_dumps(self, obj_name):
|
734
732
|
"""Similar to evaluate(), but for dictionary results."""
|
733
|
+
if obj_name.startswith("return "):
|
734
|
+
obj_name = obj_name[len("return "):]
|
735
735
|
return self.loop.run_until_complete(
|
736
736
|
self.page.js_dumps(obj_name)
|
737
737
|
)
|
@@ -1648,11 +1648,11 @@ class CDPMethods():
|
|
1648
1648
|
text = text.strip()
|
1649
1649
|
element = None
|
1650
1650
|
try:
|
1651
|
-
element = self.
|
1651
|
+
element = self.find_element(selector, timeout=timeout)
|
1652
1652
|
except Exception:
|
1653
1653
|
raise Exception("Element {%s} not found!" % selector)
|
1654
1654
|
for i in range(30):
|
1655
|
-
if
|
1655
|
+
if text in element.text_all:
|
1656
1656
|
return True
|
1657
1657
|
time.sleep(0.1)
|
1658
1658
|
raise Exception(
|
@@ -1683,11 +1683,27 @@ class CDPMethods():
|
|
1683
1683
|
|
1684
1684
|
def assert_true(self, expression):
|
1685
1685
|
if not expression:
|
1686
|
-
raise AssertionError("%s is not true")
|
1686
|
+
raise AssertionError("%s is not true" % expression)
|
1687
1687
|
|
1688
1688
|
def assert_false(self, expression):
|
1689
1689
|
if expression:
|
1690
|
-
raise AssertionError("%s is not false")
|
1690
|
+
raise AssertionError("%s is not false" % expression)
|
1691
|
+
|
1692
|
+
def assert_equal(self, first, second):
|
1693
|
+
if first != second:
|
1694
|
+
raise AssertionError("%s is not equal to %s" % (first, second))
|
1695
|
+
|
1696
|
+
def assert_not_equal(self, first, second):
|
1697
|
+
if first == second:
|
1698
|
+
raise AssertionError("%s is equal to %s" % (first, second))
|
1699
|
+
|
1700
|
+
def assert_in(self, first, second):
|
1701
|
+
if first not in second:
|
1702
|
+
raise AssertionError("%s is not in %s" % (first, second))
|
1703
|
+
|
1704
|
+
def assert_not_in(self, first, second):
|
1705
|
+
if first in second:
|
1706
|
+
raise AssertionError("%s is in %s" % (first, second))
|
1691
1707
|
|
1692
1708
|
def scroll_into_view(self, selector):
|
1693
1709
|
self.find_element(selector).scroll_into_view()
|
@@ -392,7 +392,7 @@ class BaseCase(unittest.TestCase):
|
|
392
392
|
original_by = by
|
393
393
|
selector, by = self.__recalculate_selector(selector, by)
|
394
394
|
if self.__is_cdp_swap_needed():
|
395
|
-
self.cdp.click(selector)
|
395
|
+
self.cdp.click(selector, timeout=timeout)
|
396
396
|
return
|
397
397
|
if delay and (type(delay) in [int, float]) and delay > 0:
|
398
398
|
time.sleep(delay)
|
@@ -885,7 +885,7 @@ class BaseCase(unittest.TestCase):
|
|
885
885
|
timeout = self.__get_new_timeout(timeout)
|
886
886
|
selector, by = self.__recalculate_selector(selector, by)
|
887
887
|
if self.__is_cdp_swap_needed():
|
888
|
-
self.cdp.type(selector, text)
|
888
|
+
self.cdp.type(selector, text, timeout=timeout)
|
889
889
|
return
|
890
890
|
if self.__is_shadow_selector(selector):
|
891
891
|
self.__shadow_type(selector, text, timeout)
|
@@ -1112,7 +1112,7 @@ class BaseCase(unittest.TestCase):
|
|
1112
1112
|
def press_keys(self, selector, text, by="css selector", timeout=None):
|
1113
1113
|
"""Use send_keys() to press one key at a time."""
|
1114
1114
|
if self.__is_cdp_swap_needed():
|
1115
|
-
self.cdp.press_keys(selector, text)
|
1115
|
+
self.cdp.press_keys(selector, text, timeout=timeout)
|
1116
1116
|
return
|
1117
1117
|
self.wait_for_ready_state_complete()
|
1118
1118
|
element = self.wait_for_element_present(
|
@@ -1323,6 +1323,9 @@ class BaseCase(unittest.TestCase):
|
|
1323
1323
|
|
1324
1324
|
def go_back(self):
|
1325
1325
|
self.__check_scope()
|
1326
|
+
if self.__is_cdp_swap_needed():
|
1327
|
+
self.cdp.go_back()
|
1328
|
+
return
|
1326
1329
|
if hasattr(self, "recorder_mode") and self.recorder_mode:
|
1327
1330
|
self.save_recorded_actions()
|
1328
1331
|
pre_action_url = None
|
@@ -1348,6 +1351,9 @@ class BaseCase(unittest.TestCase):
|
|
1348
1351
|
|
1349
1352
|
def go_forward(self):
|
1350
1353
|
self.__check_scope()
|
1354
|
+
if self.__is_cdp_swap_needed():
|
1355
|
+
self.cdp.go_forward()
|
1356
|
+
return
|
1351
1357
|
if hasattr(self, "recorder_mode") and self.recorder_mode:
|
1352
1358
|
self.save_recorded_actions()
|
1353
1359
|
self.__last_page_load_url = None
|
@@ -1597,7 +1603,7 @@ class BaseCase(unittest.TestCase):
|
|
1597
1603
|
"""This method clicks link text on a page."""
|
1598
1604
|
self.__check_scope()
|
1599
1605
|
if self.__is_cdp_swap_needed():
|
1600
|
-
self.cdp.find_element(link_text).click()
|
1606
|
+
self.cdp.find_element(link_text, timeout=timeout).click()
|
1601
1607
|
return
|
1602
1608
|
self.__skip_if_esc()
|
1603
1609
|
if not timeout:
|
@@ -1732,6 +1738,9 @@ class BaseCase(unittest.TestCase):
|
|
1732
1738
|
if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT:
|
1733
1739
|
timeout = self.__get_new_timeout(timeout)
|
1734
1740
|
partial_link_text = self.__get_type_checked_text(partial_link_text)
|
1741
|
+
if self.__is_cdp_swap_needed():
|
1742
|
+
self.cdp.find_element(partial_link_text, timeout=timeout).click()
|
1743
|
+
return
|
1735
1744
|
if not self.is_partial_link_text_present(partial_link_text):
|
1736
1745
|
self.wait_for_partial_link_text_present(
|
1737
1746
|
partial_link_text, timeout=timeout
|
@@ -3380,6 +3389,8 @@ class BaseCase(unittest.TestCase):
|
|
3380
3389
|
|
3381
3390
|
def execute_script(self, script, *args, **kwargs):
|
3382
3391
|
self.__check_scope()
|
3392
|
+
if self.__is_cdp_swap_needed():
|
3393
|
+
return self.cdp.evaluate(script)
|
3383
3394
|
self._check_browser()
|
3384
3395
|
return self.driver.execute_script(script, *args, **kwargs)
|
3385
3396
|
|
@@ -6308,7 +6319,7 @@ class BaseCase(unittest.TestCase):
|
|
6308
6319
|
If "all_matches" is False, only the first match is clicked.
|
6309
6320
|
If "scroll" is False, won't scroll unless running in Demo Mode."""
|
6310
6321
|
if self.__is_cdp_swap_needed():
|
6311
|
-
self.cdp.click(selector)
|
6322
|
+
self.cdp.click(selector, timeout=timeout)
|
6312
6323
|
return
|
6313
6324
|
self.wait_for_ready_state_complete()
|
6314
6325
|
if not timeout or timeout is True:
|
@@ -8131,6 +8142,8 @@ class BaseCase(unittest.TestCase):
|
|
8131
8142
|
def is_chromium(self):
|
8132
8143
|
"""Return True if the browser is Chrome or Edge."""
|
8133
8144
|
self.__check_scope()
|
8145
|
+
if self.__is_cdp_swap_needed():
|
8146
|
+
return True
|
8134
8147
|
chromium = False
|
8135
8148
|
if (
|
8136
8149
|
"chrome" in self.driver.capabilities
|
@@ -8245,7 +8258,7 @@ class BaseCase(unittest.TestCase):
|
|
8245
8258
|
timeout = settings.SMALL_TIMEOUT
|
8246
8259
|
if self.__is_cdp_swap_needed():
|
8247
8260
|
mfa_code = self.get_mfa_code(totp_key)
|
8248
|
-
self.cdp.type(selector, mfa_code + "\n")
|
8261
|
+
self.cdp.type(selector, mfa_code + "\n", timeout=timeout)
|
8249
8262
|
return
|
8250
8263
|
self.wait_for_element_visible(selector, by=by, timeout=timeout)
|
8251
8264
|
if self.recorder_mode and self.__current_url_is_recordable():
|
@@ -9003,7 +9016,7 @@ class BaseCase(unittest.TestCase):
|
|
9003
9016
|
original_selector = selector
|
9004
9017
|
selector, by = self.__recalculate_selector(selector, by)
|
9005
9018
|
if self.__is_cdp_swap_needed():
|
9006
|
-
return self.cdp.select(selector)
|
9019
|
+
return self.cdp.select(selector, timeout=timeout)
|
9007
9020
|
if self.__is_shadow_selector(selector):
|
9008
9021
|
return self.__get_shadow_element(selector, timeout)
|
9009
9022
|
return page_actions.wait_for_element_visible(
|
@@ -9026,7 +9039,7 @@ class BaseCase(unittest.TestCase):
|
|
9026
9039
|
original_selector = selector
|
9027
9040
|
selector, by = self.__recalculate_selector(selector, by)
|
9028
9041
|
if self.__is_cdp_swap_needed():
|
9029
|
-
return self.cdp.select(selector)
|
9042
|
+
return self.cdp.select(selector, timeout=timeout)
|
9030
9043
|
elif self.__is_shadow_selector(selector):
|
9031
9044
|
# If a shadow selector, use visible instead of clickable
|
9032
9045
|
return self.__wait_for_shadow_element_visible(selector, timeout)
|
@@ -9427,7 +9440,7 @@ class BaseCase(unittest.TestCase):
|
|
9427
9440
|
original_selector = selector
|
9428
9441
|
selector, by = self.__recalculate_selector(selector, by)
|
9429
9442
|
if self.__is_cdp_swap_needed():
|
9430
|
-
return self.cdp.select(selector)
|
9443
|
+
return self.cdp.select(selector, timeout=timeout)
|
9431
9444
|
elif self.__is_shadow_selector(selector):
|
9432
9445
|
return self.__wait_for_shadow_element_present(selector, timeout)
|
9433
9446
|
return page_actions.wait_for_element_present(
|
@@ -9449,7 +9462,7 @@ class BaseCase(unittest.TestCase):
|
|
9449
9462
|
original_selector = selector
|
9450
9463
|
selector, by = self.__recalculate_selector(selector, by)
|
9451
9464
|
if self.__is_cdp_swap_needed():
|
9452
|
-
return self.cdp.select(selector)
|
9465
|
+
return self.cdp.select(selector, timeout=timeout)
|
9453
9466
|
if self.recorder_mode and self.__current_url_is_recordable():
|
9454
9467
|
if self.get_session_storage_item("pause_recorder") == "no":
|
9455
9468
|
if by == By.XPATH:
|
@@ -9492,7 +9505,7 @@ class BaseCase(unittest.TestCase):
|
|
9492
9505
|
timeout = self.__get_new_timeout(timeout)
|
9493
9506
|
css_selector = self.convert_to_css_selector(selector, by=by)
|
9494
9507
|
if self.__is_cdp_swap_needed():
|
9495
|
-
return self.cdp.select(css_selector)
|
9508
|
+
return self.cdp.select(css_selector, timeout=timeout)
|
9496
9509
|
return js_utils.wait_for_css_query_selector(
|
9497
9510
|
self.driver, css_selector, timeout
|
9498
9511
|
)
|
@@ -9713,7 +9726,7 @@ class BaseCase(unittest.TestCase):
|
|
9713
9726
|
text = self.__get_type_checked_text(text)
|
9714
9727
|
selector, by = self.__recalculate_selector(selector, by)
|
9715
9728
|
if self.__is_cdp_swap_needed():
|
9716
|
-
return self.cdp.find_element(selector)
|
9729
|
+
return self.cdp.find_element(selector, timeout=timeout)
|
9717
9730
|
elif self.__is_shadow_selector(selector):
|
9718
9731
|
return self.__wait_for_shadow_text_visible(text, selector, timeout)
|
9719
9732
|
return page_actions.wait_for_text_visible(
|
@@ -10093,7 +10106,7 @@ class BaseCase(unittest.TestCase):
|
|
10093
10106
|
if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT:
|
10094
10107
|
timeout = self.__get_new_timeout(timeout)
|
10095
10108
|
if self.__is_cdp_swap_needed():
|
10096
|
-
self.cdp.find_element(link_text)
|
10109
|
+
self.cdp.find_element(link_text, timeout=timeout)
|
10097
10110
|
return
|
10098
10111
|
self.wait_for_link_text_visible(link_text, timeout=timeout)
|
10099
10112
|
if self.demo_mode:
|
@@ -14,6 +14,12 @@ from seleniumbase.fixtures import shared_utils
|
|
14
14
|
from seleniumbase.fixtures import xpath_to_css
|
15
15
|
|
16
16
|
|
17
|
+
def execute_script(driver, script, *args, **kwargs):
|
18
|
+
if shared_utils.is_cdp_swap_needed(driver):
|
19
|
+
return driver.cdp.evaluate(script)
|
20
|
+
return driver.execute_script(script, *args, **kwargs)
|
21
|
+
|
22
|
+
|
17
23
|
def wait_for_ready_state_complete(driver, timeout=settings.LARGE_TIMEOUT):
|
18
24
|
"""The DOM (Document Object Model) has a property called "readyState".
|
19
25
|
When the value of this becomes "complete", page resources are considered
|
@@ -31,7 +37,7 @@ def wait_for_ready_state_complete(driver, timeout=settings.LARGE_TIMEOUT):
|
|
31
37
|
if sb_config.time_limit and not sb_config.recorder_mode:
|
32
38
|
shared_utils.check_if_time_limit_exceeded()
|
33
39
|
try:
|
34
|
-
ready_state =
|
40
|
+
ready_state = execute_script(driver, "return document.readyState;")
|
35
41
|
except WebDriverException:
|
36
42
|
# Bug fix for: [Permission denied to access property "document"]
|
37
43
|
time.sleep(0.03)
|
@@ -57,7 +63,7 @@ def wait_for_angularjs(driver, timeout=settings.LARGE_TIMEOUT, **kwargs):
|
|
57
63
|
return
|
58
64
|
with suppress(Exception):
|
59
65
|
# This closes pop-up alerts
|
60
|
-
|
66
|
+
execute_script(driver, "")
|
61
67
|
if (
|
62
68
|
(hasattr(driver, "_is_using_uc") and driver._is_using_uc)
|
63
69
|
or not settings.WAIT_FOR_ANGULARJS
|
@@ -126,7 +132,7 @@ def convert_to_css_selector(selector, by=By.CSS_SELECTOR):
|
|
126
132
|
|
127
133
|
def is_html_inspector_activated(driver):
|
128
134
|
try:
|
129
|
-
|
135
|
+
execute_script(driver, "HTMLInspector;") # Fails if not defined
|
130
136
|
return True
|
131
137
|
except Exception:
|
132
138
|
return False
|
@@ -134,7 +140,7 @@ def is_html_inspector_activated(driver):
|
|
134
140
|
|
135
141
|
def is_jquery_activated(driver):
|
136
142
|
try:
|
137
|
-
|
143
|
+
execute_script(driver, "jQuery('html');") # Fails if jq is not defined
|
138
144
|
return True
|
139
145
|
except Exception:
|
140
146
|
return False
|
@@ -148,7 +154,7 @@ def wait_for_jquery_active(driver, timeout=None):
|
|
148
154
|
for x in range(timeout):
|
149
155
|
# jQuery needs a small amount of time to activate.
|
150
156
|
try:
|
151
|
-
|
157
|
+
execute_script(driver, "jQuery('html');")
|
152
158
|
wait_for_ready_state_complete(driver)
|
153
159
|
wait_for_angularjs(driver)
|
154
160
|
return
|
@@ -188,7 +194,7 @@ def activate_jquery(driver):
|
|
188
194
|
# This method is needed because jQuery is not always defined on web sites.
|
189
195
|
with suppress(Exception):
|
190
196
|
# Let's first find out if jQuery is already defined.
|
191
|
-
|
197
|
+
execute_script(driver, "jQuery('html');")
|
192
198
|
# Since that command worked, jQuery is defined. Let's return.
|
193
199
|
return
|
194
200
|
# jQuery is not defined. It will be loaded in the next part.
|
@@ -197,7 +203,7 @@ def activate_jquery(driver):
|
|
197
203
|
for x in range(36):
|
198
204
|
# jQuery needs a small amount of time to activate.
|
199
205
|
try:
|
200
|
-
|
206
|
+
execute_script(driver, "jQuery('html');")
|
201
207
|
return
|
202
208
|
except Exception:
|
203
209
|
if x == 18:
|
@@ -243,7 +249,8 @@ def is_in_frame(driver):
|
|
243
249
|
# Returns False if the driver was on default content.
|
244
250
|
if shared_utils.is_cdp_swap_needed(driver):
|
245
251
|
return False
|
246
|
-
in_basic_frame =
|
252
|
+
in_basic_frame = execute_script(
|
253
|
+
driver,
|
247
254
|
"""
|
248
255
|
var frame = window.frameElement;
|
249
256
|
if (frame) {
|
@@ -254,7 +261,7 @@ def is_in_frame(driver):
|
|
254
261
|
}
|
255
262
|
"""
|
256
263
|
)
|
257
|
-
location_href =
|
264
|
+
location_href = execute_script(driver, """return window.location.href;""")
|
258
265
|
in_external_frame = False
|
259
266
|
if driver.current_url != location_href:
|
260
267
|
in_external_frame = True
|
@@ -268,11 +275,11 @@ def safe_execute_script(driver, script):
|
|
268
275
|
it's important that the jQuery library has been loaded first.
|
269
276
|
This method will load jQuery if it wasn't already loaded."""
|
270
277
|
try:
|
271
|
-
|
278
|
+
execute_script(driver, script)
|
272
279
|
except Exception:
|
273
280
|
# The likely reason this fails is because: "jQuery is not defined"
|
274
281
|
activate_jquery(driver) # It's a good thing we can define it here
|
275
|
-
|
282
|
+
execute_script(driver, script)
|
276
283
|
|
277
284
|
|
278
285
|
def remove_extra_slashes(selector):
|
@@ -328,7 +335,7 @@ def wait_for_css_query_selector(
|
|
328
335
|
stop_ms = start_ms + (timeout * 1000.0)
|
329
336
|
for x in range(int(timeout * 10)):
|
330
337
|
try:
|
331
|
-
element =
|
338
|
+
element = execute_script(driver, script)
|
332
339
|
if element:
|
333
340
|
return element
|
334
341
|
except Exception:
|
@@ -359,7 +366,7 @@ def swap_selector_and_by_if_reversed(selector, by):
|
|
359
366
|
def call_me_later(driver, script, ms):
|
360
367
|
"""Call script after ms passed."""
|
361
368
|
call = "function() {%s}" % script
|
362
|
-
|
369
|
+
execute_script(driver, "window.setTimeout(%s, %s);" % (call, ms))
|
363
370
|
|
364
371
|
|
365
372
|
def highlight(driver, selector, by="css selector", loops=4):
|
@@ -387,7 +394,7 @@ def highlight(driver, selector, by="css selector", loops=4):
|
|
387
394
|
def highlight_with_js(driver, selector, loops=4, o_bs=""):
|
388
395
|
with suppress(Exception):
|
389
396
|
# This closes any pop-up alerts
|
390
|
-
|
397
|
+
execute_script(driver, "")
|
391
398
|
if selector == "html":
|
392
399
|
selector = "body"
|
393
400
|
selector_no_spaces = selector.replace(" ", "")
|
@@ -407,7 +414,7 @@ def highlight_with_js(driver, selector, loops=4, o_bs=""):
|
|
407
414
|
% selector
|
408
415
|
)
|
409
416
|
try:
|
410
|
-
|
417
|
+
execute_script(driver, script)
|
411
418
|
except Exception:
|
412
419
|
return
|
413
420
|
for n in range(loops):
|
@@ -417,7 +424,7 @@ def highlight_with_js(driver, selector, loops=4, o_bs=""):
|
|
417
424
|
% selector
|
418
425
|
)
|
419
426
|
try:
|
420
|
-
|
427
|
+
execute_script(driver, script)
|
421
428
|
except Exception:
|
422
429
|
return
|
423
430
|
time.sleep(0.0181)
|
@@ -427,7 +434,7 @@ def highlight_with_js(driver, selector, loops=4, o_bs=""):
|
|
427
434
|
% selector
|
428
435
|
)
|
429
436
|
try:
|
430
|
-
|
437
|
+
execute_script(driver, script)
|
431
438
|
except Exception:
|
432
439
|
return
|
433
440
|
time.sleep(0.0181)
|
@@ -437,7 +444,7 @@ def highlight_with_js(driver, selector, loops=4, o_bs=""):
|
|
437
444
|
% selector
|
438
445
|
)
|
439
446
|
try:
|
440
|
-
|
447
|
+
execute_script(driver, script)
|
441
448
|
except Exception:
|
442
449
|
return
|
443
450
|
time.sleep(0.0181)
|
@@ -447,7 +454,7 @@ def highlight_with_js(driver, selector, loops=4, o_bs=""):
|
|
447
454
|
% selector
|
448
455
|
)
|
449
456
|
try:
|
450
|
-
|
457
|
+
execute_script(driver, script)
|
451
458
|
except Exception:
|
452
459
|
return
|
453
460
|
time.sleep(0.0181)
|
@@ -457,7 +464,7 @@ def highlight_with_js(driver, selector, loops=4, o_bs=""):
|
|
457
464
|
% selector
|
458
465
|
)
|
459
466
|
try:
|
460
|
-
|
467
|
+
execute_script(driver, script)
|
461
468
|
except Exception:
|
462
469
|
return
|
463
470
|
time.sleep(0.0181)
|
@@ -467,7 +474,7 @@ def highlight_with_js(driver, selector, loops=4, o_bs=""):
|
|
467
474
|
% selector
|
468
475
|
)
|
469
476
|
try:
|
470
|
-
|
477
|
+
execute_script(driver, script)
|
471
478
|
except Exception:
|
472
479
|
return
|
473
480
|
time.sleep(0.0181)
|
@@ -477,7 +484,7 @@ def highlight_with_js(driver, selector, loops=4, o_bs=""):
|
|
477
484
|
o_bs,
|
478
485
|
)
|
479
486
|
try:
|
480
|
-
|
487
|
+
execute_script(driver, script)
|
481
488
|
except Exception:
|
482
489
|
return
|
483
490
|
|
@@ -485,13 +492,13 @@ def highlight_with_js(driver, selector, loops=4, o_bs=""):
|
|
485
492
|
def highlight_element_with_js(driver, element, loops=4, o_bs=""):
|
486
493
|
with suppress(Exception):
|
487
494
|
# This closes any pop-up alerts
|
488
|
-
|
495
|
+
execute_script(driver, "")
|
489
496
|
script = (
|
490
497
|
"""arguments[0].style.boxShadow =
|
491
498
|
'0px 0px 6px 6px rgba(128, 128, 128, 0.5)';"""
|
492
499
|
)
|
493
500
|
try:
|
494
|
-
|
501
|
+
execute_script(driver, script, element)
|
495
502
|
except Exception:
|
496
503
|
return
|
497
504
|
for n in range(loops):
|
@@ -500,7 +507,7 @@ def highlight_element_with_js(driver, element, loops=4, o_bs=""):
|
|
500
507
|
'0px 0px 6px 6px rgba(255, 0, 0, 1)';"""
|
501
508
|
)
|
502
509
|
try:
|
503
|
-
|
510
|
+
execute_script(driver, script, element)
|
504
511
|
except Exception:
|
505
512
|
return
|
506
513
|
time.sleep(0.0181)
|
@@ -509,7 +516,7 @@ def highlight_element_with_js(driver, element, loops=4, o_bs=""):
|
|
509
516
|
'0px 0px 6px 6px rgba(128, 0, 128, 1)';"""
|
510
517
|
)
|
511
518
|
try:
|
512
|
-
|
519
|
+
execute_script(driver, script, element)
|
513
520
|
except Exception:
|
514
521
|
return
|
515
522
|
time.sleep(0.0181)
|
@@ -518,7 +525,7 @@ def highlight_element_with_js(driver, element, loops=4, o_bs=""):
|
|
518
525
|
'0px 0px 6px 6px rgba(0, 0, 255, 1)';"""
|
519
526
|
)
|
520
527
|
try:
|
521
|
-
|
528
|
+
execute_script(driver, script, element)
|
522
529
|
except Exception:
|
523
530
|
return
|
524
531
|
time.sleep(0.0181)
|
@@ -527,7 +534,7 @@ def highlight_element_with_js(driver, element, loops=4, o_bs=""):
|
|
527
534
|
'0px 0px 6px 6px rgba(0, 255, 0, 1)';"""
|
528
535
|
)
|
529
536
|
try:
|
530
|
-
|
537
|
+
execute_script(driver, script, element)
|
531
538
|
except Exception:
|
532
539
|
return
|
533
540
|
time.sleep(0.0181)
|
@@ -536,7 +543,7 @@ def highlight_element_with_js(driver, element, loops=4, o_bs=""):
|
|
536
543
|
'0px 0px 6px 6px rgba(128, 128, 0, 1)';"""
|
537
544
|
)
|
538
545
|
try:
|
539
|
-
|
546
|
+
execute_script(driver, script, element)
|
540
547
|
except Exception:
|
541
548
|
return
|
542
549
|
time.sleep(0.0181)
|
@@ -545,13 +552,13 @@ def highlight_element_with_js(driver, element, loops=4, o_bs=""):
|
|
545
552
|
'0px 0px 6px 6px rgba(128, 0, 128, 1)';"""
|
546
553
|
)
|
547
554
|
try:
|
548
|
-
|
555
|
+
execute_script(driver, script, element)
|
549
556
|
except Exception:
|
550
557
|
return
|
551
558
|
time.sleep(0.0181)
|
552
559
|
script = """arguments[0].style.boxShadow = '%s';""" % (o_bs)
|
553
560
|
try:
|
554
|
-
|
561
|
+
execute_script(driver, script, element)
|
555
562
|
except Exception:
|
556
563
|
return
|
557
564
|
|
@@ -559,7 +566,7 @@ def highlight_element_with_js(driver, element, loops=4, o_bs=""):
|
|
559
566
|
def highlight_with_jquery(driver, selector, loops=4, o_bs=""):
|
560
567
|
with suppress(Exception):
|
561
568
|
# This closes any pop-up alerts
|
562
|
-
|
569
|
+
execute_script(driver, "")
|
563
570
|
if selector == "html":
|
564
571
|
selector = "body"
|
565
572
|
selector_no_spaces = selector.replace(" ", "")
|
@@ -585,45 +592,45 @@ def highlight_with_jquery(driver, selector, loops=4, o_bs=""):
|
|
585
592
|
'0px 0px 6px 6px rgba(255, 0, 0, 1)');"""
|
586
593
|
% selector
|
587
594
|
)
|
588
|
-
|
595
|
+
execute_script(driver, script)
|
589
596
|
time.sleep(0.0181)
|
590
597
|
script = (
|
591
598
|
"""jQuery('%s').css('box-shadow',
|
592
599
|
'0px 0px 6px 6px rgba(128, 0, 128, 1)');"""
|
593
600
|
% selector
|
594
601
|
)
|
595
|
-
|
602
|
+
execute_script(driver, script)
|
596
603
|
time.sleep(0.0181)
|
597
604
|
script = (
|
598
605
|
"""jQuery('%s').css('box-shadow',
|
599
606
|
'0px 0px 6px 6px rgba(0, 0, 255, 1)');"""
|
600
607
|
% selector
|
601
608
|
)
|
602
|
-
|
609
|
+
execute_script(driver, script)
|
603
610
|
time.sleep(0.0181)
|
604
611
|
script = (
|
605
612
|
"""jQuery('%s').css('box-shadow',
|
606
613
|
'0px 0px 6px 6px rgba(0, 255, 0, 1)');"""
|
607
614
|
% selector
|
608
615
|
)
|
609
|
-
|
616
|
+
execute_script(driver, script)
|
610
617
|
time.sleep(0.0181)
|
611
618
|
script = (
|
612
619
|
"""jQuery('%s').css('box-shadow',
|
613
620
|
'0px 0px 6px 6px rgba(128, 128, 0, 1)');"""
|
614
621
|
% selector
|
615
622
|
)
|
616
|
-
|
623
|
+
execute_script(driver, script)
|
617
624
|
time.sleep(0.0181)
|
618
625
|
script = (
|
619
626
|
"""jQuery('%s').css('box-shadow',
|
620
627
|
'0px 0px 6px 6px rgba(128, 0, 128, 1)');"""
|
621
628
|
% selector
|
622
629
|
)
|
623
|
-
|
630
|
+
execute_script(driver, script)
|
624
631
|
time.sleep(0.0181)
|
625
632
|
script = """jQuery('%s').css('box-shadow', '%s');""" % (selector, o_bs)
|
626
|
-
|
633
|
+
execute_script(driver, script)
|
627
634
|
|
628
635
|
|
629
636
|
def add_css_link(driver, css_link):
|
@@ -638,7 +645,7 @@ def add_css_link(driver, css_link):
|
|
638
645
|
}
|
639
646
|
injectCSS("%s");"""
|
640
647
|
css_link = escape_quotes_if_needed(css_link)
|
641
|
-
|
648
|
+
execute_script(driver, script_to_add_css % css_link)
|
642
649
|
|
643
650
|
|
644
651
|
def add_js_link(driver, js_link):
|
@@ -654,7 +661,7 @@ def add_js_link(driver, js_link):
|
|
654
661
|
}
|
655
662
|
injectJS("%s");"""
|
656
663
|
js_link = escape_quotes_if_needed(js_link)
|
657
|
-
|
664
|
+
execute_script(driver, script_to_add_js % js_link)
|
658
665
|
|
659
666
|
|
660
667
|
def add_css_style(driver, css_style):
|
@@ -668,7 +675,7 @@ def add_css_style(driver, css_style):
|
|
668
675
|
injectStyle("%s");"""
|
669
676
|
css_style = css_style.replace("\n", "")
|
670
677
|
css_style = escape_quotes_if_needed(css_style)
|
671
|
-
|
678
|
+
execute_script(driver, add_css_style_script % css_style)
|
672
679
|
|
673
680
|
|
674
681
|
def add_js_code_from_link(driver, js_link):
|
@@ -685,7 +692,7 @@ def add_js_code_from_link(driver, js_link):
|
|
685
692
|
)
|
686
693
|
js_code = js_code.replace("\n", " ")
|
687
694
|
js_code = escape_quotes_if_needed(js_code)
|
688
|
-
|
695
|
+
execute_script(driver, add_js_code_script % js_code)
|
689
696
|
|
690
697
|
|
691
698
|
def add_js_code(driver, js_code):
|
@@ -699,7 +706,7 @@ def add_js_code(driver, js_code):
|
|
699
706
|
)
|
700
707
|
js_code = js_code.replace("\n", " ")
|
701
708
|
js_code = escape_quotes_if_needed(js_code)
|
702
|
-
|
709
|
+
execute_script(driver, add_js_code_script % js_code)
|
703
710
|
|
704
711
|
|
705
712
|
def add_meta_tag(driver, http_equiv=None, content=None):
|
@@ -720,12 +727,12 @@ def add_meta_tag(driver, http_equiv=None, content=None):
|
|
720
727
|
http_equiv,
|
721
728
|
content,
|
722
729
|
)
|
723
|
-
|
730
|
+
execute_script(driver, script_to_add_meta)
|
724
731
|
|
725
732
|
|
726
733
|
def is_jquery_confirm_activated(driver):
|
727
734
|
try:
|
728
|
-
|
735
|
+
execute_script(driver, "jconfirm;") # Fails if jconfirm is not defined
|
729
736
|
return True
|
730
737
|
except Exception:
|
731
738
|
return False
|
@@ -748,7 +755,7 @@ def activate_jquery_confirm(driver):
|
|
748
755
|
add_css_link(driver, jq_confirm_css)
|
749
756
|
add_js_link(driver, jq_confirm_js)
|
750
757
|
try:
|
751
|
-
|
758
|
+
execute_script(driver, "jconfirm;")
|
752
759
|
wait_for_ready_state_complete(driver)
|
753
760
|
wait_for_angularjs(driver)
|
754
761
|
return
|
@@ -774,7 +781,7 @@ def activate_html_inspector(driver):
|
|
774
781
|
for x in range(25):
|
775
782
|
# HTML-Inspector needs a small amount of time to load & activate.
|
776
783
|
try:
|
777
|
-
|
784
|
+
execute_script(driver, "HTMLInspector;")
|
778
785
|
wait_for_ready_state_complete(driver)
|
779
786
|
wait_for_angularjs(driver)
|
780
787
|
return
|
@@ -824,7 +831,8 @@ def activate_messenger(driver):
|
|
824
831
|
for x in range(10):
|
825
832
|
# Messenger needs a small amount of time to load & activate.
|
826
833
|
try:
|
827
|
-
result =
|
834
|
+
result = execute_script(
|
835
|
+
driver,
|
828
836
|
""" if (typeof Messenger === 'undefined') { return "U"; } """
|
829
837
|
)
|
830
838
|
if result == "U":
|
@@ -835,7 +843,7 @@ def activate_messenger(driver):
|
|
835
843
|
except Exception:
|
836
844
|
time.sleep(0.02)
|
837
845
|
try:
|
838
|
-
|
846
|
+
execute_script(driver, msg_style)
|
839
847
|
add_js_link(driver, msgr_theme_flat_js)
|
840
848
|
add_js_link(driver, msgr_theme_future_js)
|
841
849
|
wait_for_ready_state_complete(driver)
|
@@ -892,13 +900,13 @@ def set_messenger_theme(
|
|
892
900
|
% (max_messages, messenger_location, theme)
|
893
901
|
)
|
894
902
|
try:
|
895
|
-
|
903
|
+
execute_script(driver, msg_style)
|
896
904
|
except Exception:
|
897
905
|
time.sleep(0.03)
|
898
906
|
activate_messenger(driver)
|
899
907
|
time.sleep(0.15)
|
900
908
|
with suppress(Exception):
|
901
|
-
|
909
|
+
execute_script(driver, msg_style)
|
902
910
|
time.sleep(0.02)
|
903
911
|
time.sleep(0.05)
|
904
912
|
|
@@ -917,19 +925,19 @@ def post_message(driver, message, msg_dur=None, style="info"):
|
|
917
925
|
% (message, style, msg_dur)
|
918
926
|
)
|
919
927
|
try:
|
920
|
-
|
928
|
+
execute_script(driver, messenger_script)
|
921
929
|
except Exception:
|
922
930
|
activate_messenger(driver)
|
923
931
|
set_messenger_theme(driver)
|
924
932
|
try:
|
925
|
-
|
933
|
+
execute_script(driver, messenger_script)
|
926
934
|
except Exception:
|
927
935
|
time.sleep(0.17)
|
928
936
|
activate_messenger(driver)
|
929
937
|
time.sleep(0.17)
|
930
938
|
set_messenger_theme(driver)
|
931
939
|
time.sleep(0.27)
|
932
|
-
|
940
|
+
execute_script(driver, messenger_script)
|
933
941
|
|
934
942
|
|
935
943
|
def post_messenger_success_message(driver, message, msg_dur=None):
|
@@ -959,7 +967,7 @@ def post_messenger_error_message(driver, message, msg_dur=None):
|
|
959
967
|
def highlight_with_js_2(driver, message, selector, o_bs, msg_dur):
|
960
968
|
with suppress(Exception):
|
961
969
|
# This closes any pop-up alerts
|
962
|
-
|
970
|
+
execute_script(driver, "")
|
963
971
|
if selector == "html":
|
964
972
|
selector = "body"
|
965
973
|
selector_no_spaces = selector.replace(" ", "")
|
@@ -982,7 +990,7 @@ def highlight_with_js_2(driver, message, selector, o_bs, msg_dur):
|
|
982
990
|
% selector
|
983
991
|
)
|
984
992
|
try:
|
985
|
-
|
993
|
+
execute_script(driver, script)
|
986
994
|
except Exception:
|
987
995
|
return
|
988
996
|
time.sleep(0.0181)
|
@@ -992,7 +1000,7 @@ def highlight_with_js_2(driver, message, selector, o_bs, msg_dur):
|
|
992
1000
|
% selector
|
993
1001
|
)
|
994
1002
|
try:
|
995
|
-
|
1003
|
+
execute_script(driver, script)
|
996
1004
|
except Exception:
|
997
1005
|
return
|
998
1006
|
time.sleep(0.0181)
|
@@ -1002,7 +1010,7 @@ def highlight_with_js_2(driver, message, selector, o_bs, msg_dur):
|
|
1002
1010
|
% selector
|
1003
1011
|
)
|
1004
1012
|
try:
|
1005
|
-
|
1013
|
+
execute_script(driver, script)
|
1006
1014
|
except Exception:
|
1007
1015
|
return
|
1008
1016
|
time.sleep(0.0181)
|
@@ -1012,7 +1020,7 @@ def highlight_with_js_2(driver, message, selector, o_bs, msg_dur):
|
|
1012
1020
|
% selector
|
1013
1021
|
)
|
1014
1022
|
try:
|
1015
|
-
|
1023
|
+
execute_script(driver, script)
|
1016
1024
|
except Exception:
|
1017
1025
|
return
|
1018
1026
|
time.sleep(0.0181)
|
@@ -1022,7 +1030,7 @@ def highlight_with_js_2(driver, message, selector, o_bs, msg_dur):
|
|
1022
1030
|
% selector
|
1023
1031
|
)
|
1024
1032
|
try:
|
1025
|
-
|
1033
|
+
execute_script(driver, script)
|
1026
1034
|
except Exception:
|
1027
1035
|
return
|
1028
1036
|
time.sleep(0.0181)
|
@@ -1034,7 +1042,7 @@ def highlight_with_js_2(driver, message, selector, o_bs, msg_dur):
|
|
1034
1042
|
o_bs,
|
1035
1043
|
)
|
1036
1044
|
try:
|
1037
|
-
|
1045
|
+
execute_script(driver, script)
|
1038
1046
|
except Exception:
|
1039
1047
|
return
|
1040
1048
|
|
@@ -1042,13 +1050,13 @@ def highlight_with_js_2(driver, message, selector, o_bs, msg_dur):
|
|
1042
1050
|
def highlight_element_with_js_2(driver, message, element, o_bs, msg_dur):
|
1043
1051
|
with suppress(Exception):
|
1044
1052
|
# This closes any pop-up alerts
|
1045
|
-
|
1053
|
+
execute_script(driver, "")
|
1046
1054
|
script = (
|
1047
1055
|
"""arguments[0].style.boxShadow =
|
1048
1056
|
'0px 0px 6px 6px rgba(128, 128, 128, 0.5)';"""
|
1049
1057
|
)
|
1050
1058
|
try:
|
1051
|
-
|
1059
|
+
execute_script(driver, script, element)
|
1052
1060
|
except Exception:
|
1053
1061
|
return
|
1054
1062
|
time.sleep(0.0181)
|
@@ -1057,7 +1065,7 @@ def highlight_element_with_js_2(driver, message, element, o_bs, msg_dur):
|
|
1057
1065
|
'0px 0px 6px 6px rgba(205, 30, 0, 1)';"""
|
1058
1066
|
)
|
1059
1067
|
try:
|
1060
|
-
|
1068
|
+
execute_script(driver, script, element)
|
1061
1069
|
except Exception:
|
1062
1070
|
return
|
1063
1071
|
time.sleep(0.0181)
|
@@ -1066,7 +1074,7 @@ def highlight_element_with_js_2(driver, message, element, o_bs, msg_dur):
|
|
1066
1074
|
'0px 0px 6px 6px rgba(128, 0, 128, 1)';"""
|
1067
1075
|
)
|
1068
1076
|
try:
|
1069
|
-
|
1077
|
+
execute_script(driver, script, element)
|
1070
1078
|
except Exception:
|
1071
1079
|
return
|
1072
1080
|
time.sleep(0.0181)
|
@@ -1075,7 +1083,7 @@ def highlight_element_with_js_2(driver, message, element, o_bs, msg_dur):
|
|
1075
1083
|
'0px 0px 6px 6px rgba(50, 50, 128, 1)';"""
|
1076
1084
|
)
|
1077
1085
|
try:
|
1078
|
-
|
1086
|
+
execute_script(driver, script, element)
|
1079
1087
|
except Exception:
|
1080
1088
|
return
|
1081
1089
|
time.sleep(0.0181)
|
@@ -1084,7 +1092,7 @@ def highlight_element_with_js_2(driver, message, element, o_bs, msg_dur):
|
|
1084
1092
|
'0px 0px 6px 6px rgba(50, 205, 50, 1)';"""
|
1085
1093
|
)
|
1086
1094
|
try:
|
1087
|
-
|
1095
|
+
execute_script(driver, script, element)
|
1088
1096
|
except Exception:
|
1089
1097
|
return
|
1090
1098
|
time.sleep(0.0181)
|
@@ -1093,7 +1101,7 @@ def highlight_element_with_js_2(driver, message, element, o_bs, msg_dur):
|
|
1093
1101
|
post_messenger_success_message(driver, message, msg_dur)
|
1094
1102
|
script = """arguments[0].style.boxShadow = '%s';""" % (o_bs)
|
1095
1103
|
try:
|
1096
|
-
|
1104
|
+
execute_script(driver, script, element)
|
1097
1105
|
except Exception:
|
1098
1106
|
return
|
1099
1107
|
|
@@ -1131,7 +1139,7 @@ def highlight_with_jquery_2(driver, message, selector, o_bs, msg_dur):
|
|
1131
1139
|
% selector
|
1132
1140
|
)
|
1133
1141
|
try:
|
1134
|
-
|
1142
|
+
execute_script(driver, script)
|
1135
1143
|
except Exception:
|
1136
1144
|
return
|
1137
1145
|
time.sleep(0.0181)
|
@@ -1141,7 +1149,7 @@ def highlight_with_jquery_2(driver, message, selector, o_bs, msg_dur):
|
|
1141
1149
|
% selector
|
1142
1150
|
)
|
1143
1151
|
try:
|
1144
|
-
|
1152
|
+
execute_script(driver, script)
|
1145
1153
|
except Exception:
|
1146
1154
|
return
|
1147
1155
|
time.sleep(0.0181)
|
@@ -1151,7 +1159,7 @@ def highlight_with_jquery_2(driver, message, selector, o_bs, msg_dur):
|
|
1151
1159
|
% selector
|
1152
1160
|
)
|
1153
1161
|
try:
|
1154
|
-
|
1162
|
+
execute_script(driver, script)
|
1155
1163
|
except Exception:
|
1156
1164
|
return
|
1157
1165
|
time.sleep(0.0181)
|
@@ -1161,7 +1169,7 @@ def highlight_with_jquery_2(driver, message, selector, o_bs, msg_dur):
|
|
1161
1169
|
% selector
|
1162
1170
|
)
|
1163
1171
|
try:
|
1164
|
-
|
1172
|
+
execute_script(driver, script)
|
1165
1173
|
except Exception:
|
1166
1174
|
return
|
1167
1175
|
time.sleep(0.0181)
|
@@ -1172,7 +1180,7 @@ def highlight_with_jquery_2(driver, message, selector, o_bs, msg_dur):
|
|
1172
1180
|
|
1173
1181
|
script = """jQuery('%s').css('box-shadow', '%s');""" % (selector, o_bs)
|
1174
1182
|
try:
|
1175
|
-
|
1183
|
+
execute_script(driver, script)
|
1176
1184
|
except Exception:
|
1177
1185
|
return
|
1178
1186
|
|
@@ -1180,33 +1188,33 @@ def highlight_with_jquery_2(driver, message, selector, o_bs, msg_dur):
|
|
1180
1188
|
def get_active_element_css(driver):
|
1181
1189
|
from seleniumbase.js_code import active_css_js
|
1182
1190
|
|
1183
|
-
return
|
1191
|
+
return execute_script(driver, active_css_js.get_active_element_css)
|
1184
1192
|
|
1185
1193
|
|
1186
1194
|
def get_locale_code(driver):
|
1187
1195
|
script = "return navigator.language || navigator.languages[0];"
|
1188
|
-
return
|
1196
|
+
return execute_script(driver, script)
|
1189
1197
|
|
1190
1198
|
|
1191
1199
|
def get_screen_rect(driver):
|
1192
|
-
return
|
1200
|
+
return execute_script(driver, "return window.screen;")
|
1193
1201
|
|
1194
1202
|
|
1195
1203
|
def get_origin(driver):
|
1196
|
-
return
|
1204
|
+
return execute_script(driver, "return window.location.origin;")
|
1197
1205
|
|
1198
1206
|
|
1199
1207
|
def get_user_agent(driver):
|
1200
|
-
return
|
1208
|
+
return execute_script(driver, "return navigator.userAgent;")
|
1201
1209
|
|
1202
1210
|
|
1203
1211
|
def get_cookie_string(driver):
|
1204
|
-
return
|
1212
|
+
return execute_script(driver, "return document.cookie;")
|
1205
1213
|
|
1206
1214
|
|
1207
1215
|
def get_scroll_distance_to_element(driver, element):
|
1208
1216
|
try:
|
1209
|
-
scroll_position =
|
1217
|
+
scroll_position = execute_script(driver, "return window.scrollY;")
|
1210
1218
|
element_location = None
|
1211
1219
|
element_location = element.location["y"]
|
1212
1220
|
element_location = element_location - constants.Scroll.Y_OFFSET
|
@@ -1247,9 +1255,9 @@ def scroll_to_element(driver, element):
|
|
1247
1255
|
# The old jQuery scroll_script required by=By.CSS_SELECTOR
|
1248
1256
|
# scroll_script = "jQuery('%s')[0].scrollIntoView()" % selector
|
1249
1257
|
# This other scroll_script does not centralize the element
|
1250
|
-
#
|
1258
|
+
# execute_script(driver, "arguments[0].scrollIntoView();", element)
|
1251
1259
|
try:
|
1252
|
-
|
1260
|
+
execute_script(driver, scroll_script)
|
1253
1261
|
return True
|
1254
1262
|
except Exception:
|
1255
1263
|
return False
|
@@ -1260,7 +1268,7 @@ def slow_scroll_to_element(driver, element, *args, **kwargs):
|
|
1260
1268
|
# IE breaks on slow-scrolling. Do a fast scroll instead.
|
1261
1269
|
scroll_to_element(driver, element)
|
1262
1270
|
return
|
1263
|
-
scroll_position =
|
1271
|
+
scroll_position = execute_script(driver, "return window.scrollY;")
|
1264
1272
|
element_location_y = None
|
1265
1273
|
try:
|
1266
1274
|
element_location_y = element.location["y"]
|
@@ -1290,12 +1298,12 @@ def slow_scroll_to_element(driver, element, *args, **kwargs):
|
|
1290
1298
|
time.sleep(0.011)
|
1291
1299
|
new_position += step_value
|
1292
1300
|
scroll_script = "window.scrollTo(0, %s);" % new_position
|
1293
|
-
|
1301
|
+
execute_script(driver, scroll_script)
|
1294
1302
|
time.sleep(0.01)
|
1295
1303
|
scroll_script = "window.scrollTo(%s, %s);" % (
|
1296
1304
|
element_location_x_fix, element_location_y
|
1297
1305
|
)
|
1298
|
-
|
1306
|
+
execute_script(driver, scroll_script)
|
1299
1307
|
time.sleep(0.01)
|
1300
1308
|
if distance > 430 or distance < -300:
|
1301
1309
|
# Add small recovery time for long-distance slow-scrolling
|
@@ -636,6 +636,10 @@ class Tab(Connection):
|
|
636
636
|
"""History forward"""
|
637
637
|
await self.send(cdp.runtime.evaluate("window.history.forward()"))
|
638
638
|
|
639
|
+
async def get_navigation_history(self):
|
640
|
+
"""Get Navigation History"""
|
641
|
+
return await self.send(cdp.page.get_navigation_history())
|
642
|
+
|
639
643
|
async def reload(
|
640
644
|
self,
|
641
645
|
ignore_cache: Optional[bool] = True,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: seleniumbase
|
3
|
-
Version: 4.33.
|
3
|
+
Version: 4.33.3
|
4
4
|
Summary: A complete web automation framework for end-to-end testing.
|
5
5
|
Home-page: https://github.com/seleniumbase/SeleniumBase
|
6
6
|
Author: Michael Mintz
|
@@ -105,7 +105,7 @@ Requires-Dist: execnet==2.1.1
|
|
105
105
|
Requires-Dist: iniconfig==2.0.0
|
106
106
|
Requires-Dist: pluggy==1.5.0
|
107
107
|
Requires-Dist: py==1.11.0
|
108
|
-
Requires-Dist: pytest==8.3.
|
108
|
+
Requires-Dist: pytest==8.3.4
|
109
109
|
Requires-Dist: pytest-html==2.0.1
|
110
110
|
Requires-Dist: pytest-metadata==3.1.1
|
111
111
|
Requires-Dist: pytest-ordering==0.6
|
@@ -3,7 +3,7 @@ sbase/__main__.py,sha256=G0bVB1-DM4PGwQ1KyOupaWCs4ePbChZNNWuX2htim5U,647
|
|
3
3
|
sbase/steps.py,sha256=_WvAjydKqZfTdnZW9LPKkRty-g-lfdUPmLqnZj6ulcs,43013
|
4
4
|
seleniumbase/__init__.py,sha256=OtJh8nGKL4xtZpw8KPqmn7Q6R-86t4cWUDyVF5MbMTo,2398
|
5
5
|
seleniumbase/__main__.py,sha256=dn1p6dgCchmcH1zzTzzQvFwwdQQqnTGH6ULV9m4hv24,654
|
6
|
-
seleniumbase/__version__.py,sha256=
|
6
|
+
seleniumbase/__version__.py,sha256=b9CFhb2bSkJaSVPoCfXxUM8ff_Ki-2b4bCUxhDAADOc,46
|
7
7
|
seleniumbase/behave/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
8
8
|
seleniumbase/behave/behave_helper.py,sha256=elkl8P9eLulRAioLstE9baYNM9N_PHBmAOcajX-pH_Y,24198
|
9
9
|
seleniumbase/behave/behave_sb.py,sha256=-hza7Nx2U41mSObYiPMi48v3JlPh3sJO3yzP0kqZ1Gk,59174
|
@@ -36,7 +36,7 @@ seleniumbase/console_scripts/sb_print.py,sha256=tNy-bMDgwHJO3bZxMpmo9weSE8uhbH0C
|
|
36
36
|
seleniumbase/console_scripts/sb_recorder.py,sha256=fnHb5-kh11Hit-E9Ha-e4QXzqLcZvtij6mb5qNd4B1Q,11032
|
37
37
|
seleniumbase/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
38
38
|
seleniumbase/core/application_manager.py,sha256=e_0sjtI8cjY5BNyZj1QBR0j6_oCScxGmSXYEpcYwuZE,576
|
39
|
-
seleniumbase/core/browser_launcher.py,sha256=
|
39
|
+
seleniumbase/core/browser_launcher.py,sha256=ua9a6UfYWzKMFG-R4Jvrk1gkh4RPt7IOTGyp_siCYjQ,221101
|
40
40
|
seleniumbase/core/capabilities_parser.py,sha256=meIS2uHapTCq2ldfNAToC7r0cKmZDRXuYNKExM1GHDY,6038
|
41
41
|
seleniumbase/core/colored_traceback.py,sha256=DrRWfg7XEnKcgY59Xj7Jdk09H-XqHYBSUpB-DiZt6iY,2020
|
42
42
|
seleniumbase/core/create_db_tables.sql,sha256=VWPtrdiW_HQ6yETHjqTu-VIrTwvd8I8o1NfBeaVSHpU,972
|
@@ -50,7 +50,7 @@ seleniumbase/core/proxy_helper.py,sha256=cXhu8ErK9Vjdm82RMaQj7hEq_yUWizSp6LyiD50
|
|
50
50
|
seleniumbase/core/recorder_helper.py,sha256=fNGjbapXmEsht54x1o6Igk198QdnPxDDnjUOzQxNhNQ,25055
|
51
51
|
seleniumbase/core/report_helper.py,sha256=AIl6Qava2yW1uSzbLpJBlPlYDz0KE-rVhogh8hsGWBo,12201
|
52
52
|
seleniumbase/core/s3_manager.py,sha256=bkeI8I4y19ebWuQG1oEZV5qJbotC6eN8vin31OCNWJk,3521
|
53
|
-
seleniumbase/core/sb_cdp.py,sha256=
|
53
|
+
seleniumbase/core/sb_cdp.py,sha256=NyiooRREzeRQYITMiE9b0WwcH3-u8tMsy-cLJSnxerc,67644
|
54
54
|
seleniumbase/core/sb_driver.py,sha256=NGa4adi8OAi2WFtFkEguXg3JCd1p-JuZweIpGNifEfU,13488
|
55
55
|
seleniumbase/core/session_helper.py,sha256=s9zD3PVZEWVzG2h81cCUskbNWLfdjC_LwwQjKptHCak,558
|
56
56
|
seleniumbase/core/settings_parser.py,sha256=KokVXpCiGZhJ-D4Bo-hizPz5r-iefzWoiTANu9zNaq4,7504
|
@@ -65,11 +65,11 @@ seleniumbase/extensions/disable_csp.zip,sha256=YMifIIgEBiLrEFrS1sfW4Exh4br1V4oK1
|
|
65
65
|
seleniumbase/extensions/recorder.zip,sha256=OOyzF-Ize2cSRu1CqhzSAq5vusI9hqLLd2OIApUHesI,11918
|
66
66
|
seleniumbase/extensions/sbase_ext.zip,sha256=3s1N8zrVaMz8RQEOIoBzC3KDjtmHwVZRvVsX25Odr_s,8175
|
67
67
|
seleniumbase/fixtures/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
68
|
-
seleniumbase/fixtures/base_case.py,sha256=
|
68
|
+
seleniumbase/fixtures/base_case.py,sha256=qitMs026hzMdVlWxhN9WNvqR2W9h6q2Ofmorycq4I-Q,717445
|
69
69
|
seleniumbase/fixtures/constants.py,sha256=e1LppavlrAcI4XBJMq7u5j8SffaQ7SPQps1y0YvZYfY,13649
|
70
70
|
seleniumbase/fixtures/css_to_xpath.py,sha256=9ouDB1xl4MJ2os6JOgTIAyHKOQfuxtxvXC3O5hSnEKA,1954
|
71
71
|
seleniumbase/fixtures/errors.py,sha256=KyxuEVx_e3MPhVrJfNIa_3ltMpbCFxfy_jxK8RFNTns,555
|
72
|
-
seleniumbase/fixtures/js_utils.py,sha256=
|
72
|
+
seleniumbase/fixtures/js_utils.py,sha256=t-hqdd75O6Kfe6y5U8986gvZGATpPfDiDnIqeZZodgw,51435
|
73
73
|
seleniumbase/fixtures/page_actions.py,sha256=dbp63c-7asYZyd8aOu57Y3dxQQozp_VJsP5h74s1kBA,66552
|
74
74
|
seleniumbase/fixtures/page_utils.py,sha256=5m7iXpikLs80TJoRO6_gEfXE1AKeQgcH1aFbR8o1C9A,12034
|
75
75
|
seleniumbase/fixtures/shared_utils.py,sha256=WbPb15IvIWzRtMInKG8DUzJ26UZU-PixdOwTCjXQirU,7545
|
@@ -120,7 +120,7 @@ seleniumbase/undetected/cdp_driver/cdp_util.py,sha256=YhtD2Tm6PLIy9VKbgk8lHdGniS
|
|
120
120
|
seleniumbase/undetected/cdp_driver/config.py,sha256=Rjvde7V-XJ0ihZdTmOmHEVWSuDWm3SprQ3njg8SN3Go,12087
|
121
121
|
seleniumbase/undetected/cdp_driver/connection.py,sha256=sOTUGjbUqKA2hPvDcRCdqw1VQjVGJs7mbgVvzS7ldtE,23360
|
122
122
|
seleniumbase/undetected/cdp_driver/element.py,sha256=wEHtuF9oiny7cb4QMMjdtD5Yf1z3WOs2_NHEWcscusM,40289
|
123
|
-
seleniumbase/undetected/cdp_driver/tab.py,sha256=
|
123
|
+
seleniumbase/undetected/cdp_driver/tab.py,sha256=cmSUg9fRnIVYgeqs-t8Tcg1FrSVIrM5IBQmCMzvl4OQ,50678
|
124
124
|
seleniumbase/utilities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
125
125
|
seleniumbase/utilities/selenium_grid/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
126
126
|
seleniumbase/utilities/selenium_grid/download_selenium_server.py,sha256=ZdoInIbhtmdKCIPxxtJHhd2sqotqcNXWMYbwWrkh9O0,1727
|
@@ -135,9 +135,9 @@ seleniumbase/utilities/selenium_grid/start-grid-hub.bat,sha256=Ftq-GrAKRYH2ssDPr
|
|
135
135
|
seleniumbase/utilities/selenium_grid/start-grid-hub.sh,sha256=KADv0RUHONLL2_I443QFK8PryBpDmKn5Gy0s4o0vDSM,106
|
136
136
|
seleniumbase/utilities/selenium_ide/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
137
137
|
seleniumbase/utilities/selenium_ide/convert_ide.py,sha256=pZFnqEJQEKZPyNFjkLD29s2HPQgCrWW9XJWpCPhWOoM,31691
|
138
|
-
seleniumbase-4.33.
|
139
|
-
seleniumbase-4.33.
|
140
|
-
seleniumbase-4.33.
|
141
|
-
seleniumbase-4.33.
|
142
|
-
seleniumbase-4.33.
|
143
|
-
seleniumbase-4.33.
|
138
|
+
seleniumbase-4.33.3.dist-info/LICENSE,sha256=odSYtWibXBnQ1gBg6CnDZ82n8kLF_if5-2nbqnEyD8k,1085
|
139
|
+
seleniumbase-4.33.3.dist-info/METADATA,sha256=3YY_YaHTz2H48ee9t80yTk55JOJY7pIuZwoucYGEx3U,86554
|
140
|
+
seleniumbase-4.33.3.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
141
|
+
seleniumbase-4.33.3.dist-info/entry_points.txt,sha256=CNrh2EKNaHYEhO6pP1RJyVLB99LkDDYX7TnUK8xfjqk,623
|
142
|
+
seleniumbase-4.33.3.dist-info/top_level.txt,sha256=4N97aBOQ8ETCnDnokBsWb07lJfTaq3C1ZzYRxvLMxqU,19
|
143
|
+
seleniumbase-4.33.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|