|
7 | 7 | <!-- YouTube View --><a href="https://www.youtube.com/watch?v=5dMFI3e85ig"><img src="http://img.youtube.com/vi/5dMFI3e85ig/0.jpg" title="SeleniumBase on YouTube" width="400" /></a>
|
8 | 8 | <!-- GitHub Only --><p>(<b><a href="https://www.youtube.com/watch?v=5dMFI3e85ig">Watch the UC Mode tutorial on YouTube! ▶️</a></b>)</p>
|
9 | 9 |
|
10 |
| -👤 <b translate="no">UC Mode</b> is based on [undetected-chromedriver](https://github.com/ultrafunkamsterdam/undetected-chromedriver), but includes multiple updates, fixes, and improvements to support a wider range of features and edge cases: |
| 10 | +👤 <b translate="no">UC Mode</b> is based on [undetected-chromedriver](https://github.com/ultrafunkamsterdam/undetected-chromedriver), but includes multiple updates, fixes, and improvements, such as: |
11 | 11 |
|
12 |
| -* Automatically changes the user agent to prevent detection. |
13 |
| -* Supports multithreaded tests in parallel via `pytest-xdist`. |
14 |
| -* Adjusts some configuration based on the environment. |
15 |
| -* Includes driver version-detection and management. |
16 |
| -* Has options for setting proxy and proxy-with-auth. |
17 |
| -* Has args for adjusting timings from default values. |
18 |
| -* Includes multiple ways of structuring test scripts. |
| 12 | +* Automatically changing user agents to prevent detection. |
| 13 | +* Automatically setting various chromium args as needed. |
| 14 | +* Has special methods. Eg. `driver.uc_click(selector)` |
19 | 15 |
|
20 | 16 | 👤 Here's an example with the <b><code translate="no">Driver</code></b> manager:
|
21 | 17 |
|
@@ -83,6 +79,10 @@ with SB(uc=True, test=True) as sb:
|
83 | 79 |
|
84 | 80 | --------
|
85 | 81 |
|
| 82 | +👤 In <b translate="no">UC Mode</b>, <code translate="no">driver.get(url)</code> has been modified from its original version: If anti-bot services are detected from a <code translate="no">requests.get(url)</code> call that's made before navigating to the website, then <code translate="no">driver.uc_open_with_reconnect(url)</code> will be used instead. To open a URL normally in <b translate="no">UC Mode</b>, use <code translate="no">driver.default_get(url)</code>. |
| 83 | + |
| 84 | +-------- |
| 85 | + |
86 | 86 | ### 👤 Here are some examples that use UC Mode:
|
87 | 87 | * [SeleniumBase/examples/verify_undetected.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/verify_undetected.py)
|
88 | 88 | * [SeleniumBase/examples/raw_bing_captcha.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/raw_bing_captcha.py)
|
@@ -212,21 +212,25 @@ with ThreadPoolExecutor(max_workers=len(urls)) as executor:
|
212 | 212 | from seleniumbase import SB
|
213 | 213 |
|
214 | 214 | with SB(uc=True, test=True) as sb:
|
215 |
| - sb.driver.uc_open_with_reconnect("nopecha.com/demo/turnstile", 4.5) |
216 |
| - sb.switch_to_frame("#example-container5 iframe") |
217 |
| - sb.driver.uc_click("span.mark", reconnect_time=3) |
218 |
| - |
| 215 | + sb.driver.uc_open_with_reconnect("nopecha.com/demo/turnstile", 3.4) |
219 | 216 | if sb.is_element_visible("#example-container0 iframe"):
|
220 | 217 | sb.switch_to_frame("#example-container0 iframe")
|
221 | 218 | if not sb.is_element_visible("circle.success-circle"):
|
222 | 219 | sb.driver.uc_click("span.mark", reconnect_time=3)
|
223 | 220 | sb.switch_to_frame("#example-container0 iframe")
|
224 |
| - sb.assert_element("circle.success-circle") |
225 |
| - sb.switch_to_parent_frame() |
| 221 | + sb.switch_to_default_content() |
226 | 222 |
|
| 223 | + sb.switch_to_frame("#example-container5 iframe") |
| 224 | + sb.driver.uc_click("span.mark", reconnect_time=2.5) |
227 | 225 | sb.switch_to_frame("#example-container5 iframe")
|
228 | 226 | sb.assert_element("svg#success-icon", timeout=3)
|
229 | 227 | sb.switch_to_parent_frame()
|
| 228 | + |
| 229 | + if sb.is_element_visible("#example-container0 iframe"): |
| 230 | + sb.switch_to_frame("#example-container0 iframe") |
| 231 | + sb.assert_element("circle.success-circle") |
| 232 | + sb.switch_to_parent_frame() |
| 233 | + |
230 | 234 | sb.set_messenger_theme(location="top_center")
|
231 | 235 | sb.post_message("SeleniumBase wasn't detected!", duration=3)
|
232 | 236 | ```
|
|
0 commit comments