Skip to content

Commit 577c8e5

Browse files
authored
Merge pull request #1489 from seleniumbase/undetected-chromedriver
Add option "--uc" for using an undetectable chromedriver
2 parents 512b9db + 66aadf8 commit 577c8e5

30 files changed

+1755
-130
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,7 @@ The code above will leave your browser window open in case there's a failure. (i
496496
--enable-ws # (Enable Web Security on Chromium-based browsers.)
497497
--enable-sync # (Enable "Chrome Sync".)
498498
--use-auto-ext # (Use Chrome's automation extension.)
499+
--undetected # (Use an undetectable chromedriver to evade bot-detection.)
499500
--remote-debug # (Enable Chrome's Remote Debugger on http://localhost:9222)
500501
--final-debug # (Enter Debug Mode after each test ends. Don't use with CI!)
501502
--dashboard # (Enable the SeleniumBase Dashboard. Saved at: dashboard.html)

examples/ReadMe.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## [<img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32">](https://github.com/seleniumbase/SeleniumBase/) Running Example Tests:
1+
## [<img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32">](https://github.com/seleniumbase/SeleniumBase/) Example Tests:
22

33
<p align="left"><a align="center" href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_demo_site.py"><img align="center" src="https://seleniumbase.io/cdn/img/sb_demo_page.png" alt="SeleniumBase Demo Page" width="420" /></a></p>
44

@@ -7,7 +7,7 @@
77
* Tests are structured using [20 unique syntax formats](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/syntax_formats.md).
88
* Logs from test failures are saved to ``./latest_logs/``.
99
* Tests can be run with [multiple command-line options](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/customizing_test_runs.md).
10-
* Example tests are found in: **[SeleniumBase/examples/](https://github.com/seleniumbase/SeleniumBase/tree/master/examples)**.
10+
* Examples can be found in: **[SeleniumBase/examples/](https://github.com/seleniumbase/SeleniumBase/tree/master/examples)**.
1111

1212
(NOTE: Some example tests fail on purpose to demonstrate [logging features](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/example_logs/ReadMe.md).)
1313

examples/raw_parameter_script.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
sb.enable_ws = False
6464
sb.enable_sync = False
6565
sb.use_auto_ext = False
66+
sb.undetectable = False
6667
sb.no_sandbox = False
6768
sb.disable_gpu = False
6869
sb._multithreaded = False

examples/tour_examples/ReadMe.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
> **[IntroJS](https://introjs.com/)**, **[Bootstrap Tour](http://bootstraptour.com/)**, **[DriverJS](https://kamranahmed.info/driver.js/)**, **[Shepherd](https://shepherdjs.dev/)**, and **[Hopscotch](https://linkedinattic.github.io/hopscotch/)**.
1010
11-
<b>Example tour: (with autoplay)</b>
11+
<b>A tour demo: (with autoplay)</b>
1212

1313
<img src="https://seleniumbase.io/cdn/gif/introjs_tour.gif" title="SeleniumBase Tour of Google"><br>
1414

@@ -19,7 +19,7 @@ cd examples/tour_examples
1919
pytest maps_introjs_tour.py --interval=1
2020
```
2121

22-
<b>Here's a longer example:</b>
22+
<b>Here's a longer version:</b>
2323

2424
<img src="https://seleniumbase.io/cdn/gif/google_tour_4.gif" title="SeleniumBase Tour of Google"><br>
2525

@@ -97,7 +97,7 @@ You can play a tour by calling:
9797

9898
All methods have the optional ``name`` argument, which is only needed if you're creating multiple tours at once. Then, when you're adding a step or playing a tour, SeleniumBase knows which tour you're referring too. You can avoid using the ``name`` arg for multiple tours if you play a tour before creating a new one.
9999

100-
### Here's an example of using SeleniumBase Tours:
100+
### Here's how the code looks:
101101

102102
```python
103103
from seleniumbase import BaseCase
@@ -122,7 +122,7 @@ class MyTourClass(BaseCase):
122122
self.play_tour()
123123
```
124124

125-
#### This example is from [google_tour.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/tour_examples/google_tour.py), which you can run from the ``examples/tour_examples`` folder with the following command:
125+
#### That code is from [google_tour.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/tour_examples/google_tour.py), which you can run from the ``tour_examples/`` folder with the following command:
126126

127127
```bash
128128
pytest google_tour.py

examples/verify_undetected.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"""
2+
Determine if your browser is detectable by anti-bot services.
3+
Some sites use scripts to detect Selenium and then block you.
4+
To evade detection, add --uc as a pytest command-line option.
5+
"""
6+
from seleniumbase import BaseCase
7+
8+
9+
class UndetectedTest(BaseCase):
10+
def test_browser_is_undetected(self):
11+
self.open("https://nowsecure.nl")
12+
try:
13+
self.assert_text("OH YEAH, you passed!", "h1", timeout=6.6)
14+
self.post_message("Browser wasn't detected!", duration=1.6)
15+
self._print("\n Success! Website did not detect Selenium!")
16+
except Exception:
17+
self.fail('Browser was detected! Try using: "pytest --uc"')

help_docs/customizing_test_runs.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ pytest my_first_test.py --settings-file=custom_settings.py
162162
--enable-ws # (Enable Web Security on Chromium-based browsers.)
163163
--enable-sync # (Enable "Chrome Sync".)
164164
--use-auto-ext # (Use Chrome's automation extension.)
165+
--undetected # (Use an undetectable chromedriver to evade bot-detection.)
165166
--remote-debug # (Enable Chrome's Remote Debugger on http://localhost:9222)
166167
--final-debug # (Enter Debug Mode after each test ends. Don't use with CI!)
167168
--dashboard # (Enable the SeleniumBase Dashboard. Saved at: dashboard.html)

help_docs/method_summary.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ self.get_new_driver(
245245
port=None,
246246
proxy=None,
247247
proxy_bypass_list=None,
248+
proxy_pac_url=None,
248249
agent=None,
249250
switch_to=True,
250251
cap_file=None,
@@ -254,6 +255,7 @@ self.get_new_driver(
254255
enable_ws=None,
255256
enable_sync=None,
256257
use_auto_ext=None,
258+
undetectable=None,
257259
no_sandbox=None,
258260
disable_gpu=None,
259261
incognito=None,
@@ -263,12 +265,14 @@ self.get_new_driver(
263265
swiftshader=None,
264266
ad_block_on=None,
265267
block_images=None,
268+
do_not_track=None,
266269
chromium_arg=None,
267270
firefox_arg=None,
268271
firefox_pref=None,
269272
user_data_dir=None,
270273
extension_zip=None,
271274
extension_dir=None,
275+
page_load_strategy=None,
272276
external_pdf=None,
273277
is_mobile=None,
274278
d_width=None,

help_docs/webdriver_installation.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ sbase get geckodriver
1010
sbase get edgedriver
1111
```
1212

13-
* If you have the latest version of Chrome installed, get the latest chromedriver (<i>otherwise it defaults to chromedriver 72.0.3626.69 for compatibility reasons</i>):
13+
* ``sbase get chromedriver`` automatically tries to detect the version you need. If it can't, it defaults to ``chromedriver 72.0.3626.69`` for compatibility reasons. To force getting the latest version, use:
1414

1515
```bash
1616
sbase get chromedriver latest
1717
```
1818

19-
* You can also install a specific version of chromedriver for a specific version of Chrome:
19+
* You can also get a specific version of chromedriver for a specific version of Chrome:
2020

2121
```bash
2222
sbase get chromedriver 102.0.5005.61
@@ -31,11 +31,11 @@ wget https://raw.githubusercontent.com/seleniumbase/SeleniumBase/master/examples
3131
pytest upgrade_chromedriver.py -s
3232
```
3333

34-
* If you run a test without the correct webdriver installed, the driver will be downloaded automatically.
34+
* If you run a test without the correct webdriver available, the driver will be downloaded automatically.
3535

3636
If you plan on using the [Selenium Grid integration](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/utilities/selenium_grid/ReadMe.md) (which allows for remote webdriver), you'll need to put the drivers on your System PATH. On macOS and Linux, ``/usr/local/bin`` is a good PATH spot. On Windows, you may need to set the System PATH under Environment Variables to include the location where you placed the driver files. As a shortcut, you could place the driver files into your Python ``Scripts/`` folder in the location where you have Python installed, which should already be on your System PATH.
3737

38-
Here's where you can go to manually install web drivers from the source:
38+
Here's where you can go to manually get web drivers from the source:
3939

4040
* For Chrome, get [Chromedriver](https://sites.google.com/a/chromium.org/chromedriver/downloads) on your System PATH.
4141

@@ -69,7 +69,7 @@ brew upgrade geckodriver
6969

7070
**Linux shortcuts**:
7171

72-
If you still need the web drivers, here are some scripts to help you install chromedriver and geckodriver on a Linux machine:
72+
If you still need the web drivers, here are some scripts to help you get chromedriver and geckodriver on a Linux machine:
7373

7474
```bash
7575
wget https://chromedriver.storage.googleapis.com/72.0.3626.69/chromedriver_linux64.zip

integrations/google_cloud/ReadMe.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
### Building a browser-based test automation server on the [Google Cloud Platform](https://cloud.google.com/) by using [SeleniumBase](https://github.com/seleniumbase/SeleniumBase)
22

3-
(This tutorial, [from a previous Google Cloud Meetup](https://www.meetup.com/Boston-Google-Cloud-Meetup/events/230839686/?showDescription=true), will teach you how to setup a Linux server for running automated browser tests. The cost of running this server is about [$13.61/month on Google Cloud](https://console.cloud.google.com/launcher/details/bitnami-launchpad/jenkins) (enough to handle **5 parallel tests**). This is less expensive than using other platforms.)
3+
(This tutorial, [from a previous Google Cloud Meetup](https://www.meetup.com/Boston-Google-Cloud-Meetup/events/230839686/?showDescription=true), will teach you how to setup a Linux server for running automated browser tests. The cost of running this server is about [$13.60/month on Google Cloud](https://console.cloud.google.com/launcher/details/bitnami-launchpad/jenkins) (enough to handle **5 parallel tests**). This is less expensive than using other platforms.)
44

55
<!-- YouTube View --><a href="https://www.youtube.com/watch?v=n-sno20R9P0"><img src="https://seleniumbase.io/other/gcp_video_thumb.png" title="SeleniumBase on YouTube" width="285" /></a>
66
<!-- GitHub Only --><p>(<b><a href="https://www.youtube.com/watch?v=n-sno20R9P0">SeleniumBase Google Cloud Video</a></b>)</p>

mkdocs.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ plugins:
7171
- CONTRIBUTING.md
7272
- SECURITY.md
7373
- help_docs/chinese.md
74+
- help_docs/mysql_installation.md
7475
- integrations/katalon/ReadMe.md
7576
- seleniumbase/utilities/selenium_ide/ReadMe.md
7677
- seleniumbase/examples/chart_maker/ReadMe.md
@@ -82,7 +83,7 @@ plugins:
8283
# Page tree
8384
nav:
8485
- SeleniumBase ReadMe: README.md
85-
- Features List: help_docs/features_list.md
86+
- List of Features: help_docs/features_list.md
8687
- Running Example Tests: examples/ReadMe.md
8788
- Command Line Options: help_docs/customizing_test_runs.md
8889
- Dashboard / Reports: examples/example_logs/ReadMe.md

0 commit comments

Comments
 (0)