Skip to content

Commit fab150b

Browse files
committed
Update examples
1 parent 111f8ee commit fab150b

File tree

6 files changed

+40
-38
lines changed

6 files changed

+40
-38
lines changed

examples/presenter/uc_presentation.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ def test_presentation(self):
3030
self.get_new_driver(undetectable=True)
3131
url = "https://gitlab.com/users/sign_in"
3232
try:
33-
self.driver.uc_open_with_reconnect(url, reconnect_time=3)
33+
self.uc_open_with_reconnect(url, reconnect_time=3)
3434
try:
3535
self.assert_text("Username", '[for="user_login"]', timeout=3)
3636
self.post_message("SeleniumBase wasn't detected", duration=4)
3737
except Exception:
38-
self.driver.uc_open_with_reconnect(url, reconnect_time=4)
38+
self.uc_open_with_reconnect(url, reconnect_time=4)
3939
self.assert_text("Username", '[for="user_login"]', timeout=3)
4040
self.post_message("SeleniumBase wasn't detected", duration=4)
4141
finally:
@@ -249,8 +249,7 @@ def test_presentation(self):
249249
code=(
250250
"<mk-1>from seleniumbase import SB</mk-1>\n\n"
251251
"<mk-2>with SB(uc=True) as sb:</mk-2>\n"
252-
' <mk-3>sb.driver.get('
253-
'"https://seleniumbase.io/simple/login")</mk-3>\n'
252+
' <mk-3>sb.get("seleniumbase.io/simple/login")</mk-3>\n'
254253
' <mk-4>sb.type("#username", "demo_user")</mk-4>\n'
255254
' <mk-5>sb.type("#password", "secret_pass")</mk-5>\n'
256255
' <mk-6>sb.click(\'a:contains("Sign in")\')</mk-6>\n'
@@ -266,7 +265,7 @@ def test_presentation(self):
266265

267266
try:
268267
with SB(uc=True) as sb:
269-
sb.driver.get("https://seleniumbase.io/simple/login")
268+
sb.get("https://seleniumbase.io/simple/login")
270269
sb.type("#username", "demo_user")
271270
sb.type("#password", "secret_pass")
272271
sb.click('a:contains("Sign in")')
@@ -285,7 +284,7 @@ def test_presentation(self):
285284
code=(
286285
"from seleniumbase import SB\n\n"
287286
"with SB(uc=True<mk-1>, demo=True</mk-1>) as sb:\n"
288-
' sb.driver.get('
287+
' sb.get('
289288
'"https://seleniumbase.io/simple/login")\n'
290289
' sb.type("#username", "demo_user")\n'
291290
' sb.type("#password", "secret_pass")\n'
@@ -301,7 +300,7 @@ def test_presentation(self):
301300

302301
try:
303302
with SB(uc=True, demo=True) as sb:
304-
sb.driver.get("https://seleniumbase.io/simple/login")
303+
sb.get("https://seleniumbase.io/simple/login")
305304
sb.type("#username", "demo_user")
306305
sb.type("#password", "secret_pass")
307306
sb.click('a:contains("Sign in")')
@@ -340,11 +339,11 @@ def test_presentation(self):
340339
code=(
341340
"from seleniumbase import SB\n\n"
342341
"with SB(uc=True) as sb:\n"
343-
' sb.driver.get("https://nowsecure.nl/#relax")\n'
342+
' sb.get("https://nowsecure.nl/#relax")\n'
344343
" sb.sleep(1)\n"
345344
' if not sb.is_text_visible("OH YEAH, you passed", "h1"):\n'
346345
" sb.get_new_driver(undetectable=True)\n"
347-
' sb.driver.get("https://nowsecure.nl/#relax")\n'
346+
' sb.get("https://nowsecure.nl/#relax")\n'
348347
" sb.sleep(1)\n"
349348
' sb.activate_demo_mode()\n'
350349
' sb.assert_text("OH YEAH, you passed!", "h1", timeout=3)\n'
@@ -354,10 +353,10 @@ def test_presentation(self):
354353

355354
try:
356355
with SB(uc=True) as sb:
357-
sb.driver.uc_open_with_tab("https://nowsecure.nl/#relax")
356+
sb.uc_open_with_tab("https://nowsecure.nl/#relax")
358357
sb.sleep(1)
359358
if not sb.is_text_visible("OH YEAH, you passed", "h1"):
360-
sb.driver.uc_open_with_tab("https://nowsecure.nl/#relax")
359+
sb.uc_open_with_tab("https://nowsecure.nl/#relax")
361360
sb.sleep(1)
362361
sb.activate_demo_mode()
363362
sb.assert_text("OH YEAH, you passed!", "h1", timeout=3)

examples/presenter/uc_presentation_3.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def test_presentation_3(self):
1818
self.begin_presentation(filename="uc_presentation.html")
1919

2020
self.open("https://seleniumbase.io/other/uc3_title.jpg")
21-
self.sleep(3)
21+
self.sleep(2.5)
2222

2323
self.create_presentation(theme="serif", transition="fade")
2424
self.add_slide(
@@ -108,11 +108,11 @@ def test_presentation_3(self):
108108
"<p><mk-0>Special <b>UC Mode</b> methods for clicking CAPTCHAs:"
109109
"</mk-0></p><hr /><div></div>"
110110
"<ul><br />\n"
111-
"<li><mk-1><code><b>uc_gui_handle_captcha()</b></code></mk-1></li>"
112-
"\n"
111+
"<li><mk-1><code><b>sb.uc_gui_handle_captcha()</b></code></mk-1>"
112+
"</li>\n"
113113
"PyAutoGUI uses the TAB key with SPACEBAR.<br /><br />\n\n"
114-
"<li><mk-2><code><b>uc_gui_click_captcha()</b></code></mk-2></li>"
115-
"\n\n"
114+
"<li><mk-2><code><b>sb.uc_gui_click_captcha()</b></code></mk-2>"
115+
"</li>\n\n"
116116
"PyAutoGUI clicks CAPTCHA with the mouse.<br />\n"
117117
"(Note that you'll need to use this one on Linux!)\n"
118118
"</ul>\n\n\n\n"
@@ -171,7 +171,7 @@ def test_presentation_3(self):
171171
"<mk-2>with SB(uc=True) as sb:</mk-2>\n"
172172
'<mk-3> url = "https://gitlab.com/users/sign_in"</mk-3>\n'
173173
"<mk-4> sb.uc_open_with_reconnect(url, 4)</mk-4>\n"
174-
"<mk-5> uc_gui_handle_captcha()</mk-5>\n\n"
174+
"<mk-5> sb.uc_gui_handle_captcha()</mk-5>\n\n"
175175
"<mk-6> ...</mk-6>\n\n\n\n\n\n"
176176
),
177177
)
@@ -183,7 +183,7 @@ def test_presentation_3(self):
183183
"with SB(uc=True) as sb:\n"
184184
' url = "https://gitlab.com/users/sign_in"\n'
185185
" sb.uc_open_with_reconnect(url, 4)\n"
186-
" uc_gui_handle_captcha()\n\n"
186+
" sb.uc_gui_handle_captcha()\n\n"
187187
'<mk-1> sb.assert_text("Username", \'[for="user_login"]\','
188188
' timeout=3)</mk-1>\n'
189189
'<mk-2> sb.assert_element(\'[for="user_login"]\')</mk-2>\n'
@@ -221,7 +221,7 @@ def test_presentation_3(self):
221221
"<mk-2>with SB(uc=True) as sb:</mk-2>\n"
222222
'<mk-3> url = "https://gitlab.com/users/sign_in"</mk-3>\n'
223223
"<mk-4> sb.uc_open_with_reconnect(url, 4)</mk-4>\n"
224-
"<mk-5> uc_gui_click_captcha()</mk-5>\n\n"
224+
"<mk-5> sb.uc_gui_click_captcha()</mk-5>\n\n"
225225
"<mk-6> ...</mk-6>\n\n\n\n\n"
226226
),
227227
)
@@ -233,7 +233,7 @@ def test_presentation_3(self):
233233
"with SB(uc=True) as sb:\n"
234234
' url = "https://gitlab.com/users/sign_in"\n'
235235
" sb.uc_open_with_reconnect(url, 4)\n"
236-
" uc_gui_click_captcha()\n\n"
236+
" sb.uc_gui_click_captcha()\n\n"
237237
'<mk-1> sb.assert_text("Username", \'[for="user_login"]\','
238238
' timeout=3)</mk-1>\n'
239239
'<mk-2> sb.assert_element(\'[for="user_login"]\')</mk-2>\n'
@@ -252,8 +252,8 @@ def test_presentation_3(self):
252252
"<li><mk-2>Navigate with stealth by calling "
253253
"<code><b>sb.uc_open_with_reconnect(url)</b></code>"
254254
"</mk-2></li><br />\n"
255-
"<li><mk-3>Use <code><b>uc_gui_handle_captcha()</b></code>"
256-
" or <code><b>uc_gui_click_captcha()</b></code>"
255+
"<li><mk-3>Use <code><b>sb.uc_gui_handle_captcha()</b></code>"
256+
" or <code><b>sb.uc_gui_click_captcha()</b></code>"
257257
" to bypass CAPTCHAs as needed.</mk-3></li>\n"
258258
"</ul>\n"
259259
"<p><br /><mk-4>(It's that easy!)</mk-4></p><br />\n"
@@ -263,7 +263,7 @@ def test_presentation_3(self):
263263
"<hr /><div></div><br />"
264264
"<ul>\n"
265265
"<li><mk-1>Previous tutorials mentioned this method:<br />"
266-
"<code><b>uc_click(selector)</b></code>"
266+
"<code><b>sb.uc_click(selector)</b></code>"
267267
"</mk-1></li><br />\n"
268268
"<mk-2>Although this method can no longer click a<br />"
269269
"CAPTCHA directly, it should be used when<br />"
@@ -281,7 +281,7 @@ def test_presentation_3(self):
281281
url = "https://ahrefs.com/website-authority-checker"
282282
input_field = 'input[placeholder="Enter domain"]'
283283
submit_button = 'span:contains("Check Authority")'
284-
sb.uc_open_with_reconnect(url, 2) # The bot-check is later
284+
sb.uc_open_with_reconnect(url) # The bot-check is later
285285
sb.type(input_field, "github.com/seleniumbase/SeleniumBase")
286286
sb.reconnect(0.1)
287287
sb.uc_click(submit_button, reconnect_time=4)
@@ -349,7 +349,7 @@ def test_presentation_3(self):
349349
' url = "https://steamdb.info/"\n'
350350
" sb.uc_open_with_reconnect(url, 3)\n"
351351
' sb.uc_click("a.header-login span", 3)\n\n'
352-
"<mk-0> uc_gui_click_captcha()</mk-0>\n"
352+
"<mk-0> sb.uc_gui_click_captcha()</mk-0>\n"
353353
'<mk-1> sb.assert_text("Sign in", "button#js-sign-in",'
354354
' timeout=3)</mk-1>\n'
355355
'<mk-2> sb.uc_click("button#js-sign-in", 2)</mk-2>\n'
@@ -726,7 +726,7 @@ def test_presentation_3(self):
726726
"<p>👤 <mk-0>The plan to handle real-time bot-scanning</mk-0> 👤</p>"
727727
"<hr /><h6><br /></h6>"
728728
"<p>"
729-
'<pre><code>uc_gui_click_captcha(frame="iframe", retry=False,'
729+
'<pre><code>sb.uc_gui_click_captcha(frame="iframe", retry=False,'
730730
' <mk-1>blind=True</mk-1>)</code></pre><br /><mk-1>'
731731
'Set the third arg, `blind`, to `True` to force a retry'
732732
' (if the first click failed) by clicking at the last known'

examples/raw_ahrefs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
url = "https://ahrefs.com/website-authority-checker"
55
input_field = 'input[placeholder="Enter domain"]'
66
submit_button = 'span:contains("Check Authority")'
7-
sb.uc_open_with_reconnect(url, 2) # The bot-check is later
7+
sb.uc_open_with_reconnect(url) # The bot-check is later
88
sb.type(input_field, "github.com/seleniumbase/SeleniumBase")
99
sb.reconnect(0.1)
1010
sb.uc_click(submit_button, reconnect_time=4)
1111
sb.uc_gui_click_captcha()
12-
sb.wait_for_text_not_visible("Checking", timeout=10)
12+
sb.wait_for_text_not_visible("Checking", timeout=12)
1313
sb.highlight('p:contains("github.com/seleniumbase/SeleniumBase")')
1414
sb.highlight('a:contains("Top 100 backlinks")')
1515
sb.set_messenger_theme(location="bottom_center")

examples/raw_cf.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
"""SB Manager using UC Mode & PyAutoGUI for bypassing CAPTCHAs."""
22
from seleniumbase import SB
33

4-
with SB(uc=True, test=True) as sb:
4+
with SB(uc=True, test=True, locale_code="en") as sb:
55
url = "https://www.cloudflare.com/login"
6-
sb.uc_open_with_reconnect(url, 5)
6+
sb.uc_open_with_reconnect(url, 5.5)
77
sb.uc_gui_handle_captcha() # PyAutoGUI press Tab and Spacebar
88
sb.sleep(2.5)
99

10-
with SB(uc=True, test=True) as sb:
10+
with SB(uc=True, test=True, locale_code="en") as sb:
1111
url = "https://www.cloudflare.com/login"
12-
sb.uc_open_with_reconnect(url, 5)
12+
sb.uc_open_with_reconnect(url, 5.5)
1313
sb.uc_gui_click_captcha() # PyAutoGUI click. (Linux needs it)
1414
sb.sleep(2.5)

examples/raw_order_tickets.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from seleniumbase import SB
22

33
with SB(uc=True, test=True, ad_block=True) as sb:
4-
url = "https://www.thaiticketmajor.com/concert/"
4+
url = "https://www.thaiticketmajor.com/concert/#"
55
sb.uc_open_with_reconnect(url, 6.111)
66
sb.uc_click("button.btn-signin", 4.1)
77
sb.uc_gui_click_captcha()
8+
sb.sleep(2)

examples/raw_pixelscan.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
with SB(uc=True, incognito=True, test=True) as sb:
44
sb.driver.uc_open_with_reconnect("https://pixelscan.net/", 10)
55
sb.remove_elements("jdiv") # Remove chat widgets
6-
sb.assert_text("No automation framework detected", "pxlscn-bot-detection")
7-
not_masking = "You are not masking your fingerprint"
8-
sb.assert_text(not_masking, "pxlscn-fingerprint-masking")
6+
no_automation_detected = "No automation framework detected"
7+
sb.assert_text(no_automation_detected, "pxlscn-bot-detection")
8+
not_masking_text = "You are not masking your fingerprint"
9+
sb.assert_text(not_masking_text, "pxlscn-fingerprint-masking")
910
sb.highlight("span.text-success", loops=8)
1011
sb.sleep(1)
11-
sb.highlight("pxlscn-fingerprint-masking div", loops=9, scroll=False)
12+
fingerprint_masking_div = "pxlscn-fingerprint-masking div"
13+
sb.highlight(fingerprint_masking_div, loops=9, scroll=False)
1214
sb.sleep(1)
13-
sb.highlight("div.bot-detection-context", loops=10, scroll=False)
15+
sb.highlight(".bot-detection-context", loops=10, scroll=False)
1416
sb.sleep(2)

0 commit comments

Comments
 (0)