Skip to content

Commit e87d738

Browse files
authored
Merge pull request #2685 from seleniumbase/refresh-uc-mode-and-dependencies
Refresh UC Mode and dependencies
2 parents f32657c + 9ede89b commit e87d738

File tree

13 files changed

+107
-25
lines changed

13 files changed

+107
-25
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
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/super_logo_sb2.png" alt="SeleniumBase" title="SeleniumBase" width="350" /></a></p>
12+
<p align="center"><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.github.io/cdn/img/super_logo_sb3.png" alt="SeleniumBase" title="SeleniumBase" width="350" /></a></p>
1313

1414

1515
<p align="center" class="hero__title"><b>All-in-one Browser Automation Framework:<br />Web Crawling / Testing / Scraping / Stealth</b></p>
@@ -102,7 +102,7 @@ pytest test_demo_site.py
102102

103103
--------
104104

105-
<p align="left"><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.github.io/cdn/img/super_logo_sb2.png" alt="SeleniumBase" title="SeleniumBase" width="232" /></a></p>
105+
<p align="left"><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.github.io/cdn/img/super_logo_sb3.png" alt="SeleniumBase" title="SeleniumBase" width="232" /></a></p>
106106

107107
<blockquote>
108108
<p dir="auto"><strong>Explore the README:</strong></p>
@@ -1371,7 +1371,7 @@ pytest --reruns=1 --reruns-delay=1
13711371
13721372
<p><div><b><a href="https://github.com/mdmintz">https://github.com/mdmintz</a></b></div></p>
13731373
1374-
<div><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.github.io/cdn/img/super_logo_sb2.png" title="SeleniumBase" width="240" /></a></div>
1374+
<div><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.github.io/cdn/img/super_logo_sb3.png" title="SeleniumBase" width="240" /></a></div>
13751375
<div><a href="https://seleniumbase.io"><img src="https://img.shields.io/badge/docs-seleniumbase.io-11BBAA.svg" alt="SeleniumBase Docs" /></a></div> <div><a href="https://github.com/seleniumbase/SeleniumBase"><img src="https://img.shields.io/badge/tested%20with-SeleniumBase-04C38E.svg" alt="Tested with SeleniumBase" /></a></div> <div><a href="https://github.com/seleniumbase/SeleniumBase/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-MIT-22BBCC.svg" title="SeleniumBase" /></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></div>
13761376
<div><a href="https://pepy.tech/project/seleniumbase" target="_blank"><img src="https://static.pepy.tech/badge/seleniumbase" alt="SeleniumBase PyPI downloads" /></a></div>
13771377
<div><a href="https://github.com/seleniumbase/SeleniumBase/stargazers"><img src="https://img.shields.io/github/stars/seleniumbase/seleniumbase.svg?color=19A57B" title="Stargazers" /></a></div>

examples/raw_ahrefs.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from seleniumbase import SB
22

3-
43
with SB(uc=True, test=True, locale_code="en") as sb:
54
url = "https://ahrefs.com/website-authority-checker"
65
input_field = 'input[placeholder="Enter domain"]'

examples/raw_form_turnstile.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from seleniumbase import SB
22

33
with SB(uc=True, test=True) as sb:
4-
sb.driver.uc_open_with_reconnect("seleniumbase.io/apps/form_turnstile", 3)
4+
url = "seleniumbase.io/apps/form_turnstile"
5+
sb.driver.uc_open_with_reconnect(url, 2)
56
sb.press_keys("#name", "SeleniumBase")
67
sb.press_keys("#email", "[email protected]")
78
sb.press_keys("#phone", "1-555-555-5555")

examples/raw_nopecha.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
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", 3.4)
4+
sb.driver.uc_open_with_reconnect("nopecha.com/demo/turnstile", 4)
55
if sb.is_element_visible("#example-container0 iframe"):
66
sb.switch_to_frame("#example-container0 iframe")
77
if not sb.is_element_visible("circle.success-circle"):

examples/raw_order_tickets.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from seleniumbase import SB
2+
3+
with SB(uc=True, test=True, ad_block_on=True) as sb:
4+
url = "https://www.thaiticketmajor.com/concert/"
5+
sb.driver.uc_open_with_reconnect(url, 5.5)
6+
sb.driver.uc_click("button.btn-signin", 4)
7+
sb.switch_to_frame('iframe[title*="Cloudflare"]')
8+
sb.assert_element("div#success svg#success-icon")
9+
sb.switch_to_default_content()
10+
sb.set_messenger_theme(location="top_center")
11+
sb.post_message("SeleniumBase wasn't detected!")

examples/raw_turnstile.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33

44
def open_the_turnstile_page(sb):
5-
sb.driver.uc_open_with_reconnect(
6-
"seleniumbase.io/apps/turnstile", reconnect_time=3,
7-
)
5+
url = "seleniumbase.io/apps/turnstile"
6+
sb.driver.uc_open_with_reconnect(url, reconnect_time=2)
87

98

109
def click_turnstile_and_verify(sb):

help_docs/uc_mode.md

Lines changed: 62 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,21 @@
1919
from seleniumbase import Driver
2020

2121
driver = Driver(uc=True)
22-
driver.uc_open_with_reconnect("https://gitlab.com/users/sign_in", 3)
22+
url = "https://gitlab.com/users/sign_in"
23+
driver.uc_open_with_reconnect(url, 3)
2324
driver.quit()
2425
```
2526

27+
<img src="https://seleniumbase.github.io/other/gitlab_bypass.png" title="SeleniumBase" width="370">
28+
2629
👤 Here's an example with the <b><code translate="no">SB</code></b> manager (which has more methods and functionality than the <b><code translate="no">Driver</code></b> format):
2730

2831
```python
2932
from seleniumbase import SB
3033

