seleniumbase 4.32.8__py3-none-any.whl → 4.32.10__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- seleniumbase/__version__.py +1 -1
- seleniumbase/core/browser_launcher.py +91 -40
- seleniumbase/core/sb_cdp.py +438 -53
- seleniumbase/core/sb_driver.py +16 -0
- seleniumbase/fixtures/base_case.py +59 -11
- seleniumbase/fixtures/constants.py +1 -0
- seleniumbase/fixtures/js_utils.py +1 -5
- seleniumbase/fixtures/page_actions.py +0 -2
- seleniumbase/fixtures/shared_utils.py +14 -3
- seleniumbase/plugins/driver_manager.py +1 -5
- seleniumbase/plugins/sb_manager.py +1 -5
- seleniumbase/undetected/cdp_driver/connection.py +4 -3
- seleniumbase/undetected/cdp_driver/element.py +18 -2
- {seleniumbase-4.32.8.dist-info → seleniumbase-4.32.10.dist-info}/METADATA +8 -7
- {seleniumbase-4.32.8.dist-info → seleniumbase-4.32.10.dist-info}/RECORD +19 -19
- {seleniumbase-4.32.8.dist-info → seleniumbase-4.32.10.dist-info}/WHEEL +1 -1
- {seleniumbase-4.32.8.dist-info → seleniumbase-4.32.10.dist-info}/LICENSE +0 -0
- {seleniumbase-4.32.8.dist-info → seleniumbase-4.32.10.dist-info}/entry_points.txt +0 -0
- {seleniumbase-4.32.8.dist-info → seleniumbase-4.32.10.dist-info}/top_level.txt +0 -0
seleniumbase/__version__.py
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
# seleniumbase package
|
2
|
-
__version__ = "4.32.
|
2
|
+
__version__ = "4.32.10"
|
@@ -544,6 +544,8 @@ def uc_open_with_cdp_mode(driver, url=None):
|
|
544
544
|
)
|
545
545
|
loop.run_until_complete(driver.cdp_base.wait(0))
|
546
546
|
|
547
|
+
gui_lock = fasteners.InterProcessLock(constants.MultiBrowser.PYAUTOGUILOCK)
|
548
|
+
|
547
549
|
if (
|
548
550
|
"chrome-extension://" in str(driver.cdp_base.main_tab)
|
549
551
|
and len(driver.cdp_base.tabs) >= 2
|
@@ -553,7 +555,8 @@ def uc_open_with_cdp_mode(driver, url=None):
|
|
553
555
|
|
554
556
|
for tab in driver.cdp_base.tabs[-1::-1]:
|
555
557
|
if "chrome-extension://" not in str(tab):
|
556
|
-
|
558
|
+
with gui_lock:
|
559
|
+
loop.run_until_complete(tab.activate())
|
557
560
|
break
|
558
561
|
|
559
562
|
page_tab = None
|
@@ -566,13 +569,20 @@ def uc_open_with_cdp_mode(driver, url=None):
|
|
566
569
|
break
|
567
570
|
if page_tab:
|
568
571
|
loop.run_until_complete(page_tab.aopen())
|
569
|
-
|
572
|
+
with gui_lock:
|
573
|
+
loop.run_until_complete(page_tab.activate())
|
570
574
|
|
571
575
|
loop.run_until_complete(driver.cdp_base.update_targets())
|
572
576
|
page = loop.run_until_complete(driver.cdp_base.get(url))
|
573
|
-
|
577
|
+
with gui_lock:
|
578
|
+
loop.run_until_complete(page.activate())
|
579
|
+
loop.run_until_complete(page.wait())
|
574
580
|
if not safe_url:
|
575
581
|
time.sleep(constants.UC.CDP_MODE_OPEN_WAIT)
|
582
|
+
if IS_WINDOWS:
|
583
|
+
time.sleep(constants.UC.EXTRA_WINDOWS_WAIT)
|
584
|
+
else:
|
585
|
+
time.sleep(0.012)
|
576
586
|
cdp = types.SimpleNamespace()
|
577
587
|
CDPM = sb_cdp.CDPMethods(loop, page, driver)
|
578
588
|
cdp.get = CDPM.get
|
@@ -603,14 +613,15 @@ def uc_open_with_cdp_mode(driver, url=None):
|
|
603
613
|
cdp.click = CDPM.click
|
604
614
|
cdp.click_active_element = CDPM.click_active_element
|
605
615
|
cdp.click_if_visible = CDPM.click_if_visible
|
616
|
+
cdp.click_visible_elements = CDPM.click_visible_elements
|
606
617
|
cdp.mouse_click = CDPM.mouse_click
|
607
618
|
cdp.remove_element = CDPM.remove_element
|
608
619
|
cdp.remove_from_dom = CDPM.remove_from_dom
|
609
620
|
cdp.remove_elements = CDPM.remove_elements
|
610
|
-
cdp.scroll_into_view = CDPM.scroll_into_view
|
611
621
|
cdp.send_keys = CDPM.send_keys
|
612
622
|
cdp.press_keys = CDPM.press_keys
|
613
623
|
cdp.type = CDPM.type
|
624
|
+
cdp.set_value = CDPM.set_value
|
614
625
|
cdp.evaluate = CDPM.evaluate
|
615
626
|
cdp.js_dumps = CDPM.js_dumps
|
616
627
|
cdp.maximize = CDPM.maximize
|
@@ -620,8 +631,16 @@ def uc_open_with_cdp_mode(driver, url=None):
|
|
620
631
|
cdp.reset_window_size = CDPM.reset_window_size
|
621
632
|
cdp.set_locale = CDPM.set_locale
|
622
633
|
cdp.set_attributes = CDPM.set_attributes
|
634
|
+
cdp.gui_press_key = CDPM.gui_press_key
|
635
|
+
cdp.gui_press_keys = CDPM.gui_press_keys
|
636
|
+
cdp.gui_write = CDPM.gui_write
|
623
637
|
cdp.gui_click_x_y = CDPM.gui_click_x_y
|
624
638
|
cdp.gui_click_element = CDPM.gui_click_element
|
639
|
+
cdp.gui_drag_drop_points = CDPM.gui_drag_drop_points
|
640
|
+
cdp.gui_drag_and_drop = CDPM.gui_drag_and_drop
|
641
|
+
cdp.gui_hover_x_y = CDPM.gui_hover_x_y
|
642
|
+
cdp.gui_hover_element = CDPM.gui_hover_element
|
643
|
+
cdp.gui_hover_and_click = CDPM.gui_hover_and_click
|
625
644
|
cdp.internalize_links = CDPM.internalize_links
|
626
645
|
cdp.get_window = CDPM.get_window
|
627
646
|
cdp.get_element_attributes = CDPM.get_element_attributes
|
@@ -648,7 +667,9 @@ def uc_open_with_cdp_mode(driver, url=None):
|
|
648
667
|
cdp.get_window_rect = CDPM.get_window_rect
|
649
668
|
cdp.get_window_size = CDPM.get_window_size
|
650
669
|
cdp.nested_click = CDPM.nested_click
|
670
|
+
cdp.select_option_by_text = CDPM.select_option_by_text
|
651
671
|
cdp.flash = CDPM.flash
|
672
|
+
cdp.highlight = CDPM.highlight
|
652
673
|
cdp.focus = CDPM.focus
|
653
674
|
cdp.highlight_overlay = CDPM.highlight_overlay
|
654
675
|
cdp.get_window_position = CDPM.get_window_position
|
@@ -660,12 +681,19 @@ def uc_open_with_cdp_mode(driver, url=None):
|
|
660
681
|
cdp.is_element_present = CDPM.is_element_present
|
661
682
|
cdp.is_element_visible = CDPM.is_element_visible
|
662
683
|
cdp.assert_element_present = CDPM.assert_element_present
|
684
|
+
cdp.assert_element_absent = CDPM.assert_element_absent
|
663
685
|
cdp.assert_element = CDPM.assert_element
|
664
686
|
cdp.assert_element_visible = CDPM.assert_element
|
687
|
+
cdp.assert_element_not_visible = CDPM.assert_element_not_visible
|
688
|
+
cdp.assert_title = CDPM.assert_title
|
665
689
|
cdp.assert_text = CDPM.assert_text
|
666
690
|
cdp.assert_exact_text = CDPM.assert_exact_text
|
667
|
-
cdp.
|
691
|
+
cdp.scroll_into_view = CDPM.scroll_into_view
|
692
|
+
cdp.scroll_to_y = CDPM.scroll_to_y
|
693
|
+
cdp.scroll_to_top = CDPM.scroll_to_top
|
694
|
+
cdp.scroll_to_bottom = CDPM.scroll_to_bottom
|
668
695
|
cdp.scroll_up = CDPM.scroll_up
|
696
|
+
cdp.scroll_down = CDPM.scroll_down
|
669
697
|
cdp.save_screenshot = CDPM.save_screenshot
|
670
698
|
cdp.page = page # async world
|
671
699
|
cdp.driver = driver.cdp_base # async world
|
@@ -677,6 +705,7 @@ def uc_open_with_cdp_mode(driver, url=None):
|
|
677
705
|
core_items.tab = cdp.tab
|
678
706
|
core_items.util = cdp.util
|
679
707
|
cdp.core = core_items
|
708
|
+
cdp.loop = cdp.get_event_loop()
|
680
709
|
driver.cdp = cdp
|
681
710
|
driver._is_using_cdp = True
|
682
711
|
|
@@ -721,6 +750,9 @@ def uc_click(
|
|
721
750
|
timeout=settings.SMALL_TIMEOUT,
|
722
751
|
reconnect_time=None,
|
723
752
|
):
|
753
|
+
if __is_cdp_swap_needed(driver):
|
754
|
+
driver.cdp.click(selector)
|
755
|
+
return
|
724
756
|
with suppress(Exception):
|
725
757
|
rct = float(by) # Add shortcut: driver.uc_click(selector, RCT)
|
726
758
|
if not reconnect_time:
|
@@ -938,48 +970,46 @@ def uc_gui_click_x_y(driver, x, y, timeframe=0.25):
|
|
938
970
|
connected = True
|
939
971
|
width_ratio = 1.0
|
940
972
|
if IS_WINDOWS:
|
941
|
-
|
942
|
-
driver.window_handles
|
943
|
-
except Exception:
|
944
|
-
connected = False
|
973
|
+
connected = driver.is_connected()
|
945
974
|
if (
|
946
975
|
not connected
|
947
976
|
and (
|
948
977
|
not hasattr(sb_config, "_saved_width_ratio")
|
949
978
|
or not sb_config._saved_width_ratio
|
950
979
|
)
|
980
|
+
and not __is_cdp_swap_needed(driver)
|
951
981
|
):
|
952
982
|
driver.reconnect(0.1)
|
953
|
-
|
954
|
-
if IS_WINDOWS and connected:
|
983
|
+
if IS_WINDOWS and not __is_cdp_swap_needed(driver):
|
955
984
|
window_rect = driver.get_window_rect()
|
956
985
|
width = window_rect["width"]
|
957
986
|
height = window_rect["height"]
|
958
987
|
win_x = window_rect["x"]
|
959
988
|
win_y = window_rect["y"]
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
)
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
driver.maximize_window()
|
968
|
-
win_width = driver.get_window_size()["width"]
|
969
|
-
width_ratio = round(float(scr_width) / float(win_width), 2)
|
970
|
-
width_ratio += 0.01
|
971
|
-
if width_ratio < 0.45 or width_ratio > 2.55:
|
972
|
-
width_ratio = 1.01
|
973
|
-
sb_config._saved_width_ratio = width_ratio
|
989
|
+
scr_width = pyautogui.size().width
|
990
|
+
driver.maximize_window()
|
991
|
+
win_width = driver.get_window_size()["width"]
|
992
|
+
width_ratio = round(float(scr_width) / float(win_width), 2) + 0.01
|
993
|
+
if width_ratio < 0.45 or width_ratio > 2.55:
|
994
|
+
width_ratio = 1.01
|
995
|
+
sb_config._saved_width_ratio = width_ratio
|
974
996
|
driver.minimize_window()
|
975
997
|
driver.set_window_rect(win_x, win_y, width, height)
|
976
|
-
elif (
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
998
|
+
elif IS_WINDOWS and __is_cdp_swap_needed(driver):
|
999
|
+
window_rect = driver.cdp.get_window_rect()
|
1000
|
+
width = window_rect["width"]
|
1001
|
+
height = window_rect["height"]
|
1002
|
+
win_x = window_rect["x"]
|
1003
|
+
win_y = window_rect["y"]
|
1004
|
+
scr_width = pyautogui.size().width
|
1005
|
+
driver.cdp.maximize()
|
1006
|
+
win_width = driver.cdp.get_window_size()["width"]
|
1007
|
+
width_ratio = round(float(scr_width) / float(win_width), 2) + 0.01
|
1008
|
+
if width_ratio < 0.45 or width_ratio > 2.55:
|
1009
|
+
width_ratio = 1.01
|
1010
|
+
sb_config._saved_width_ratio = width_ratio
|
1011
|
+
driver.cdp.minimize()
|
1012
|
+
driver.cdp.set_window_rect(win_x, win_y, width, height)
|
983
1013
|
if IS_WINDOWS:
|
984
1014
|
x = x * width_ratio
|
985
1015
|
y = y * width_ratio
|
@@ -1084,6 +1114,21 @@ def _uc_gui_click_captcha(
|
|
1084
1114
|
sb_config._saved_width_ratio = width_ratio
|
1085
1115
|
driver.minimize_window()
|
1086
1116
|
driver.set_window_rect(win_x, win_y, width, height)
|
1117
|
+
elif IS_WINDOWS and __is_cdp_swap_needed(driver):
|
1118
|
+
window_rect = driver.cdp.get_window_rect()
|
1119
|
+
width = window_rect["width"]
|
1120
|
+
height = window_rect["height"]
|
1121
|
+
win_x = window_rect["x"]
|
1122
|
+
win_y = window_rect["y"]
|
1123
|
+
scr_width = pyautogui.size().width
|
1124
|
+
driver.cdp.maximize()
|
1125
|
+
win_width = driver.cdp.get_window_size()["width"]
|
1126
|
+
width_ratio = round(float(scr_width) / float(win_width), 2) + 0.01
|
1127
|
+
if width_ratio < 0.45 or width_ratio > 2.55:
|
1128
|
+
width_ratio = 1.01
|
1129
|
+
sb_config._saved_width_ratio = width_ratio
|
1130
|
+
driver.cdp.minimize()
|
1131
|
+
driver.cdp.set_window_rect(win_x, win_y, width, height)
|
1087
1132
|
if ctype == "cf_t":
|
1088
1133
|
if (
|
1089
1134
|
driver.is_element_present(".cf-turnstile-wrapper iframe")
|
@@ -1195,10 +1240,10 @@ def _uc_gui_click_captcha(
|
|
1195
1240
|
element = driver.wait_for_element_present(
|
1196
1241
|
selector, timeout=2.5
|
1197
1242
|
)
|
1198
|
-
x = i_x + element.rect["x"] +
|
1199
|
-
x +=
|
1200
|
-
y = i_y + element.rect["y"] +
|
1201
|
-
y +=
|
1243
|
+
x = i_x + element.rect["x"] + (element.rect["width"] / 2.0)
|
1244
|
+
x += 0.5
|
1245
|
+
y = i_y + element.rect["y"] + (element.rect["height"] / 2.0)
|
1246
|
+
y += 0.5
|
1202
1247
|
else:
|
1203
1248
|
x = (i_x + 34) * width_ratio
|
1204
1249
|
y = (i_y + 34) * width_ratio
|
@@ -1212,12 +1257,18 @@ def _uc_gui_click_captcha(
|
|
1212
1257
|
return
|
1213
1258
|
if x and y:
|
1214
1259
|
sb_config._saved_cf_x_y = (x, y)
|
1215
|
-
if driver
|
1216
|
-
driver.
|
1217
|
-
|
1218
|
-
|
1260
|
+
if not __is_cdp_swap_needed(driver):
|
1261
|
+
if driver.is_element_present(".footer .clearfix .ray-id"):
|
1262
|
+
driver.uc_open_with_disconnect(
|
1263
|
+
driver.get_current_url(), 3.8
|
1264
|
+
)
|
1265
|
+
else:
|
1266
|
+
driver.disconnect()
|
1219
1267
|
with suppress(Exception):
|
1220
1268
|
_uc_gui_click_x_y(driver, x, y, timeframe=0.32)
|
1269
|
+
if __is_cdp_swap_needed(driver):
|
1270
|
+
time.sleep(float(constants.UC.RECONNECT_TIME) / 2.0)
|
1271
|
+
return
|
1221
1272
|
reconnect_time = (float(constants.UC.RECONNECT_TIME) / 2.0) + 0.6
|
1222
1273
|
if IS_LINUX:
|
1223
1274
|
reconnect_time = constants.UC.RECONNECT_TIME + 0.2
|