Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ffeee7f

Browse files
committed
Update the docs
1 parent 2f0db00 commit ffeee7f

File tree

2 files changed

+24
-17
lines changed

2 files changed

+24
-17
lines changed

‎README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,16 @@ with SB(test=True) as sb:
8585

8686
--------
8787

88-
<p align="left">📗 Here's an example of bypassing bot-detection on a site that uses Cloudflare: <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/cdp_mode/raw_gitlab.py">SeleniumBase/examples/cdp_mode/raw_gitlab.py</a></p>
88+
<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>
8989

9090
```python
9191
from seleniumbase import SB
9292

9393
with SB(uc=True, test=True, locale_code="en") as sb:
9494
url = "https://gitlab.com/users/sign_in"
9595
sb.activate_cdp_mode(url)
96-
sb.uc_gui_click_captcha()# PyAutoGUI if needed
97-
sb.save_screenshot_to_logs()
96+
sb.uc_gui_click_captcha()
97+
sb.sleep(2)
9898
```
9999

100100
<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">
@@ -827,7 +827,7 @@ You can run it from the ``examples/`` folder like this:
827827
pytest test_fail.py
828828
```
829829
830-
🔵 You'll notice that a logs folder, "latest_logs", was created to hold information about the failing test, and screenshots. During test runs, past results get moved to the archived_logs folder if you have ARCHIVE_EXISTING_LOGS set to True in [settings.py](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/config/settings.py), or if your run tests with ``--archive-logs``. If you choose not to archive existing logs, they will be deleted and replaced by the logs of the latest test run.
830+
🔵 You'll notice that a logs folder, ``./latest_logs/``, was created to hold information (and screenshots) about the failing test. During test runs, past results get moved to the archived_logs folder if you have ARCHIVE_EXISTING_LOGS set to True in [settings.py](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/config/settings.py), or if your run tests with ``--archive-logs``. If you choose not to archive existing logs, they will be deleted and replaced by the logs of the latest test run.
831831
832832
--------
833833

‎examples/cdp_mode/ReadMe.md

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,38 +35,45 @@
3535
3636
That disconnects WebDriver from Chrome (which prevents detection), and gives you access to `sb.cdp` methods (which don't trigger anti-bot checks).
3737

38-
Simple example: ([SeleniumBase/examples/cdp_mode/raw_planetmc.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/cdp_mode/raw_planetmc.py))
38+
Simple example: ([SeleniumBase/examples/cdp_mode/raw_gitlab.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/cdp_mode/raw_gitlab.py))
3939

4040
```python
4141
from seleniumbase import SB
4242

43-
with SB(uc=True, test=True) as sb:
44-
url = "www.planetminecraft.com/account/sign_in/"
43+
with SB(uc=True, test=True, locale_code="en") as sb:
44+
url = "https://gitlab.com/users/sign_in"
4545
sb.activate_cdp_mode(url)
46-
sb.sleep(2)
47-
sb.cdp.gui_click_element("#turnstile-widget div")
46+
sb.uc_gui_click_captcha()
4847
sb.sleep(2)
4948
```
5049

51-
<img src="https://seleniumbase.github.io/other/planet_mc.png" title="SeleniumBase" width="480">
50+
<img src="https://seleniumbase.github.io/other/cf_sec.jpg"title="SeleniumBase"width="332"> <imgsrc="https://seleniumbase.github.io/other/gitlab_bypass.png" title="SeleniumBase" width="288">
5251

53-
(If the CAPTCHA wasn't initially bypassed, then the click gets the job done.)
52+
(If the CAPTCHA wasn't bypassed automatically, then `sb.uc_gui_click_captcha()` gets the job done.)
5453

55-
Note that `PyAutoGUI` is an optional dependency. If calling a method that uses it when not already installed, then `SeleniumBase` will install it at run-time, which pauses the script briefly.
54+
Note that `PyAutoGUI` is an optional dependency. If calling a method that uses it when not already installed, then `SeleniumBase` installs `PyAutoGUI` at run-time.
55+
56+
--------
5657

57-
For standard Cloudflare pages, use `sb.uc_gui_click_captcha()` if Turnstiles aren't initially bypassed. Example: ([SeleniumBase/examples/cdp_mode/raw_gitlab.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/cdp_mode/raw_gitlab.py))
58+
For Cloudflare CAPTCHAs that appear as part of a websites, you may need to use `sb.cdp.gui_click_element(selector)` instead (if the Turnstile wasn't bypassed automatically). Example: ([SeleniumBase/examples/cdp_mode/raw_planetmc.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/cdp_mode/raw_planetmc.py))
5859

5960
```python
6061
from seleniumbase import SB
6162

62-
with SB(uc=True, test=True, locale_code="en") as sb:
63-
url = "https://gitlab.com/users/sign_in"
63+
with SB(uc=True, test=True) as sb:
64+
url = "www.planetminecraft.com/account/sign_in/"
6465
sb.activate_cdp_mode(url)
65-
sb.uc_gui_click_captcha()
66+
sb.sleep(2)
67+
sb.cdp.gui_click_element("#turnstile-widget div")
6668
sb.sleep(2)
6769
```
6870

69-
<img src="https://seleniumbase.github.io/other/cf_sec.jpg" title="SeleniumBase" width="404"> <img src="https://seleniumbase.github.io/other/gitlab_bypass.png" title="SeleniumBase" width="350">
71+
<img src="https://seleniumbase.github.io/other/planet_mc.png" title="SeleniumBase" width="480">
72+
73+
When using `sb.cdp.gui_click_element(selector)` on CF Turnstiles, use the parent `selector` that appears **above** the `#shadow-root` element:
74+
Eg. `sb.cdp.gui_click_element("#turnstile-widget div")`
75+
76+
<img src="https://seleniumbase.github.io/other/above_shadow.png" title="SeleniumBase" width="480">
7077

7178
--------
7279

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /