Skip to content

Commit 66f60d5

Browse files
committed
Update examples
1 parent 54e20c0 commit 66f60d5

File tree

2 files changed

+29
-10
lines changed

2 files changed

+29
-10
lines changed

examples/cdp_mode/raw_mouse_drag.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from seleniumbase import SB
2+
3+
with SB(uc=True, test=True, incognito=True) as sb:
4+
url = "https://seleniumbase.io/other/drag_and_drop"
5+
sb.activate_cdp_mode(url)
6+
sb.assert_element_not_visible("#div1 img#drag1")
7+
sb.cdp.gui_drag_and_drop("#drag1", "#div1")
8+
sb.assert_element("#div1 img#drag1")
9+
sb.sleep(1)
10+
11+
with SB(uc=True, test=True, incognito=True) as sb:
12+
url = "https://jqueryui.com/draggable/"
13+
sb.activate_cdp_mode(url)
14+
sb.switch_to_frame("iframe")
15+
x, y = sb.get_gui_element_center("#draggable")
16+
sb.switch_to_default_content()
17+
sb.scroll_to_top()
18+
sb.cdp.gui_drag_drop_points(x, y, x + 180, y + 90)
19+
sb.cdp.gui_drag_drop_points(x + 180, y + 90, x + 60, y + 120)
20+
sb.cdp.gui_drag_drop_points(x + 60, y + 120, x + 40, y + 40)
21+
sb.sleep(1)

examples/cdp_mode/raw_socialblade.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,21 @@
55
url = "https://socialblade.com/"
66
sb.activate_cdp_mode(url)
77
sb.sleep(1.5)
8-
sb.uc_gui_click_captcha()
9-
sb.sleep(0.5)
8+
if not sb.is_element_visible('input[placeholder*="Search"]'):
9+
sb.uc_gui_click_captcha()
10+
sb.sleep(0.5)
1011
channel_name = "michaelmintz"
1112
channel_title = "Michael Mintz"
1213
sb.cdp.press_keys('input[placeholder*="Search"]', channel_name)
13-
sb.sleep(1.5)
14+
sb.sleep(2)
1415
sb.cdp.click('a:contains("%s")' % channel_title)
1516
sb.sleep(2)
1617
sb.cdp.remove_elements("#lngtd-top-sticky")
1718
sb.sleep(1.5)
18-
name = sb.cdp.get_text("h1")
19-
source = sb.get_page_source()
20-
base = "https://www.youtube.com/c/"
21-
base2 = 'href="/youtube/c/'
22-
start = source.find(base2) + len(base2)
23-
end = source.find('"', start)
24-
link = base + source[start:end]
19+
name = sb.cdp.get_text("h3")
20+
ch_name = name.split(" ")[-1]
21+
name = name.split(" @")[0]
22+
link = "https://www.youtube.com/%s" % ch_name
2523
print("********** SocialBlade Stats for %s: **********" % name)
2624
print(">>> (Link: %s) <<<" % link)
2725
print(sb.get_text('[class*="grid lg:hidden"]'))

0 commit comments

Comments
 (0)