Merge pull request #3006 from seleniumbase/various-updates

Various updates
This commit is contained in:
Michael Mintz 2024-08-06 23:32:23 -04:00 committed by GitHub
commit 283c3db022
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 61 additions and 29 deletions

View File

@ -334,16 +334,6 @@ The above JS method is used within the <b><code translate="no">SeleniumBase</cod
--------
🛠️ <b>Troubleshooting UC Mode</b>
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.)
<img src="https://seleniumbase.github.io/other/ts_uc_1.jpg" title="Make sure Scaling is set to 100%" width="410">
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`.
--------
🏆 <b>Choosing the right CAPTCHA service</b> for your business / website:
<img src="https://seleniumbase.github.io/other/me_se_conf.jpg" title="SeleniumBase" width="370">

View File

@ -6,8 +6,8 @@ setuptools>=68.0.0;python_version<"3.8"
setuptools~=70.2;python_version>="3.8" and python_version<"3.10"
setuptools>=70.2.0;python_version>="3.10"
wheel>=0.42.0;python_version<"3.8"
wheel>=0.43.0;python_version>="3.8"
attrs>=23.2.0
wheel>=0.44.0;python_version>="3.8"
attrs>=24.2.0
certifi>=2024.7.4
exceptiongroup>=1.2.2
filelock>=3.12.2;python_version<"3.8"
@ -17,7 +17,8 @@ platformdirs>=4.2.2;python_version>="3.8"
typing-extensions>=4.12.2;python_version>="3.8"
parse>=1.20.2
parse-type>=0.6.2
pyyaml>=6.0.1
pyyaml==6.0.1;python_version<"3.8"
pyyaml>=6.0.2;python_version>="3.8"
six==1.16.0
idna==3.7
chardet==5.2.0
@ -30,7 +31,7 @@ sniffio==1.3.1
h11==0.14.0
outcome==1.3.0.post0
trio==0.22.2;python_version<"3.8"
trio==0.26.0;python_version>="3.8"
trio==0.26.1;python_version>="3.8"
trio-websocket==0.11.1
wsproto==1.2.0
websocket-client==1.8.0;python_version>="3.8"
@ -78,13 +79,13 @@ rich==13.7.1
# ("pip install -r requirements.txt" also installs this, but "pip install -e ." won't.)
coverage==7.2.7;python_version<"3.8"
coverage>=7.6.0;python_version>="3.8"
coverage>=7.6.1;python_version>="3.8"
pytest-cov==4.1.0;python_version<"3.8"
pytest-cov>=5.0.0;python_version>="3.8"
flake8==5.0.4;python_version<"3.9"
flake8==7.1.0;python_version>="3.9"
flake8==7.1.1;python_version>="3.9"
mccabe==0.7.0
pyflakes==2.5.0;python_version<"3.9"
pyflakes==3.2.0;python_version>="3.9"
pycodestyle==2.9.1;python_version<"3.9"
pycodestyle==2.12.0;python_version>="3.9"
pycodestyle==2.12.1;python_version>="3.9"

View File

@ -1,2 +1,2 @@
# seleniumbase package
__version__ = "4.29.6"
__version__ = "4.29.7"

View File

@ -50,7 +50,7 @@ IS_WINDOWS = shared_utils.is_windows()
DRIVER_DIR = os.path.dirname(os.path.realpath(drivers.__file__))
LOCAL_PATH = "/usr/local/bin/" # On Mac and Linux systems
DEFAULT_CHROMEDRIVER_VERSION = "114.0.5735.90" # (If can't find LATEST_STABLE)
DEFAULT_GECKODRIVER_VERSION = "v0.34.0"
DEFAULT_GECKODRIVER_VERSION = "v0.35.0"
DEFAULT_EDGEDRIVER_VERSION = "115.0.1901.183" # (If can't find LATEST_STABLE)

View File

@ -781,6 +781,7 @@ def _uc_gui_click_captcha(
)
with gui_lock: # Prevent issues with multiple processes
needs_switch = False
width_ratio = 1.0
is_in_frame = js_utils.is_in_frame(driver)
if is_in_frame and driver.is_element_present("#challenge-stage"):
driver.switch_to.parent_frame()
@ -791,6 +792,20 @@ def _uc_gui_click_captcha(
page_actions.switch_to_window(
driver, driver.current_window_handle, 2, uc_lock=False
)
if IS_WINDOWS:
window_rect = driver.get_window_rect()
width = window_rect["width"]
height = window_rect["height"]
win_x = window_rect["x"]
win_y = window_rect["y"]
scr_width = pyautogui.size().width
driver.maximize_window()
win_width = driver.get_window_size()["width"]
width_ratio = round(float(scr_width) / float(win_width), 2) + 0.01
if width_ratio < 0.45 or width_ratio > 2.55:
width_ratio = 1.01
driver.minimize_window()
driver.set_window_rect(win_x, win_y, width, height)
if ctype == "cf_t":
if (
driver.is_element_present(".cf-turnstile-wrapper iframe")
@ -1015,6 +1030,18 @@ def _uc_gui_handle_captcha(
page_actions.switch_to_window(
driver, driver.current_window_handle, 2, uc_lock=False
)
if IS_WINDOWS and hasattr(pyautogui, "getActiveWindowTitle"):
py_a_g_title = pyautogui.getActiveWindowTitle()
window_title = driver.title
if not py_a_g_title.startswith(window_title):
window_rect = driver.get_window_rect()
width = window_rect["width"]
height = window_rect["height"]
win_x = window_rect["x"]
win_y = window_rect["y"]
driver.minimize_window()
driver.set_window_rect(win_x, win_y, width, height)
time.sleep(0.33)
if ctype == "cf_t":
if (
driver.is_element_present(".cf-turnstile-wrapper iframe")
@ -1688,7 +1715,10 @@ def _set_chrome_options(
chrome_options.add_argument("--ignore-certificate-errors")
if not enable_ws:
chrome_options.add_argument("--disable-web-security")
if IS_LINUX or not is_using_uc(undetectable, browser_name):
if (
IS_LINUX
or (IS_MAC and not is_using_uc(undetectable, browser_name))
):
chrome_options.add_argument("--no-sandbox")
if remote_debug:
# To access the Debugger, go to: chrome://inspect/#devices
@ -3405,7 +3435,10 @@ def get_local_driver(
edge_options.add_argument("--allow-running-insecure-content")
if user_agent:
edge_options.add_argument("--user-agent=%s" % user_agent)
if IS_LINUX or not is_using_uc(undetectable, browser_name):
if (
IS_LINUX
or (IS_MAC and not is_using_uc(undetectable, browser_name))
):
edge_options.add_argument("--no-sandbox")
if remote_debug:
# To access the Debugger, go to: edge://inspect/#devices

View File

@ -114,6 +114,13 @@ def recalculate_selector(selector, by, xp_ok=True):
by = By.XPATH
if by == "":
by = By.CSS_SELECTOR
if not is_valid_by(by):
valid_by_options = [
"css selector", "link text", "partial link text",
"name", "xpath", "id", "tag name", "class name",
]
msg = "Choose a `by` from: %s." % valid_by_options
raise Exception('Invalid `by`: "%s"\n%s' % (by, msg))
return (selector, by)

View File

@ -154,8 +154,8 @@ setup(
'setuptools~=70.2;python_version>="3.8" and python_version<"3.10"',
'setuptools>=70.2.0;python_version>="3.10"', # 71.0.x has issues
'wheel>=0.42.0;python_version<"3.8"',
'wheel>=0.43.0;python_version>="3.8"',
'attrs>=23.2.0',
'wheel>=0.44.0;python_version>="3.8"',
'attrs>=24.2.0',
"certifi>=2024.7.4",
"exceptiongroup>=1.2.2",
'filelock>=3.12.2;python_version<"3.8"',
@ -165,7 +165,8 @@ setup(
'typing-extensions>=4.12.2;python_version>="3.8"',
'parse>=1.20.2',
'parse-type>=0.6.2',
'pyyaml>=6.0.1',
'pyyaml==6.0.1;python_version<"3.8"',
'pyyaml>=6.0.2;python_version>="3.8"',
"six==1.16.0",
"idna==3.7",
'chardet==5.2.0',
@ -178,7 +179,7 @@ setup(
'h11==0.14.0',
'outcome==1.3.0.post0',
'trio==0.22.2;python_version<"3.8"',
'trio==0.26.0;python_version>="3.8"',
'trio==0.26.1;python_version>="3.8"',
'trio-websocket==0.11.1',
'wsproto==1.2.0',
'websocket-client==1.8.0;python_version>="3.8"',
@ -235,7 +236,7 @@ setup(
# Usage: coverage run -m pytest; coverage html; coverage report
"coverage": [
'coverage==7.2.7;python_version<"3.8"',
'coverage>=7.6.0;python_version>="3.8"',
'coverage>=7.6.1;python_version>="3.8"',
'pytest-cov==4.1.0;python_version<"3.8"',
'pytest-cov>=5.0.0;python_version>="3.8"',
],
@ -243,12 +244,12 @@ setup(
# Usage: flake8
"flake8": [
'flake8==5.0.4;python_version<"3.9"',
'flake8==7.1.0;python_version>="3.9"',
'flake8==7.1.1;python_version>="3.9"',
"mccabe==0.7.0",
'pyflakes==2.5.0;python_version<"3.9"',
'pyflakes==3.2.0;python_version>="3.9"',
'pycodestyle==2.9.1;python_version<"3.9"',
'pycodestyle==2.12.0;python_version>="3.9"',
'pycodestyle==2.12.1;python_version>="3.9"',
],
# pip install -e .[ipdb]
# (Not needed for debugging anymore. SeleniumBase now includes "pdbp".)
@ -264,7 +265,7 @@ setup(
'cryptography==39.0.2;python_version<"3.9"',
'cryptography==43.0.0;python_version>="3.9"',
'cffi==1.15.1;python_version<"3.8"',
'cffi==1.16.0;python_version>="3.8"',
'cffi==1.17.0;python_version>="3.8"',
"pycparser==2.22",
],
# pip install -e .[pillow]