seleniumbase 4.32.9__py3-none-any.whl → 4.32.10__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 +85 -40
- seleniumbase/core/sb_cdp.py +399 -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/undetected/cdp_driver/element.py +18 -2
- {seleniumbase-4.32.9.dist-info → seleniumbase-4.32.10.dist-info}/METADATA +5 -5
- {seleniumbase-4.32.9.dist-info → seleniumbase-4.32.10.dist-info}/RECORD +16 -16
- {seleniumbase-4.32.9.dist-info → seleniumbase-4.32.10.dist-info}/WHEEL +1 -1
- {seleniumbase-4.32.9.dist-info → seleniumbase-4.32.10.dist-info}/LICENSE +0 -0
- {seleniumbase-4.32.9.dist-info → seleniumbase-4.32.10.dist-info}/entry_points.txt +0 -0
- {seleniumbase-4.32.9.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
|
@@ -625,6 +636,11 @@ def uc_open_with_cdp_mode(driver, url=None):
|
|
625
636
|
cdp.gui_write = CDPM.gui_write
|
626
637
|
cdp.gui_click_x_y = CDPM.gui_click_x_y
|
627
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
|
628
644
|
cdp.internalize_links = CDPM.internalize_links
|
629
645
|
cdp.get_window = CDPM.get_window
|
630
646
|
cdp.get_element_attributes = CDPM.get_element_attributes
|
@@ -651,7 +667,9 @@ def uc_open_with_cdp_mode(driver, url=None):
|
|
651
667
|
cdp.get_window_rect = CDPM.get_window_rect
|
652
668
|
cdp.get_window_size = CDPM.get_window_size
|
653
669
|
cdp.nested_click = CDPM.nested_click
|
670
|
+
cdp.select_option_by_text = CDPM.select_option_by_text
|
654
671
|
cdp.flash = CDPM.flash
|
672
|
+
cdp.highlight = CDPM.highlight
|
655
673
|
cdp.focus = CDPM.focus
|
656
674
|
cdp.highlight_overlay = CDPM.highlight_overlay
|
657
675
|
cdp.get_window_position = CDPM.get_window_position
|
@@ -663,12 +681,19 @@ def uc_open_with_cdp_mode(driver, url=None):
|
|
663
681
|
cdp.is_element_present = CDPM.is_element_present
|
664
682
|
cdp.is_element_visible = CDPM.is_element_visible
|
665
683
|
cdp.assert_element_present = CDPM.assert_element_present
|
684
|
+
cdp.assert_element_absent = CDPM.assert_element_absent
|
666
685
|
cdp.assert_element = CDPM.assert_element
|
667
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
|
668
689
|
cdp.assert_text = CDPM.assert_text
|
669
690
|
cdp.assert_exact_text = CDPM.assert_exact_text
|
670
|
-
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
|
671
695
|
cdp.scroll_up = CDPM.scroll_up
|
696
|
+
cdp.scroll_down = CDPM.scroll_down
|
672
697
|
cdp.save_screenshot = CDPM.save_screenshot
|
673
698
|
cdp.page = page # async world
|
674
699
|
cdp.driver = driver.cdp_base # async world
|
@@ -680,6 +705,7 @@ def uc_open_with_cdp_mode(driver, url=None):
|
|
680
705
|
core_items.tab = cdp.tab
|
681
706
|
core_items.util = cdp.util
|
682
707
|
cdp.core = core_items
|
708
|
+
cdp.loop = cdp.get_event_loop()
|
683
709
|
driver.cdp = cdp
|
684
710
|
driver._is_using_cdp = True
|
685
711
|
|
@@ -944,48 +970,46 @@ def uc_gui_click_x_y(driver, x, y, timeframe=0.25):
|
|
944
970
|
connected = True
|
945
971
|
width_ratio = 1.0
|
946
972
|
if IS_WINDOWS:
|
947
|
-
|
948
|
-
driver.window_handles
|
949
|
-
except Exception:
|
950
|
-
connected = False
|
973
|
+
connected = driver.is_connected()
|
951
974
|
if (
|
952
975
|
not connected
|
953
976
|
and (
|
954
977
|
not hasattr(sb_config, "_saved_width_ratio")
|
955
978
|
or not sb_config._saved_width_ratio
|
956
979
|
)
|
980
|
+
and not __is_cdp_swap_needed(driver)
|
957
981
|
):
|
958
982
|
driver.reconnect(0.1)
|
959
|
-
|
960
|
-
if IS_WINDOWS and connected:
|
983
|
+
if IS_WINDOWS and not __is_cdp_swap_needed(driver):
|
961
984
|
window_rect = driver.get_window_rect()
|
962
985
|
width = window_rect["width"]
|
963
986
|
height = window_rect["height"]
|
964
987
|
win_x = window_rect["x"]
|
965
988
|
win_y = window_rect["y"]
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
)
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
driver.maximize_window()
|
974
|
-
win_width = driver.get_window_size()["width"]
|
975
|
-
width_ratio = round(float(scr_width) / float(win_width), 2)
|
976
|
-
width_ratio += 0.01
|
977
|
-
if width_ratio < 0.45 or width_ratio > 2.55:
|
978
|
-
width_ratio = 1.01
|
979
|
-
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
|
980
996
|
driver.minimize_window()
|
981
997
|
driver.set_window_rect(win_x, win_y, width, height)
|
982
|
-
elif (
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
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)
|
989
1013
|
if IS_WINDOWS:
|
990
1014
|
x = x * width_ratio
|
991
1015
|
y = y * width_ratio
|
@@ -1090,6 +1114,21 @@ def _uc_gui_click_captcha(
|
|
1090
1114
|
sb_config._saved_width_ratio = width_ratio
|
1091
1115
|
driver.minimize_window()
|
1092
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)
|
1093
1132
|
if ctype == "cf_t":
|
1094
1133
|
if (
|
1095
1134
|
driver.is_element_present(".cf-turnstile-wrapper iframe")
|
@@ -1201,10 +1240,10 @@ def _uc_gui_click_captcha(
|
|
1201
1240
|
element = driver.wait_for_element_present(
|
1202
1241
|
selector, timeout=2.5
|
1203
1242
|
)
|
1204
|
-
x = i_x + element.rect["x"] +
|
1205
|
-
x +=
|
1206
|
-
y = i_y + element.rect["y"] +
|
1207
|
-
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
|
1208
1247
|
else:
|
1209
1248
|
x = (i_x + 34) * width_ratio
|
1210
1249
|
y = (i_y + 34) * width_ratio
|
@@ -1218,12 +1257,18 @@ def _uc_gui_click_captcha(
|
|
1218
1257
|
return
|
1219
1258
|
if x and y:
|
1220
1259
|
sb_config._saved_cf_x_y = (x, y)
|
1221
|
-
if driver
|
1222
|
-
driver.
|
1223
|
-
|
1224
|
-
|
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()
|
1225
1267
|
with suppress(Exception):
|
1226
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
|
1227
1272
|
reconnect_time = (float(constants.UC.RECONNECT_TIME) / 2.0) + 0.6
|
1228
1273
|
if IS_LINUX:
|
1229
1274
|
reconnect_time = constants.UC.RECONNECT_TIME + 0.2
|