Skip to content

Commit e23c4ec

Browse files
authored
Merge pull request #2667 from seleniumbase/fix-issue-with-uc-mode
Fix issue with UC Mode
2 parents 18036a2 + 74e16db commit e23c4ec

File tree

7 files changed

+47
-33
lines changed

7 files changed

+47
-33
lines changed

Diff for: README.md

+13-10
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@
99

1010
<h1>SeleniumBase</h1>
1111

12-
<p align="center"><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.github.io/cdn/img/sb_logo_gs.png" alt="SeleniumBase" title="SeleniumBase" width="500" /></a></p>
12+
<p align="center"><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.github.io/cdn/img/super_logo_i.png" alt="SeleniumBase" title="SeleniumBase" width="400" /></a></p>
1313

14-
<h3 align="center" class="hero__title"><b>End-to-end testing for the next generation.</b></h3>
1514

16-
<h4 align="center"><b>Overcome your greatest browser automation challenges.</b></h4>
15+
<p align="center" class="hero__title"><b>All-in-one Browser Automation Framework:<br />Web Crawling / Testing / Scraping / Stealth</b></p>
1716

1817
<p align="center"><a href="https://pypi.python.org/pypi/seleniumbase" target="_blank"><img src="https://img.shields.io/pypi/v/seleniumbase.svg?color=3399EE" alt="PyPI version" /></a> <a href="https://github.com/seleniumbase/SeleniumBase/releases" target="_blank"><img src="https://img.shields.io/github/v/release/seleniumbase/SeleniumBase.svg?color=22AAEE" alt="GitHub version" /></a> <a href="https://seleniumbase.io"><img src="https://img.shields.io/badge/docs-seleniumbase.io-11BBAA.svg" alt="SeleniumBase Docs" /></a> <a href="https://github.com/seleniumbase/SeleniumBase/actions" target="_blank"><img src="https://github.com/seleniumbase/SeleniumBase/workflows/CI%20build/badge.svg" alt="SeleniumBase GitHub Actions" /></a> <a href="https://gitter.im/seleniumbase/SeleniumBase" target="_blank"><img src="https://img.shields.io/gitter/room/seleniumbase/SeleniumBase.svg" alt="Gitter chat"/></a></p>
1918

@@ -57,15 +56,19 @@
5756

5857
--------
5958

60-
📚 Learn from [**over 200 examples** in the **SeleniumBase/examples/**](https://github.com/seleniumbase/SeleniumBase/tree/master/examples) folder.
59+
📚 Learn from [**over 200 examples** in the **SeleniumBase/examples/** folder](https://github.com/seleniumbase/SeleniumBase/tree/master/examples).
60+
61+
👤 Note that <span translate="no">SeleniumBase</span> <a translate="no" href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/uc_mode.md">UC Mode / Stealth Mode has its own ReadMe</a>.
62+
63+
ℹ️ Scripts can be called via <code translate="no"><b>python</b></code>, although some <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/syntax_formats.md">Syntax Formats</a> expect <a href="https://docs.pytest.org/en/latest/how-to/usage.html" translate="no"><b>pytest</b></a> (a Python unit-testing framework included with SeleniumBase that can discover & collect tests automatically).
6164

6265
<p align="left">📗 Here's <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/my_first_test.py">my_first_test.py</a>, which tests login, shopping, and checkout:</p>
6366

6467
```bash
6568
pytest my_first_test.py
6669
```
6770

68-
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/my_first_test.py"><img src="https://seleniumbase.github.io/cdn/gif/fast_swag_2.gif" alt="SeleniumBase Test" title="SeleniumBase Test" width="550" /></a>
71+
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/my_first_test.py"><img src="https://seleniumbase.github.io/cdn/gif/fast_swag_2.gif" alt="SeleniumBase Test" title="SeleniumBase Test" width="520" /></a>
6972

7073
> ``pytest`` uses ``--chrome`` by default unless set differently.
7174
@@ -77,7 +80,7 @@ pytest my_first_test.py
7780
pytest test_coffee_cart.py --demo
7881
```
7982

80-
<p align="left"><a href="https://seleniumbase.io/coffee/" target="_blank"><img src="https://seleniumbase.github.io/cdn/gif/coffee_cart.gif" width="550" alt="SeleniumBase Coffee Cart Test" title="SeleniumBase Coffee Cart Test" /></a></p>
83+
<p align="left"><a href="https://seleniumbase.io/coffee/" target="_blank"><img src="https://seleniumbase.github.io/cdn/gif/coffee_cart.gif" width="520" alt="SeleniumBase Coffee Cart Test" title="SeleniumBase Coffee Cart Test" /></a></p>
8184

8285
> <p>(<code translate="no">--demo</code> mode slows down tests and highlights actions)</p>
8386
@@ -91,7 +94,7 @@ pytest test_coffee_cart.py --demo
9194
pytest test_demo_site.py
9295
```
9396

94-
<p align="left"><a href="https://seleniumbase.io/demo_page" target="_blank"><img src="https://seleniumbase.github.io/cdn/gif/demo_page_5.gif" width="550" alt="SeleniumBase Example" title="SeleniumBase Example" /></a></p>
97+
<p align="left"><a href="https://seleniumbase.io/demo_page" target="_blank"><img src="https://seleniumbase.github.io/cdn/gif/demo_page_5.gif" width="520" alt="SeleniumBase Example" title="SeleniumBase Example" /></a></p>
9598

9699
> Easy to type, click, select, toggle, drag & drop, and more.
97100
@@ -394,7 +397,7 @@ cd examples/
394397
pytest my_first_test.py
395398
```
396399
397-
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/my_first_test.py"><img src="https://seleniumbase.github.io/cdn/gif/fast_swag_2.gif" alt="SeleniumBase Test" title="SeleniumBase Test" width="550" /></a>
400+
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/my_first_test.py"><img src="https://seleniumbase.github.io/cdn/gif/fast_swag_2.gif" alt="SeleniumBase Test" title="SeleniumBase Test" width="520" /></a>
398401
399402
<p align="left"><b>Here's the code for <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/my_first_test.py">my_first_test.py</a>:</b></p>
400403
@@ -835,7 +838,7 @@ python -m http.server 1948
835838
pytest test_suite.py test_image_saving.py --dashboard --rs --headless
836839
```
837840
838-
<img src="https://seleniumbase.github.io/cdn/img/dashboard_2.png" alt="The SeleniumBase Dashboard" title="The SeleniumBase Dashboard" width="550" />
841+
<img src="https://seleniumbase.github.io/cdn/img/dashboard_2.png" alt="The SeleniumBase Dashboard" title="The SeleniumBase Dashboard" width="520" />
839842
840843
--------
841844
@@ -890,7 +893,7 @@ pynose test_suite.py --report
890893
behave behave_bdd/features/ -D dashboard -D headless
891894
```
892895
893-
<img src="https://seleniumbase.github.io/cdn/img/sb_behave_dashboard.png" title="SeleniumBase" width="550">
896+
<img src="https://seleniumbase.github.io/cdn/img/sb_behave_dashboard.png" title="SeleniumBase" width="520">
894897
895898
You can also use ``--junit`` to get ``.xml`` reports for each <code translate="no">behave</code> feature. Jenkins can use these files to display better reporting for your tests.
896899

Diff for: examples/raw_nopecha.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
from seleniumbase import SB
22

33
with SB(uc=True, test=True) as sb:
4-
sb.driver.uc_open_with_reconnect("nopecha.com/demo/turnstile", 4.5)
5-
sb.switch_to_frame("#example-container5 iframe")
6-
sb.driver.uc_click("span.mark", reconnect_time=3)
7-
4+
sb.driver.uc_open_with_reconnect("nopecha.com/demo/turnstile", 3.4)
85
if sb.is_element_visible("#example-container0 iframe"):
96
sb.switch_to_frame("#example-container0 iframe")
107
if not sb.is_element_visible("circle.success-circle"):
118
sb.driver.uc_click("span.mark", reconnect_time=3)
129
sb.switch_to_frame("#example-container0 iframe")
13-
sb.assert_element("circle.success-circle")
14-
sb.switch_to_parent_frame()
10+
sb.switch_to_default_content()
1511

12+
sb.switch_to_frame("#example-container5 iframe")
13+
sb.driver.uc_click("span.mark", reconnect_time=2.5)
1614
sb.switch_to_frame("#example-container5 iframe")
1715
sb.assert_element("svg#success-icon", timeout=3)
1816
sb.switch_to_parent_frame()
17+
18+
if sb.is_element_visible("#example-container0 iframe"):
19+
sb.switch_to_frame("#example-container0 iframe")
20+
sb.assert_element("circle.success-circle")
21+
sb.switch_to_parent_frame()
22+
1923
sb.set_messenger_theme(location="top_center")
2024
sb.post_message("SeleniumBase wasn't detected!", duration=3)

Diff for: help_docs/uc_mode.md

+18-14
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,11 @@
77
<!-- 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>
88
<!-- GitHub Only --><p>(<b><a href="https://www.youtube.com/watch?v=5dMFI3e85ig">Watch the UC Mode tutorial on YouTube! ▶️</a></b>)</p>
99

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:
1111

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)`
1915

2016
👤 Here's an example with the <b><code translate="no">Driver</code></b> manager:
2117

@@ -83,6 +79,10 @@ with SB(uc=True, test=True) as sb:
8379

8480
--------
8581

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+
8686
### 👤 Here are some examples that use UC Mode:
8787
* [SeleniumBase/examples/verify_undetected.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/verify_undetected.py)
8888
* [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:
212212
from seleniumbase import SB
213213

214214
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)
219216
if sb.is_element_visible("#example-container0 iframe"):
220217
sb.switch_to_frame("#example-container0 iframe")
221218
if not sb.is_element_visible("circle.success-circle"):
222219
sb.driver.uc_click("span.mark", reconnect_time=3)
223220
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()
226222

223+
sb.switch_to_frame("#example-container5 iframe")
224+
sb.driver.uc_click("span.mark", reconnect_time=2.5)
227225
sb.switch_to_frame("#example-container5 iframe")
228226
sb.assert_element("svg#success-icon", timeout=3)
229227
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+
230234
sb.set_messenger_theme(location="top_center")
231235
sb.post_message("SeleniumBase wasn't detected!", duration=3)
232236
```

Diff for: requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ filelock>=3.12.2;python_version<"3.8"
1010
filelock>=3.13.3;python_version>="3.8"
1111
platformdirs>=4.0.0;python_version<"3.8"
1212
platformdirs>=4.2.0;python_version>="3.8"
13-
typing-extensions>=4.10.0;python_version>="3.8"
13+
typing-extensions>=4.11.0;python_version>="3.8"
1414
parse>=1.20.1
1515
parse-type>=0.6.2
1616
pyyaml>=6.0.1

Diff for: seleniumbase/__version__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# seleniumbase package
2-
__version__ = "4.25.1"
2+
__version__ = "4.25.2"

Diff for: seleniumbase/undetected/webelement.py

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import re
12
import selenium.webdriver.remote.webelement
23
from seleniumbase.fixtures import js_utils
34

@@ -17,6 +18,8 @@ def uc_click(
1718
delayed_click = True
1819
if delayed_click and ":contains" not in selector:
1920
selector = js_utils.convert_to_css_selector(selector, by)
21+
selector = re.escape(selector)
22+
selector = js_utils.escape_quotes_if_needed(selector)
2023
script = 'document.querySelector("%s").click();' % selector
2124
js_utils.call_me_later(driver, script, 111)
2225
else:

Diff for: setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@
158158
'filelock>=3.13.3;python_version>="3.8"',
159159
'platformdirs>=4.0.0;python_version<"3.8"',
160160
'platformdirs>=4.2.0;python_version>="3.8"',
161-
'typing-extensions>=4.10.0;python_version>="3.8"',
161+
'typing-extensions>=4.11.0;python_version>="3.8"',
162162
'parse>=1.20.1',
163163
'parse-type>=0.6.2',
164164
'pyyaml>=6.0.1',

0 commit comments

Comments
 (0)