seleniumbase 4.33.0__py3-none-any.whl → 4.33.2__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 +23 -6
- seleniumbase/core/sb_cdp.py +34 -19
- seleniumbase/fixtures/base_case.py +15 -13
- seleniumbase/fixtures/js_utils.py +94 -86
- seleniumbase/undetected/cdp_driver/browser.py +7 -10
- {seleniumbase-4.33.0.dist-info → seleniumbase-4.33.2.dist-info}/METADATA +2 -2
- {seleniumbase-4.33.0.dist-info → seleniumbase-4.33.2.dist-info}/RECORD +12 -12
- {seleniumbase-4.33.0.dist-info → seleniumbase-4.33.2.dist-info}/LICENSE +0 -0
- {seleniumbase-4.33.0.dist-info → seleniumbase-4.33.2.dist-info}/WHEEL +0 -0
- {seleniumbase-4.33.0.dist-info → seleniumbase-4.33.2.dist-info}/entry_points.txt +0 -0
- {seleniumbase-4.33.0.dist-info → seleniumbase-4.33.2.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.2"
|
@@ -612,6 +612,7 @@ def uc_open_with_cdp_mode(driver, url=None):
|
|
612
612
|
cdp.save_cookies = CDPM.save_cookies
|
613
613
|
cdp.load_cookies = CDPM.load_cookies
|
614
614
|
cdp.clear_cookies = CDPM.clear_cookies
|
615
|
+
cdp.sleep = CDPM.sleep
|
615
616
|
cdp.bring_active_window_to_front = CDPM.bring_active_window_to_front
|
616
617
|
cdp.bring_to_front = CDPM.bring_active_window_to_front
|
617
618
|
cdp.get_active_element = CDPM.get_active_element
|
@@ -684,6 +685,7 @@ def uc_open_with_cdp_mode(driver, url=None):
|
|
684
685
|
cdp.select_if_unselected = CDPM.select_if_unselected
|
685
686
|
cdp.unselect_if_selected = CDPM.unselect_if_selected
|
686
687
|
cdp.is_checked = CDPM.is_checked
|
688
|
+
cdp.is_selected = CDPM.is_selected
|
687
689
|
cdp.is_element_present = CDPM.is_element_present
|
688
690
|
cdp.is_element_visible = CDPM.is_element_visible
|
689
691
|
cdp.wait_for_element_visible = CDPM.wait_for_element_visible
|
@@ -699,6 +701,12 @@ def uc_open_with_cdp_mode(driver, url=None):
|
|
699
701
|
cdp.assert_url_contains = CDPM.assert_url_contains
|
700
702
|
cdp.assert_text = CDPM.assert_text
|
701
703
|
cdp.assert_exact_text = CDPM.assert_exact_text
|
704
|
+
cdp.assert_true = CDPM.assert_true
|
705
|
+
cdp.assert_false = CDPM.assert_false
|
706
|
+
cdp.assert_equal = CDPM.assert_equal
|
707
|
+
cdp.assert_not_equal = CDPM.assert_not_equal
|
708
|
+
cdp.assert_in = CDPM.assert_in
|
709
|
+
cdp.assert_not_in = CDPM.assert_not_in
|
702
710
|
cdp.scroll_into_view = CDPM.scroll_into_view
|
703
711
|
cdp.scroll_to_y = CDPM.scroll_to_y
|
704
712
|
cdp.scroll_to_top = CDPM.scroll_to_top
|
@@ -1167,7 +1175,12 @@ def _uc_gui_click_captcha(
|
|
1167
1175
|
frame = "%s div" % frame
|
1168
1176
|
elif (
|
1169
1177
|
driver.is_element_present('[name*="cf-turnstile-"]')
|
1170
|
-
and driver.is_element_present(
|
1178
|
+
and driver.is_element_present("#challenge-form div > div")
|
1179
|
+
):
|
1180
|
+
frame = "#challenge-form div > div"
|
1181
|
+
elif (
|
1182
|
+
driver.is_element_present('[name*="cf-turnstile-"]')
|
1183
|
+
and driver.is_element_present("[class*=spacer] + div div")
|
1171
1184
|
):
|
1172
1185
|
frame = '[class*=spacer] + div div'
|
1173
1186
|
elif (
|
@@ -1240,8 +1253,8 @@ def _uc_gui_click_captcha(
|
|
1240
1253
|
return
|
1241
1254
|
try:
|
1242
1255
|
if ctype == "g_rc" and not driver.is_connected():
|
1243
|
-
x = (i_x +
|
1244
|
-
y = (i_y +
|
1256
|
+
x = (i_x + 29) * width_ratio
|
1257
|
+
y = (i_y + 35) * width_ratio
|
1245
1258
|
elif visible_iframe:
|
1246
1259
|
selector = "span"
|
1247
1260
|
if ctype == "g_rc":
|
@@ -1256,8 +1269,8 @@ def _uc_gui_click_captcha(
|
|
1256
1269
|
y = i_y + element.rect["y"] + (element.rect["height"] / 2.0)
|
1257
1270
|
y += 0.5
|
1258
1271
|
else:
|
1259
|
-
x = (i_x +
|
1260
|
-
y = (i_y +
|
1272
|
+
x = (i_x + 32) * width_ratio
|
1273
|
+
y = (i_y + 32) * width_ratio
|
1261
1274
|
if driver.is_connected():
|
1262
1275
|
driver.switch_to.default_content()
|
1263
1276
|
except Exception:
|
@@ -1497,6 +1510,7 @@ def _uc_gui_handle_captcha_(driver, frame="iframe", ctype=None):
|
|
1497
1510
|
tab_count += 1
|
1498
1511
|
time.sleep(0.027)
|
1499
1512
|
active_element_css = js_utils.get_active_element_css(driver)
|
1513
|
+
print(active_element_css)
|
1500
1514
|
if (
|
1501
1515
|
active_element_css.startswith(selector)
|
1502
1516
|
or active_element_css.endswith(" > div" * 2)
|
@@ -1514,7 +1528,10 @@ def _uc_gui_handle_captcha_(driver, frame="iframe", ctype=None):
|
|
1514
1528
|
except Exception:
|
1515
1529
|
return
|
1516
1530
|
if (
|
1517
|
-
|
1531
|
+
(
|
1532
|
+
driver.is_element_present(".footer .clearfix .ray-id")
|
1533
|
+
or driver.is_element_present("script[data-cf-beacon]")
|
1534
|
+
)
|
1518
1535
|
and hasattr(sb_config, "_saved_cf_tab_count")
|
1519
1536
|
and sb_config._saved_cf_tab_count
|
1520
1537
|
):
|
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:
|
@@ -726,12 +713,16 @@ class CDPMethods():
|
|
726
713
|
|
727
714
|
def evaluate(self, expression):
|
728
715
|
"""Run a JavaScript expression and return the result."""
|
716
|
+
if expression.startswith("return "):
|
717
|
+
expression = expression[len("return "):]
|
729
718
|
return self.loop.run_until_complete(
|
730
719
|
self.page.evaluate(expression)
|
731
720
|
)
|
732
721
|
|
733
722
|
def js_dumps(self, obj_name):
|
734
723
|
"""Similar to evaluate(), but for dictionary results."""
|
724
|
+
if obj_name.startswith("return "):
|
725
|
+
obj_name = obj_name[len("return "):]
|
735
726
|
return self.loop.run_until_complete(
|
736
727
|
self.page.js_dumps(obj_name)
|
737
728
|
)
|
@@ -1648,11 +1639,11 @@ class CDPMethods():
|
|
1648
1639
|
text = text.strip()
|
1649
1640
|
element = None
|
1650
1641
|
try:
|
1651
|
-
element = self.
|
1642
|
+
element = self.find_element(selector, timeout=timeout)
|
1652
1643
|
except Exception:
|
1653
1644
|
raise Exception("Element {%s} not found!" % selector)
|
1654
1645
|
for i in range(30):
|
1655
|
-
if
|
1646
|
+
if text in element.text_all:
|
1656
1647
|
return True
|
1657
1648
|
time.sleep(0.1)
|
1658
1649
|
raise Exception(
|
@@ -1681,6 +1672,30 @@ class CDPMethods():
|
|
1681
1672
|
% (text, element.text_all, selector)
|
1682
1673
|
)
|
1683
1674
|
|
1675
|
+
def assert_true(self, expression):
|
1676
|
+
if not expression:
|
1677
|
+
raise AssertionError("%s is not true" % expression)
|
1678
|
+
|
1679
|
+
def assert_false(self, expression):
|
1680
|
+
if expression:
|
1681
|
+
raise AssertionError("%s is not false" % expression)
|
1682
|
+
|
1683
|
+
def assert_equal(self, first, second):
|
1684
|
+
if first != second:
|
1685
|
+
raise AssertionError("%s is not equal to %s" % (first, second))
|
1686
|
+
|
1687
|
+
def assert_not_equal(self, first, second):
|
1688
|
+
if first == second:
|
1689
|
+
raise AssertionError("%s is equal to %s" % (first, second))
|
1690
|
+
|
1691
|
+
def assert_in(self, first, second):
|
1692
|
+
if first not in second:
|
1693
|
+
raise AssertionError("%s is not in %s" % (first, second))
|
1694
|
+
|
1695
|
+
def assert_not_in(self, first, second):
|
1696
|
+
if first in second:
|
1697
|
+
raise AssertionError("%s is in %s" % (first, second))
|
1698
|
+
|
1684
1699
|
def scroll_into_view(self, selector):
|
1685
1700
|
self.find_element(selector).scroll_into_view()
|
1686
1701
|
self.loop.run_until_complete(self.page.wait())
|
@@ -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(
|
@@ -1597,7 +1597,7 @@ class BaseCase(unittest.TestCase):
|
|
1597
1597
|
"""This method clicks link text on a page."""
|
1598
1598
|
self.__check_scope()
|
1599
1599
|
if self.__is_cdp_swap_needed():
|
1600
|
-
self.cdp.find_element(link_text).click()
|
1600
|
+
self.cdp.find_element(link_text, timeout=timeout).click()
|
1601
1601
|
return
|
1602
1602
|
self.__skip_if_esc()
|
1603
1603
|
if not timeout:
|
@@ -3380,6 +3380,8 @@ class BaseCase(unittest.TestCase):
|
|
3380
3380
|
|
3381
3381
|
def execute_script(self, script, *args, **kwargs):
|
3382
3382
|
self.__check_scope()
|
3383
|
+
if self.__is_cdp_swap_needed():
|
3384
|
+
return self.cdp.evaluate(script)
|
3383
3385
|
self._check_browser()
|
3384
3386
|
return self.driver.execute_script(script, *args, **kwargs)
|
3385
3387
|
|
@@ -6308,7 +6310,7 @@ class BaseCase(unittest.TestCase):
|
|
6308
6310
|
If "all_matches" is False, only the first match is clicked.
|
6309
6311
|
If "scroll" is False, won't scroll unless running in Demo Mode."""
|
6310
6312
|
if self.__is_cdp_swap_needed():
|
6311
|
-
self.cdp.click(selector)
|
6313
|
+
self.cdp.click(selector, timeout=timeout)
|
6312
6314
|
return
|
6313
6315
|
self.wait_for_ready_state_complete()
|
6314
6316
|
if not timeout or timeout is True:
|
@@ -8245,7 +8247,7 @@ class BaseCase(unittest.TestCase):
|
|
8245
8247
|
timeout = settings.SMALL_TIMEOUT
|
8246
8248
|
if self.__is_cdp_swap_needed():
|
8247
8249
|
mfa_code = self.get_mfa_code(totp_key)
|
8248
|
-
self.cdp.type(selector, mfa_code + "\n")
|
8250
|
+
self.cdp.type(selector, mfa_code + "\n", timeout=timeout)
|
8249
8251
|
return
|
8250
8252
|
self.wait_for_element_visible(selector, by=by, timeout=timeout)
|
8251
8253
|
if self.recorder_mode and self.__current_url_is_recordable():
|
@@ -9003,7 +9005,7 @@ class BaseCase(unittest.TestCase):
|
|
9003
9005
|
original_selector = selector
|
9004
9006
|
selector, by = self.__recalculate_selector(selector, by)
|
9005
9007
|
if self.__is_cdp_swap_needed():
|
9006
|
-
return self.cdp.select(selector)
|
9008
|
+
return self.cdp.select(selector, timeout=timeout)
|
9007
9009
|
if self.__is_shadow_selector(selector):
|
9008
9010
|
return self.__get_shadow_element(selector, timeout)
|
9009
9011
|
return page_actions.wait_for_element_visible(
|
@@ -9026,7 +9028,7 @@ class BaseCase(unittest.TestCase):
|
|
9026
9028
|
original_selector = selector
|
9027
9029
|
selector, by = self.__recalculate_selector(selector, by)
|
9028
9030
|
if self.__is_cdp_swap_needed():
|
9029
|
-
return self.cdp.select(selector)
|
9031
|
+
return self.cdp.select(selector, timeout=timeout)
|
9030
9032
|
elif self.__is_shadow_selector(selector):
|
9031
9033
|
# If a shadow selector, use visible instead of clickable
|
9032
9034
|
return self.__wait_for_shadow_element_visible(selector, timeout)
|
@@ -9427,7 +9429,7 @@ class BaseCase(unittest.TestCase):
|
|
9427
9429
|
original_selector = selector
|
9428
9430
|
selector, by = self.__recalculate_selector(selector, by)
|
9429
9431
|
if self.__is_cdp_swap_needed():
|
9430
|
-
return self.cdp.select(selector)
|
9432
|
+
return self.cdp.select(selector, timeout=timeout)
|
9431
9433
|
elif self.__is_shadow_selector(selector):
|
9432
9434
|
return self.__wait_for_shadow_element_present(selector, timeout)
|
9433
9435
|
return page_actions.wait_for_element_present(
|
@@ -9449,7 +9451,7 @@ class BaseCase(unittest.TestCase):
|
|
9449
9451
|
original_selector = selector
|
9450
9452
|
selector, by = self.__recalculate_selector(selector, by)
|
9451
9453
|
if self.__is_cdp_swap_needed():
|
9452
|
-
return self.cdp.select(selector)
|
9454
|
+
return self.cdp.select(selector, timeout=timeout)
|
9453
9455
|
if self.recorder_mode and self.__current_url_is_recordable():
|
9454
9456
|
if self.get_session_storage_item("pause_recorder") == "no":
|
9455
9457
|
if by == By.XPATH:
|
@@ -9492,7 +9494,7 @@ class BaseCase(unittest.TestCase):
|
|
9492
9494
|
timeout = self.__get_new_timeout(timeout)
|
9493
9495
|
css_selector = self.convert_to_css_selector(selector, by=by)
|
9494
9496
|
if self.__is_cdp_swap_needed():
|
9495
|
-
return self.cdp.select(css_selector)
|
9497
|
+
return self.cdp.select(css_selector, timeout=timeout)
|
9496
9498
|
return js_utils.wait_for_css_query_selector(
|
9497
9499
|
self.driver, css_selector, timeout
|
9498
9500
|
)
|
@@ -9713,7 +9715,7 @@ class BaseCase(unittest.TestCase):
|
|
9713
9715
|
text = self.__get_type_checked_text(text)
|
9714
9716
|
selector, by = self.__recalculate_selector(selector, by)
|
9715
9717
|
if self.__is_cdp_swap_needed():
|
9716
|
-
return self.cdp.find_element(selector)
|
9718
|
+
return self.cdp.find_element(selector, timeout=timeout)
|
9717
9719
|
elif self.__is_shadow_selector(selector):
|
9718
9720
|
return self.__wait_for_shadow_text_visible(text, selector, timeout)
|
9719
9721
|
return page_actions.wait_for_text_visible(
|
@@ -10093,7 +10095,7 @@ class BaseCase(unittest.TestCase):
|
|
10093
10095
|
if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT:
|
10094
10096
|
timeout = self.__get_new_timeout(timeout)
|
10095
10097
|
if self.__is_cdp_swap_needed():
|
10096
|
-
self.cdp.find_element(link_text)
|
10098
|
+
self.cdp.find_element(link_text, timeout=timeout)
|
10097
10099
|
return
|
10098
10100
|
self.wait_for_link_text_visible(link_text, timeout=timeout)
|
10099
10101
|
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
|
@@ -6,8 +6,9 @@ import http.cookiejar
|
|
6
6
|
import json
|
7
7
|
import logging
|
8
8
|
import os
|
9
|
-
import pickle
|
10
9
|
import pathlib
|
10
|
+
import pickle
|
11
|
+
import re
|
11
12
|
import shutil
|
12
13
|
import urllib.parse
|
13
14
|
import urllib.request
|
@@ -644,7 +645,7 @@ class CookieJar:
|
|
644
645
|
"""
|
645
646
|
connection = None
|
646
647
|
for _tab in self._browser.tabs:
|
647
|
-
if _tab.closed:
|
648
|
+
if hasattr(_tab, "closed") and _tab.closed:
|
648
649
|
continue
|
649
650
|
connection = _tab
|
650
651
|
break
|
@@ -674,7 +675,7 @@ class CookieJar:
|
|
674
675
|
"""
|
675
676
|
connection = None
|
676
677
|
for _tab in self._browser.tabs:
|
677
|
-
if _tab.closed:
|
678
|
+
if hasattr(_tab, "closed") and _tab.closed:
|
678
679
|
continue
|
679
680
|
connection = _tab
|
680
681
|
break
|
@@ -698,13 +699,11 @@ class CookieJar:
|
|
698
699
|
- Contain "nowsecure"
|
699
700
|
:type pattern: str
|
700
701
|
"""
|
701
|
-
import re
|
702
|
-
|
703
702
|
pattern = re.compile(pattern)
|
704
703
|
save_path = pathlib.Path(file).resolve()
|
705
704
|
connection = None
|
706
705
|
for _tab in self._browser.tabs:
|
707
|
-
if _tab.closed:
|
706
|
+
if hasattr(_tab, "closed") and _tab.closed:
|
708
707
|
continue
|
709
708
|
connection = _tab
|
710
709
|
break
|
@@ -746,15 +745,13 @@ class CookieJar:
|
|
746
745
|
- Contain "nowsecure"
|
747
746
|
:type pattern: str
|
748
747
|
"""
|
749
|
-
import re
|
750
|
-
|
751
748
|
pattern = re.compile(pattern)
|
752
749
|
save_path = pathlib.Path(file).resolve()
|
753
750
|
cookies = pickle.load(save_path.open("r+b"))
|
754
751
|
included_cookies = []
|
755
752
|
connection = None
|
756
753
|
for _tab in self._browser.tabs:
|
757
|
-
if _tab.closed:
|
754
|
+
if hasattr(_tab, "closed") and _tab.closed:
|
758
755
|
continue
|
759
756
|
connection = _tab
|
760
757
|
break
|
@@ -779,7 +776,7 @@ class CookieJar:
|
|
779
776
|
"""
|
780
777
|
connection = None
|
781
778
|
for _tab in self._browser.tabs:
|
782
|
-
if _tab.closed:
|
779
|
+
if hasattr(_tab, "closed") and _tab.closed:
|
783
780
|
continue
|
784
781
|
connection = _tab
|
785
782
|
break
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: seleniumbase
|
3
|
-
Version: 4.33.
|
3
|
+
Version: 4.33.2
|
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
|
@@ -146,7 +146,7 @@ Requires-Dist: mss==9.0.2; extra == "mss"
|
|
146
146
|
Provides-Extra: pdfminer
|
147
147
|
Requires-Dist: pdfminer.six==20240706; extra == "pdfminer"
|
148
148
|
Requires-Dist: cryptography==39.0.2; python_version < "3.9" and extra == "pdfminer"
|
149
|
-
Requires-Dist: cryptography==
|
149
|
+
Requires-Dist: cryptography==44.0.0; python_version >= "3.9" and extra == "pdfminer"
|
150
150
|
Requires-Dist: cffi==1.17.1; extra == "pdfminer"
|
151
151
|
Requires-Dist: pycparser==2.22; extra == "pdfminer"
|
152
152
|
Provides-Extra: pillow
|
@@ -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=DurPep4UOAZOSzAkCBAp_MZg2c7IdEU_tHzobaEV4lE,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=9FDfk76brTw5nC9LNFfPn8JoYD0cY92omQJyo1FPiwg,221002
|
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=T5QkG7tiZs6XLra_vxUeIfsYhg1i7oxEkLDmpG6LLmE,67361
|
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=uxJcSytEc0dOxiSp03I58hcGmxGaFTSSBoro1-O-JLk,717061
|
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
|
@@ -115,7 +115,7 @@ seleniumbase/undetected/reactor.py,sha256=NropaXcO54pzmDq6quR27qPJxab6636H7LRAaq
|
|
115
115
|
seleniumbase/undetected/webelement.py,sha256=_s6evgUkdWJpwOnzX4qR9i796PoVbz3txlzHlOBJ4BE,1370
|
116
116
|
seleniumbase/undetected/cdp_driver/__init__.py,sha256=c0TjMwPfVFyoqYOJ7PQ-Jln_L_dpN3ebHyaD-juQoM0,64
|
117
117
|
seleniumbase/undetected/cdp_driver/_contradict.py,sha256=6thDYeoEGiC7Q3tXLgoD_AhxecCFnATzBSjNympyRHA,3184
|
118
|
-
seleniumbase/undetected/cdp_driver/browser.py,sha256=
|
118
|
+
seleniumbase/undetected/cdp_driver/browser.py,sha256=n8GYspU7b0pfBT4AqhqY6IdGVOZ1FC4wJ5emIOl-khQ,30129
|
119
119
|
seleniumbase/undetected/cdp_driver/cdp_util.py,sha256=YhtD2Tm6PLIy9VKbgk8lHdGniS3mObyX4yAC1aG0TgQ,16733
|
120
120
|
seleniumbase/undetected/cdp_driver/config.py,sha256=Rjvde7V-XJ0ihZdTmOmHEVWSuDWm3SprQ3njg8SN3Go,12087
|
121
121
|
seleniumbase/undetected/cdp_driver/connection.py,sha256=sOTUGjbUqKA2hPvDcRCdqw1VQjVGJs7mbgVvzS7ldtE,23360
|
@@ -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.2.dist-info/LICENSE,sha256=odSYtWibXBnQ1gBg6CnDZ82n8kLF_if5-2nbqnEyD8k,1085
|
139
|
+
seleniumbase-4.33.2.dist-info/METADATA,sha256=nFoS4vqUdYDMBwy1VzYwDe8CFN_M5rqdzrM4nwgHo6Y,86554
|
140
|
+
seleniumbase-4.33.2.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
141
|
+
seleniumbase-4.33.2.dist-info/entry_points.txt,sha256=CNrh2EKNaHYEhO6pP1RJyVLB99LkDDYX7TnUK8xfjqk,623
|
142
|
+
seleniumbase-4.33.2.dist-info/top_level.txt,sha256=4N97aBOQ8ETCnDnokBsWb07lJfTaq3C1ZzYRxvLMxqU,19
|
143
|
+
seleniumbase-4.33.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|