Skip to content

Commit 649591c

Browse files
committed
Update examples
1 parent 7f8a318 commit 649591c

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

examples/cdp_mode/raw_indeed_login.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""An example of clicking at custom CAPTCHA coordinates."""
2+
from seleniumbase import SB
3+
4+
with SB(uc=True, test=True, locale="en") as sb:
5+
url = "https://www.indeed.com/"
6+
sb.activate_cdp_mode(url)
7+
sb.sleep(1)
8+
sb.click('[data-gnav-element-name="SignIn"] a')
9+
sb.uc_gui_click_captcha()
10+
sb.type('input[type="email"]', "[email protected]")
11+
sb.sleep(1)
12+
sb.click('button[type="submit"]')
13+
sb.sleep(3.5)
14+
selector = 'div[class*="pass-Captcha"]'
15+
element_rect = sb.cdp.get_gui_element_rect(selector, timeout=1)
16+
x = element_rect["x"] + 32
17+
y = element_rect["y"] + 44
18+
sb.cdp.gui_click_x_y(x, y)
19+
sb.sleep(4.5)

examples/raw_no_context_mgr.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""SB() without the context manager `with` block."""
2+
from seleniumbase import SB
3+
4+
sb_context = SB()
5+
sb = sb_context.__enter__()
6+
sb.open("data:text/html,<h1>Test Page</h1>")
7+
sb.highlight("h1", loops=8)
8+
sb_context.__exit__(None, None, None)
9+
10+
"""Same example using `with`:
11+
from seleniumbase import SB
12+
13+
with SB() as sb:
14+
sb.open("data:text/html,<h1>Test Page</h1>")
15+
sb.highlight("h1", loops=8)
16+
"""

0 commit comments

Comments
 (0)