Skip to content

Commit 283c3db

Browse files
authored
Merge pull request #3006 from seleniumbase/various-updates
Various updates
2 parents feca61a + 3ca2dc9 commit 283c3db

File tree

7 files changed

+61
-29
lines changed

7 files changed

+61
-29
lines changed

help_docs/uc_mode.md

-10
Original file line numberDiff line numberDiff line change
@@ -334,16 +334,6 @@ The above JS method is used within the <b><code translate="no">SeleniumBase</cod
334334

335335
--------
336336

337-
🛠️ <b>Troubleshooting UC Mode</b>
338-
339-
On Windows, the `uc_gui_click_captcha()` method requires "Scaling" to be set at "100%". (Note that "100%" may be different from the system's "Recommended" percent, which can be higher depending on your screen resolution and monitor size.)
340-
341-
<img src="https://seleniumbase.github.io/other/ts_uc_1.jpg" title="Make sure Scaling is set to 100%" width="410">
342-
343-
As an alternative to using the `uc_gui_click_captcha()` method on Windows, you can use `sb.uc_gui_handle_captcha()`, which does not require "Scaling" to be set to a specific value. Instead of using the mouse to click a CAPTCHA, `sb.uc_gui_handle_captcha()` uses a combination of the `TAB` key and the `SPACEBAR`.
344-
345-
--------
346-
347337
🏆 <b>Choosing the right CAPTCHA service</b> for your business / website:
348338

349339
<img src="https://seleniumbase.github.io/other/me_se_conf.jpg" title="SeleniumBase" width="370">

requirements.txt

+8-7
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ setuptools>=68.0.0;python_version<"3.8"
66
setuptools~=70.2;python_version>="3.8" and python_version<"3.10"
77
setuptools>=70.2.0;python_version>="3.10"
88
wheel>=0.42.0;python_version<"3.8"
9-
wheel>=0.43.0;python_version>="3.8"
10-
attrs>=23.2.0
9+
wheel>=0.44.0;python_version>="3.8"
10+
attrs>=24.2.0
1111
certifi>=2024.7.4
1212
exceptiongroup>=1.2.2
1313
filelock>=3.12.2;python_version<"3.8"
@@ -17,7 +17,8 @@ platformdirs>=4.2.2;python_version>="3.8"
1717
typing-extensions>=4.12.2;python_version>="3.8"
1818
parse>=1.20.2
1919
parse-type>=0.6.2
20-
pyyaml>=6.0.1
20+
pyyaml==6.0.1;python_version<"3.8"
21+
pyyaml>=6.0.2;python_version>="3.8"
2122
six==1.16.0
2223
idna==3.7
2324
chardet==5.2.0
@@ -30,7 +31,7 @@ sniffio==1.3.1
3031
h11==0.14.0
3132
outcome==1.3.0.post0
3233
trio==0.22.2;python_version<"3.8"
33-
trio==0.26.0;python_version>="3.8"
34+
trio==0.26.1;python_version>="3.8"
3435
trio-websocket==0.11.1
3536
wsproto==1.2.0
3637
websocket-client==1.8.0;python_version>="3.8"
@@ -78,13 +79,13 @@ rich==13.7.1
7879
# ("pip install -r requirements.txt" also installs this, but "pip install -e ." won't.)
7980

8081
coverage==7.2.7;python_version<"3.8"
81-
coverage>=7.6.0;python_version>="3.8"
82+
coverage>=7.6.1;python_version>="3.8"
8283
pytest-cov==4.1.0;python_version<"3.8"
8384
pytest-cov>=5.0.0;python_version>="3.8"
8485
flake8==5.0.4;python_version<"3.9"
85-
flake8==7.1.0;python_version>="3.9"
86+
flake8==7.1.1;python_version>="3.9"
8687
mccabe==0.7.0
8788
pyflakes==2.5.0;python_version<"3.9"
8889
pyflakes==3.2.0;python_version>="3.9"
8990
pycodestyle==2.9.1;python_version<"3.9"
90-
pycodestyle==2.12.0;python_version>="3.9"
91+
pycodestyle==2.12.1;python_version>="3.9"

seleniumbase/__version__.py

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

seleniumbase/console_scripts/sb_install.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
DRIVER_DIR = os.path.dirname(os.path.realpath(drivers.__file__))
5151
LOCAL_PATH = "/usr/local/bin/" # On Mac and Linux systems
5252
DEFAULT_CHROMEDRIVER_VERSION = "114.0.5735.90" # (If can't find LATEST_STABLE)
53-
DEFAULT_GECKODRIVER_VERSION = "v0.34.0"
53+
DEFAULT_GECKODRIVER_VERSION = "v0.35.0"
5454
DEFAULT_EDGEDRIVER_VERSION = "115.0.1901.183" # (If can't find LATEST_STABLE)
5555

5656

seleniumbase/core/browser_launcher.py

+35-2
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,7 @@ def _uc_gui_click_captcha(
781781
)
782782
with gui_lock: # Prevent issues with multiple processes
783783
needs_switch = False
784+
width_ratio = 1.0
784785
is_in_frame = js_utils.is_in_frame(driver)
785786
if is_in_frame and driver.is_element_present("#challenge-stage"):
786787
driver.switch_to.parent_frame()
@@ -791,6 +792,20 @@ def _uc_gui_click_captcha(
791792
page_actions.switch_to_window(
792793
driver, driver.current_window_handle, 2, uc_lock=False
793794
)
795+
if IS_WINDOWS:
796+
window_rect = driver.get_window_rect()
797+
width = window_rect["width"]
798+
height = window_rect["height"]
799+
win_x = window_rect["x"]
800+
win_y = window_rect["y"]
801+
scr_width = pyautogui.size().width
802+
driver.maximize_window()
803+
win_width = driver.get_window_size()["width"]
804+
width_ratio = round(float(scr_width) / float(win_width), 2) + 0.01
805+
if width_ratio < 0.45 or width_ratio > 2.55:
806+
width_ratio = 1.01
807+
driver.minimize_window()
808+
driver.set_window_rect(win_x, win_y, width, height)
794809
if ctype == "cf_t":
795810
if (
796811
driver.is_element_present(".cf-turnstile-wrapper iframe")
@@ -1015,6 +1030,18 @@ def _uc_gui_handle_captcha(
10151030
page_actions.switch_to_window(
10161031
driver, driver.current_window_handle, 2, uc_lock=False
10171032
)
1033+
if IS_WINDOWS and hasattr(pyautogui, "getActiveWindowTitle"):
1034+
py_a_g_title = pyautogui.getActiveWindowTitle()
1035+
window_title = driver.title
1036+
if not py_a_g_title.startswith(window_title):
1037+
window_rect = driver.get_window_rect()
1038+
width = window_rect["width"]
1039+
height = window_rect["height"]
1040+
win_x = window_rect["x"]
1041+
win_y = window_rect["y"]
1042+
driver.minimize_window()
1043+
driver.set_window_rect(win_x, win_y, width, height)
1044+
time.sleep(0.33)
10181045
if ctype == "cf_t":
10191046
if (
10201047
driver.is_element_present(".cf-turnstile-wrapper iframe")
@@ -1688,7 +1715,10 @@ def _set_chrome_options(
16881715
chrome_options.add_argument("--ignore-certificate-errors")
16891716
if not enable_ws:
16901717
chrome_options.add_argument("--disable-web-security")
1691-
if IS_LINUX or not is_using_uc(undetectable, browser_name):
1718+
if (
1719+
IS_LINUX
1720+
or (IS_MAC and not is_using_uc(undetectable, browser_name))
1721+
):
16921722
chrome_options.add_argument("--no-sandbox")
16931723
if remote_debug:
16941724
# To access the Debugger, go to: chrome://inspect/#devices
@@ -3405,7 +3435,10 @@ def get_local_driver(
34053435
edge_options.add_argument("--allow-running-insecure-content")
34063436
if user_agent:
34073437
edge_options.add_argument("--user-agent=%s" % user_agent)
3408-
if IS_LINUX or not is_using_uc(undetectable, browser_name):
3438+
if (
3439+
IS_LINUX
3440+
or (IS_MAC and not is_using_uc(undetectable, browser_name))
3441+
):
34093442
edge_options.add_argument("--no-sandbox")
34103443
if remote_debug:
34113444
# To access the Debugger, go to: edge://inspect/#devices

seleniumbase/fixtures/page_utils.py

+7
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,13 @@ def recalculate_selector(selector, by, xp_ok=True):
114114
by = By.XPATH
115115
if by == "":
116116
by = By.CSS_SELECTOR
117+
if not is_valid_by(by):
118+
valid_by_options = [
119+
"css selector", "link text", "partial link text",
120+
"name", "xpath", "id", "tag name", "class name",
121+
]
122+
msg = "Choose a `by` from: %s." % valid_by_options
123+
raise Exception('Invalid `by`: "%s"\n%s' % (by, msg))
117124
return (selector, by)
118125

119126

setup.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@
154154
'setuptools~=70.2;python_version>="3.8" and python_version<"3.10"',
155155
'setuptools>=70.2.0;python_version>="3.10"', # 71.0.x has issues
156156
'wheel>=0.42.0;python_version<"3.8"',
157-
'wheel>=0.43.0;python_version>="3.8"',
158-
'attrs>=23.2.0',
157+
'wheel>=0.44.0;python_version>="3.8"',
158+
'attrs>=24.2.0',
159159
"certifi>=2024.7.4",
160160
"exceptiongroup>=1.2.2",
161161
'filelock>=3.12.2;python_version<"3.8"',
@@ -165,7 +165,8 @@
165165
'typing-extensions>=4.12.2;python_version>="3.8"',
166166
'parse>=1.20.2',
167167
'parse-type>=0.6.2',
168-
'pyyaml>=6.0.1',
168+
'pyyaml==6.0.1;python_version<"3.8"',
169+
'pyyaml>=6.0.2;python_version>="3.8"',
169170
"six==1.16.0",
170171
"idna==3.7",
171172
'chardet==5.2.0',
@@ -178,7 +179,7 @@
178179
'h11==0.14.0',
179180
'outcome==1.3.0.post0',
180181
'trio==0.22.2;python_version<"3.8"',
181-
'trio==0.26.0;python_version>="3.8"',
182+
'trio==0.26.1;python_version>="3.8"',
182183
'trio-websocket==0.11.1',
183184
'wsproto==1.2.0',
184185
'websocket-client==1.8.0;python_version>="3.8"',
@@ -235,20 +236,20 @@
235236
# Usage: coverage run -m pytest; coverage html; coverage report
236237
"coverage": [
237238
'coverage==7.2.7;python_version<"3.8"',
238-
'coverage>=7.6.0;python_version>="3.8"',
239+
'coverage>=7.6.1;python_version>="3.8"',
239240
'pytest-cov==4.1.0;python_version<"3.8"',
240241
'pytest-cov>=5.0.0;python_version>="3.8"',
241242
],
242243
# pip install -e .[flake8]
243244
# Usage: flake8
244245
"flake8": [
245246
'flake8==5.0.4;python_version<"3.9"',
246-
'flake8==7.1.0;python_version>="3.9"',
247+
'flake8==7.1.1;python_version>="3.9"',
247248
"mccabe==0.7.0",
248249
'pyflakes==2.5.0;python_version<"3.9"',
249250
'pyflakes==3.2.0;python_version>="3.9"',
250251
'pycodestyle==2.9.1;python_version<"3.9"',
251-
'pycodestyle==2.12.0;python_version>="3.9"',
252+
'pycodestyle==2.12.1;python_version>="3.9"',
252253
],
253254
# pip install -e .[ipdb]
254255
# (Not needed for debugging anymore. SeleniumBase now includes "pdbp".)
@@ -264,7 +265,7 @@
264265
'cryptography==39.0.2;python_version<"3.9"',
265266
'cryptography==43.0.0;python_version>="3.9"',
266267
'cffi==1.15.1;python_version<"3.8"',
267-
'cffi==1.16.0;python_version>="3.8"',
268+
'cffi==1.17.0;python_version>="3.8"',
268269
"pycparser==2.22",
269270
],
270271
# pip install -e .[pillow]

0 commit comments

Comments
 (0)