3134
with SB(uc=True) as sb:
32-
sb.driver.uc_open_with_reconnect("https://gitlab.com/users/sign_in", 3)
35+
url = "https://gitlab.com/users/sign_in"
36+
sb.driver.uc_open_with_reconnect(url, 3)
3337
```
3438

3539
👤 Here's a longer example, which includes a retry if the CAPTCHA isn't bypassed on the first attempt:
@@ -55,9 +59,8 @@ with SB(uc=True, test=True) as sb:
5559
from seleniumbase import SB
5660

5761
def open_the_turnstile_page(sb):
58-
sb.driver.uc_open_with_reconnect(
59-
"https://seleniumbase.io/apps/turnstile", reconnect_time=3,
60-
)
62+
url = "seleniumbase.io/apps/turnstile"
63+
sb.driver.uc_open_with_reconnect(url, reconnect_time=2)
6164

6265
def click_turnstile_and_verify(sb):
6366
sb.switch_to_frame("iframe")
@@ -77,6 +80,46 @@ with SB(uc=True, test=True) as sb:
7780

7881
<img src="https://seleniumbase.github.io/other/turnstile_click.jpg" title="SeleniumBase" width="440">
7982

83+
👤 Here's an example <b>where the CAPTCHA appears after submitting a form</b>:
84+
85+
```python
86+
from seleniumbase import SB
87+
88+
with SB(uc=True, test=True, locale_code="en") as sb:
89+
url = "https://ahrefs.com/website-authority-checker"
90+
input_field = 'input[placeholder="Enter domain"]'
91+
submit_button = 'span:contains("Check Authority")'
92+
sb.driver.uc_open_with_reconnect(url, 1) # The bot-check is later
93+
sb.type(input_field, "github.com/seleniumbase/SeleniumBase")
94+
sb.driver.reconnect(0.1)
95+
sb.driver.uc_click(submit_button, reconnect_time=4)
96+
sb.wait_for_text_not_visible("Checking", timeout=10)
97+
sb.highlight('p:contains("github.com/seleniumbase/SeleniumBase")')
98+
sb.highlight('a:contains("Top 100 backlinks")')
99+
sb.set_messenger_theme(location="bottom_center")
100+
sb.post_message("SeleniumBase wasn't detected!")
101+
```
102+
103+
<img src="https://seleniumbase.github.io/other/ahrefs_bypass.png" title="SeleniumBase" width="540">
104+
105+
👤 Here, <b>the CAPTCHA appears after clicking to go to the sign-in screen</b>:
106+
107+
```python
108+
from seleniumbase import SB
109+
110+
with SB(uc=True, test=True, ad_block_on=True) as sb:
111+
url = "https://www.thaiticketmajor.com/concert/"
112+
sb.driver.uc_open_with_reconnect(url, 5.5)
113+
sb.driver.uc_click("button.btn-signin", 4)
114+
sb.switch_to_frame('iframe[title*="Cloudflare"]')
115+
sb.assert_element("div#success svg#success-icon")
116+
sb.switch_to_default_content()
117+
sb.set_messenger_theme(location="top_center")
118+
sb.post_message("SeleniumBase wasn't detected!")
119+
```
120+
121+
<img src="https://seleniumbase.github.io/other/ttm_bypass.png" title="SeleniumBase" width="540">
122+
80123
--------
81124

82125
👤 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>.
@@ -247,7 +290,7 @@ Here are the 3 primary things that <b translate="no">UC Mode</b> does to make bo
247290

248291
For example, if the <b translate="no">Chrome DevTools Console</b> variables aren't renamed, you can expect to find them easily when using <b><code translate="no">selenium</code></b> for browser automation:
249292

250-
<img src="https://seleniumbase.github.io/other/cdc_args.png" title="SeleniumBase" width="380">
293+
<img src="https://seleniumbase.github.io/other/cdc_args.png" title="SeleniumBase" width="390">
251294

252295
(If those variables are still there, then websites can easily detect your bots.)
253296

@@ -278,7 +321,7 @@ The above JS method is used within the <b><code translate="no">SeleniumBase</cod
278321

279322
🏆 <b>Choosing the right CAPTCHA service</b> for your business / website:
280323

281-
<img src="https://seleniumbase.github.io/other/me_se_conf.jpg" title="SeleniumBase" width="340">
324+
<img src="https://seleniumbase.github.io/other/me_se_conf.jpg" title="SeleniumBase" width="370">
282325

283326
As an ethical hacker / cybersecurity researcher who builds bots that bypass CAPTCHAs for sport, <b>the CAPTCHA service that I personally recommend</b> for keeping bots out is <b translate="no">Google's reCAPTCHA</b>:
284327

@@ -288,6 +331,18 @@ Since Google makes Chrome, Google's own <b translate="no">reCAPTCHA</b> service
288331

289332
--------
290333

334+
⚖️ <b>Legal implications of web-scraping</b>:
335+
336+
Based on the following article, https://nubela.co/blog/meta-lost-the-scraping-legal-battle-to-bright-data/, (which outlines a court case where social-networking company: Meta lost the legal battle to data-scraping company: Bright Data), it was determined that web scraping is 100% legal in the eyes of the courts as long as:
337+
1. The scraping is only done with <b>public data</b> and <b>not private data</b>.
338+
2. The scraping isn’t done while logged in on the site being scraped.
339+
340+
If the above criteria are met, then scrape away! (According to the article)
341+
342+
(Note: I'm not a lawyer, so I can't officially offer legal advice, but I can direct people to existing articles online where people can find their own answers.)
343+
344+
--------
345+
291346
<img src="https://seleniumbase.github.io/cdn/img/sb_text_f.png" alt="SeleniumBase" title="SeleniumBase" align="center" width="335">
292347

293348
<div><a href="https://github.com/seleniumbase/SeleniumBase"><img src="https://seleniumbase.github.io/cdn/img/sb_logo_gs.png" alt="SeleniumBase" title="SeleniumBase" width="335" /></a></div>

mkdocs_build/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
regex>=2023.12.25
55
pymdown-extensions>=10.7.1
6-
pipdeptree>=2.17.0
6+
pipdeptree>=2.18.0
77
python-dateutil>=2.8.2
88
Markdown==3.6
99
markdown2==2.4.13

requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ wheel>=0.43.0;python_version>="3.8"
77
attrs>=23.2.0
88
certifi>=2024.2.2
99
filelock>=3.12.2;python_version<"3.8"
10-
filelock>=3.13.3;python_version>="3.8"
10+
filelock>=3.13.4;python_version>="3.8"
1111
platformdirs>=4.0.0;python_version<"3.8"
1212
platformdirs>=4.2.0;python_version>="3.8"
1313
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
1717
six==1.16.0
18-
idna==3.6
18+
idna==3.7
1919
chardet==5.2.0
2020
charset-normalizer==3.3.2
2121
urllib3>=1.26.18,<2;python_version<"3.10"
@@ -35,7 +35,7 @@ cssselect==1.2.0
3535
sortedcontainers==2.4.0
3636
fasteners==0.19
3737
execnet==2.0.2;python_version<"3.8"
38-
execnet==2.1.0;python_version>="3.8"
38+
execnet==2.1.1;python_version>="3.8"
3939
iniconfig==2.0.0
4040
pluggy==1.2.0;python_version<"3.8"
4141
pluggy==1.4.0;python_version>="3.8"

seleniumbase/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# seleniumbase package
2-
__version__ = "4.25.2"
2+
__version__ = "4.25.3"

seleniumbase/fixtures/base_case.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4134,6 +4134,23 @@ def get_new_driver(
41344134
self.__dont_record_open = True
41354135
self.open(new_start_page)
41364136
self.__dont_record_open = False
4137+
if undetectable:
4138+
if hasattr(new_driver, "uc_open"):
4139+
self.uc_open = new_driver.uc_open
4140+
if hasattr(new_driver, "uc_open_with_tab"):
4141+
self.uc_open_with_tab = new_driver.uc_open_with_tab
4142+
if hasattr(new_driver, "uc_open_with_reconnect"):
4143+
self.uc_open_with_reconnect = new_driver.uc_open_with_reconnect
4144+
if hasattr(new_driver, "reconnect"):
4145+
self.reconnect = new_driver.reconnect
4146+
if hasattr(new_driver, "disconnect"):
4147+
self.disconnect = new_driver.disconnect
4148+
if hasattr(new_driver, "connect"):
4149+
self.connect = new_driver.connect
4150+
if hasattr(new_driver, "uc_click"):
4151+
self.uc_click = new_driver.uc_click
4152+
if hasattr(new_driver, "uc_switch_to_frame"):
4153+
self.uc_switch_to_frame = new_driver.uc_switch_to_frame
41374154
return new_driver
41384155

41394156
def switch_to_driver(self, driver):

seleniumbase/undetected/webelement.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def uc_click(
1414
):
1515
if driver and selector and by:
1616
delayed_click = False
17-
if tag_name == "span" or tag_name == "button" or tag_name == "div":
17+
if tag_name in ["span", "button", "div", "a"]:
1818
delayed_click = True
1919
if delayed_click and ":contains" not in selector:
2020
selector = js_utils.convert_to_css_selector(selector, by)

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,15 @@
155155
'attrs>=23.2.0',
156156
"certifi>=2024.2.2",
157157
'filelock>=3.12.2;python_version<"3.8"',
158-
'filelock>=3.13.3;python_version>="3.8"',
158+
'filelock>=3.13.4;python_version>="3.8"',
159159
'platformdirs>=4.0.0;python_version<"3.8"',
160160
'platformdirs>=4.2.0;python_version>="3.8"',
161161
'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',
165165
"six==1.16.0",
166-
"idna==3.6",
166+
"idna==3.7",
167167
'chardet==5.2.0',
168168
'charset-normalizer==3.3.2',
169169
'urllib3>=1.26.18,<2;python_version<"3.10"',
@@ -183,7 +183,7 @@
183183
"sortedcontainers==2.4.0",
184184
'fasteners==0.19',
185185
'execnet==2.0.2;python_version<"3.8"',
186-
'execnet==2.1.0;python_version>="3.8"',
186+
'execnet==2.1.1;python_version>="3.8"',
187187
'iniconfig==2.0.0',
188188
'pluggy==1.2.0;python_version<"3.8"',
189189
'pluggy==1.4.0;python_version>="3.8"',

0 commit comments

Comments
 (0)