Skip to content

Commit cd38f86

Browse files
committedJan 9, 2025
Update examples
1 parent 04719e5 commit cd38f86

File tree

3 files changed

+167
-1
lines changed

3 files changed

+167
-1
lines changed
 

‎examples/cdp_mode/ReadMe.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,16 @@
66

77
--------
88

9-
<!-- YouTube View --><a href="https://www.youtube.com/watch?v=Mr90iQmNsKM"><img src="http://img.youtube.com/vi/Mr90iQmNsKM/0.jpg" title="SeleniumBase on YouTube" width="366" /></a>
9+
<!-- YouTube View --><a href="https://www.youtube.com/watch?v=Mr90iQmNsKM"><img src="https://github.com/user-attachments/assets/91e7ff7b-d155-4ba9-b17b-b097825fcf42" title="SeleniumBase on YouTube" width="350" /></a>
1010
<p>(<b><a href="https://www.youtube.com/watch?v=Mr90iQmNsKM">Watch the CDP Mode tutorial on YouTube! ▶️</a></b>)</p>
1111

1212
--------
1313

14+
<!-- YouTube View --><a href="https://www.youtube.com/watch?v=vt2zsdiNh3U"><img src="https://github.com/user-attachments/assets/82ab2715-727e-4d09-9314-b8905795dc43" title="SeleniumBase on YouTube" width="350" /></a>
15+
<p>(<b><a href="https://www.youtube.com/watch?v=vt2zsdiNh3U">Watch "Hacking websites with CDP" on YouTube! ▶️</a></b>)</p>
16+
17+
--------
18+
1419
👤 <b translate="no">UC Mode</b> avoids bot-detection by first disconnecting WebDriver from the browser at strategic times, calling special <code>PyAutoGUI</code> methods to bypass CAPTCHAs (as needed), and finally reconnecting the <code>driver</code> afterwards so that WebDriver actions can be performed again. Although this approach works for bypassing simple CAPTCHAs, more flexibility is needed for bypassing bot-detection on websites with advanced protection. (That's where <b translate="no">CDP Mode</b> comes in.)
1520

1621
🐙 <b translate="no">CDP Mode</b> is based on <a href="https://github.com/HyperionGray/python-chrome-devtools-protocol" translate="no">python-cdp</a>, <a href="https://github.com/HyperionGray/trio-chrome-devtools-protocol" translate="no">trio-cdp</a>, and <a href="https://github.com/ultrafunkamsterdam/nodriver" translate="no">nodriver</a>. <code>trio-cdp</code> is an early implementation of <code>python-cdp</code>, and <code>nodriver</code> is a modern implementation of <code>python-cdp</code>. (Refactored <code>Python-CDP</code> code is imported from <a href="https://github.com/mdmintz/MyCDP" translate="no">MyCDP</a>.)
+146
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
# https://www.youtube.com/watch?v=vt2zsdiNh3U
2+
from seleniumbase import BaseCase
3+
BaseCase.main(__name__, __file__)
4+
5+
6+
class UCPresentationClass(BaseCase):
7+
def test_hacking_with_cdp(self):
8+
self.open("data:,")
9+
self.set_window_position(4, 40)
10+
self._output_file_saves = False
11+
self.create_presentation(theme="serif", transition="none")
12+
self.add_slide("<h2>Press SPACE to begin!</h2>\n")
13+
self.add_slide(
14+
"<p><h3><mk-0>Coming up on the Hacker Show...</mk-0></h3></p>\n"
15+
"<hr /><ul>\n"
16+
'<img src="https://seleniumbase.io/other/hackers_at_comp.jpg"'
17+
' width="100%">'
18+
"</ul>",
19+
)
20+
self.add_slide(
21+
"<p><b>Coming up on the Hacker Show...</b></p>\n"
22+
"<hr /><br /><ul>\n"
23+
"<li><mk-0>Intercepting requests/responses/XHR with CDP."
24+
"</mk-0></li><br />\n"
25+
"<br /><br />\n"
26+
"<br /><br />\n"
27+
"<br /><br />\n"
28+
"<br /><br />\n"
29+
"</ul>",
30+
)
31+
self.add_slide(
32+
"<p><b>Coming up on the Hacker Show...</b></p>\n"
33+
"<hr /><br /><ul>\n"
34+
"<li>Intercepting requests/responses/XHR with CDP."
35+
"</li><br />\n"
36+
"<li><mk-0>Modifying requests: CDP.Fetch.continueRequest."
37+
"</mk-0></li><br />\n"
38+
"<br /><br />\n"
39+
"<br /><br />\n"
40+
"<br /><br />\n"
41+
"</ul>",
42+
)
43+
self.add_slide(
44+
"<p><b>Coming up on the Hacker Show...</b></p>\n"
45+
"<hr /><br /><ul>\n"
46+
"<li>Intercepting requests/responses/XHR with CDP."
47+
"</li><br />\n"
48+
"<li>Modifying requests: CDP.Fetch.continueRequest."
49+
"</li><br />\n"
50+
"<li><mk-0>Controlling browsers via remote-debugging-port"
51+
"</mk-0></li><br />\n"
52+
"<br /><br />\n"
53+
"<br /><br />\n"
54+
"</ul>",
55+
)
56+
self.add_slide(
57+
"<p><b>Coming up on the Hacker Show...</b></p>\n"
58+
"<hr /><br /><ul>\n"
59+
"<li>Intercepting requests/responses/XHR with CDP."
60+
"</li><br />\n"
61+
"<li>Modifying requests: CDP.Fetch.continueRequest."
62+
"</li><br />\n"
63+
"<li>Controlling browsers via remote-debugging-port"
64+
"</li><br />\n"
65+
"<li><mk-0>Bypassing CAPTCHAs & anti-bot defenses."
66+
"</mk-0></li><br />\n"
67+
"<br /><br />\n"
68+
"</ul>",
69+
)
70+
self.add_slide(
71+
"<p><b>Coming up on the Hacker Show...</b></p>\n"
72+
"<hr /><br /><ul>\n"
73+
"<li>Intercepting requests/responses/XHR with CDP."
74+
"</li><br />\n"
75+
"<li>Modifying requests: CDP.Fetch.continueRequest."
76+
"</li><br />\n"
77+
"<li>Controlling browsers via remote-debugging-port"
78+
"</li><br />\n"
79+
"<li>Bypassing CAPTCHAs & anti-bot defenses."
80+
"</li><br />\n"
81+
"<li><mk-0>And live demos of all the above... with Python!"
82+
"</mk-0></li><br />\n"
83+
"</ul>",
84+
)
85+
self.add_slide(
86+
"<h2>Get ready for some<br />serious hacking!</h2>"
87+
)
88+
self.add_slide(
89+
'<img src="https://seleniumbase.io/other/hacking_with_cdp.jpg"'
90+
' width="100%">'
91+
)
92+
self.add_slide(
93+
'<img src="https://seleniumbase.io/other/cdp.jpg"'
94+
' width="100%">'
95+
)
96+
self.add_slide(
97+
'<img src="https://seleniumbase.io/other/ms_edp.jpg"'
98+
' width="100%">'
99+
)
100+
self.add_slide(
101+
'<img src="https://seleniumbase.io/other/vid4_on_yt.jpg"'
102+
' width="100%">'
103+
)
104+
self.add_slide(
105+
'<img src="https://seleniumbase.io/other/cdp_in_sb.jpg"'
106+
' width="100%">'
107+
)
108+
self.add_slide(
109+
'<img src="https://seleniumbase.io/other/hacker_news.png"'
110+
' width="100%">'
111+
)
112+
self.add_slide(
113+
'<img src="https://seleniumbase.io/other/sb_star_history_3.png"'
114+
' width="100%">'
115+
)
116+
self.add_slide(
117+
'<img src="https://seleniumbase.io/other/top_trending_month.png"'
118+
' width="100%">'
119+
)
120+
self.add_slide(
121+
'<img src="https://seleniumbase.io/other/cdp_con_req.jpg"'
122+
' width="100%">'
123+
)
124+
self.add_slide(
125+
'<img src="https://seleniumbase.io/other/mycdp_con_req.jpg"'
126+
' width="100%">'
127+
)
128+
self.add_slide(
129+
'<img src="https://seleniumbase.io/other/sb_con_req.jpg"'
130+
' width="100%">'
131+
)
132+
self.add_slide(
133+
'<img src="https://seleniumbase.io/other/xhr_info.jpg"'
134+
' width="100%">'
135+
)
136+
self.add_slide(
137+
'<h3>The <code>remote-debugging-port</code></h3>'
138+
'<img src="https://seleniumbase.io/other/rd_port.jpg"'
139+
' width="100%">'
140+
)
141+
self.add_slide(
142+
"<h3>Let's get to the fun part...</h3>"
143+
'<img src="https://seleniumbase.io/other/hackers_at_comp.jpg"'
144+
' width="80%">'
145+
)
146+
self.begin_presentation(filename="uc_presentation.html")

‎examples/raw_skype_mobile.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""Mobile emulation test for Skype."""
2+
from seleniumbase import SB
3+
4+
with SB(mobile=True, test=True) as sb:
5+
sb.open("https://www.skype.com/en/get-skype/")
6+
sb.assert_element('[aria-label="Microsoft"]')
7+
sb.assert_text("Download Skype", "h1")
8+
sb.highlight("div.appBannerContent")
9+
sb.highlight("h1")
10+
sb.assert_text("Skype for Mobile", "h2")
11+
sb.highlight("h2")
12+
sb.highlight("#get-skype-0")
13+
sb.highlight_click("span[data-dropdown-icon]")
14+
sb.highlight("#get-skype-0_android-download")
15+
sb.highlight('[data-bi-id*="ios"]')

0 commit comments

Comments
 (0)
Please sign in to comment.