Skip to content

Commit 9bf7057

Browse files
committed
Update the ReadMe
1 parent 8e72c04 commit 9bf7057

File tree

1 file changed

+36
-11
lines changed

1 file changed

+36
-11
lines changed

README.md

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,43 +65,68 @@
6565

6666
--------
6767

68-
<p align="left">📗 Here's <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/raw_google.py">raw_google.py</a>, which performs a Google search:</p>
68+
<p align="left">📗 For performing a Google Search without hitting the "unusual traffic" page, you can use SeleniumBase UC Mode. Here's <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/raw_google.py">SeleniumBase/examples/raw_google.py</a>, which exports the search results into different formats (PDF, HTML, PNG):</p>
6969

7070
```python
7171
from seleniumbase import SB
7272

7373
with SB(test=True, uc=True) as sb:
7474
sb.open("https://google.com/ncr")
75-
sb.type('[title="Search"]', "SeleniumBase GitHub page\n")
76-
sb.click('[href*="github.com/seleniumbase/"]')
77-
sb.save_screenshot_to_logs() # ./latest_logs/
75+
sb.type('[title="Search"]', "SeleniumBase GitHub page")
76+
sb.click("div:not([jsname]) > * > input")
7877
print(sb.get_page_title())
78+
sb.sleep(2) # Wait for the "AI Overview" result
79+
if sb.is_text_visible("Generating"):
80+
sb.wait_for_text("AI Overview")
81+
sb.save_as_pdf_to_logs() # Saved to ./latest_logs/
82+
sb.save_page_source_to_logs()
83+
sb.save_screenshot_to_logs()
7984
```
8085

8186
> `python raw_google.py`
8287
83-
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/raw_google.py"><img src="https://seleniumbase.github.io/cdn/gif/google_search.gif" alt="SeleniumBase Test" title="SeleniumBase Test" width="480" /></a>
88+
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/raw_google.py"><img src="https://seleniumbase.github.io/cdn/img/google_sb_result.png" alt="SeleniumBase on Google" title="SeleniumBase on Google" width="440" /></a>
8489

8590
--------
8691

87-
<p align="left">📗 Here's an example of bypassing Cloudflare's challenge page: <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/cdp_mode/raw_gitlab.py">SeleniumBase/examples/cdp_mode/raw_gitlab.py</a></p>
92+
<p align="left">📗 Here's an example of bypassing Cloudflare's challenge page with UC Mode + CDP Mode: <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/cdp_mode/raw_gitlab.py">SeleniumBase/examples/cdp_mode/raw_gitlab.py</a></p>
8893

8994
```python
9095
from seleniumbase import SB
9196

9297
with SB(uc=True, test=True, locale="en") as sb:
9398
url = "https://gitlab.com/users/sign_in"
9499
sb.activate_cdp_mode(url)
95-
sb.sleep(1)
100+
sb.sleep(2.2)
96101
sb.uc_gui_click_captcha()
97-
sb.sleep(2)
102+
sb.assert_text("Username", '[for="user_login"]', timeout=3)
103+
sb.assert_element('label[for="user_login"]')
104+
sb.highlight('button:contains("Sign in")')
105+
sb.highlight('h1:contains("GitLab.com")')
106+
sb.post_message("SeleniumBase wasn't detected", duration=4)
98107
```
99108

100109
<img src="https://seleniumbase.github.io/other/cf_sec.jpg" title="SeleniumBase" width="332"> <img src="https://seleniumbase.github.io/other/gitlab_bypass.png" title="SeleniumBase" width="288">
101110

111+
<p align="left">📙 You can also use SeleniumBase's pure CDP Mode, which doesn't use chromedriver, Selenium, or a Python context manager at all: <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/cdp_mode/raw_cdp_gitlab.py">SeleniumBase/examples/cdp_mode/raw_cdp_gitlab.py</a></p>
112+
113+
```python
114+
from seleniumbase import sb_cdp
115+
116+
url = "https://gitlab.com/users/sign_in"
117+
sb = sb_cdp.Chrome(url)
118+
sb.sleep(2.5)
119+
sb.gui_click_captcha()
120+
sb.highlight('h1:contains("GitLab.com")')
121+
sb.highlight('button:contains("Sign in")')
122+
sb.driver.stop()
123+
```
124+
125+
> (Due to a change in Chrome 137 where the --load-extension switch was removed, one limitation with this format is that you can't load extensions directly. The other formats weren't affected by this change.)
126+
102127
--------
103128

104-
<p align="left">📗 Here's <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_get_swag.py">test_get_swag.py</a>, which tests an e-commerce site:</p>
129+
<p align="left">📗 Here's <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_get_swag.py">SeleniumBase/examples/test_get_swag.py</a>, which tests an e-commerce site:</p>
105130

106131
```python
107132
from seleniumbase import BaseCase
@@ -133,7 +158,7 @@ class MyTestClass(BaseCase):
133158
134159
--------
135160

136-
<p align="left">📗 Here's <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_coffee_cart.py" target="_blank">test_coffee_cart.py</a>, which verifies an e-commerce site:</p>
161+
<p align="left">📗 Here's <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_coffee_cart.py" target="_blank">SeleniumBase/examples/test_coffee_cart.py</a>, which verifies an e-commerce site:</p>
137162

138163
```zsh
139164
pytest test_coffee_cart.py --demo
@@ -147,7 +172,7 @@ pytest test_coffee_cart.py --demo
147172

148173
<a id="multiple_examples"></a>
149174

150-
<p align="left">📗 Here's <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_demo_site.py" target="_blank">test_demo_site.py</a>, which covers several actions:</p>
175+
<p align="left">📗 Here's <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_demo_site.py" target="_blank">SeleniumBase/examples/test_demo_site.py</a>, which covers several actions:</p>
151176

152177
```zsh
153178
pytest test_demo_site.py

0 commit comments

Comments
 (0)