Update the docs
This commit is contained in:
parent
2f0db008df
commit
ffeee7f34e
|
@ -85,7 +85,7 @@ with SB(test=True) as sb:
|
||||||
|
|
||||||
--------
|
--------
|
||||||
|
|
||||||
<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>
|
<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>
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from seleniumbase import SB
|
from seleniumbase import SB
|
||||||
|
@ -93,8 +93,8 @@ from seleniumbase import SB
|
||||||
with SB(uc=True, test=True, locale_code="en") as sb:
|
with SB(uc=True, test=True, locale_code="en") as sb:
|
||||||
url = "https://gitlab.com/users/sign_in"
|
url = "https://gitlab.com/users/sign_in"
|
||||||
sb.activate_cdp_mode(url)
|
sb.activate_cdp_mode(url)
|
||||||
sb.uc_gui_click_captcha() # PyAutoGUI if needed
|
sb.uc_gui_click_captcha()
|
||||||
sb.save_screenshot_to_logs()
|
sb.sleep(2)
|
||||||
```
|
```
|
||||||
|
|
||||||
<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">
|
<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:
|
||||||
pytest test_fail.py
|
pytest test_fail.py
|
||||||
```
|
```
|
||||||
|
|
||||||
🔵 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.
|
🔵 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.
|
||||||
|
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,27 @@
|
||||||
|
|
||||||
That disconnects WebDriver from Chrome (which prevents detection), and gives you access to `sb.cdp` methods (which don't trigger anti-bot checks).
|
That disconnects WebDriver from Chrome (which prevents detection), and gives you access to `sb.cdp` methods (which don't trigger anti-bot checks).
|
||||||
|
|
||||||
Simple example: ([SeleniumBase/examples/cdp_mode/raw_planetmc.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/cdp_mode/raw_planetmc.py))
|
Simple example: ([SeleniumBase/examples/cdp_mode/raw_gitlab.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/cdp_mode/raw_gitlab.py))
|
||||||
|
|
||||||
|
```python
|
||||||
|
from seleniumbase import SB
|
||||||
|
|
||||||
|
with SB(uc=True, test=True, locale_code="en") as sb:
|
||||||
|
url = "https://gitlab.com/users/sign_in"
|
||||||
|
sb.activate_cdp_mode(url)
|
||||||
|
sb.uc_gui_click_captcha()
|
||||||
|
sb.sleep(2)
|
||||||
|
```
|
||||||
|
|
||||||
|
<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">
|
||||||
|
|
||||||
|
(If the CAPTCHA wasn't bypassed automatically, then `sb.uc_gui_click_captcha()` gets the job done.)
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
--------
|
||||||
|
|
||||||
|
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))
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from seleniumbase import SB
|
from seleniumbase import SB
|
||||||
|
@ -50,23 +70,10 @@ with SB(uc=True, test=True) as sb:
|
||||||
|
|
||||||
<img src="https://seleniumbase.github.io/other/planet_mc.png" title="SeleniumBase" width="480">
|
<img src="https://seleniumbase.github.io/other/planet_mc.png" title="SeleniumBase" width="480">
|
||||||
|
|
||||||
(If the CAPTCHA wasn't initially bypassed, then the click gets the job done.)
|
When using `sb.cdp.gui_click_element(selector)` on CF Turnstiles, use the parent `selector` that appears **above** the `#shadow-root` element:
|
||||||
|
Eg. `sb.cdp.gui_click_element("#turnstile-widget div")`
|
||||||
|
|
||||||
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.
|
<img src="https://seleniumbase.github.io/other/above_shadow.png" title="SeleniumBase" width="480">
|
||||||
|
|
||||||
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))
|
|
||||||
|
|
||||||
```python
|
|
||||||
from seleniumbase import SB
|
|
||||||
|
|
||||||
with SB(uc=True, test=True, locale_code="en") as sb:
|
|
||||||
url = "https://gitlab.com/users/sign_in"
|
|
||||||
sb.activate_cdp_mode(url)
|
|
||||||
sb.uc_gui_click_captcha()
|
|
||||||
sb.sleep(2)
|
|
||||||
```
|
|
||||||
|
|
||||||
<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">
|
|
||||||
|
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue