diff --git a/help_docs/uc_mode.md b/help_docs/uc_mode.md index 425df658..02a3cee8 100644 --- a/help_docs/uc_mode.md +++ b/help_docs/uc_mode.md @@ -334,16 +334,6 @@ The above JS method is used within the SeleniumBaseTroubleshooting UC Mode - -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.) - - - -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`. - --------- - 🏆 Choosing the right CAPTCHA service for your business / website: diff --git a/requirements.txt b/requirements.txt index 917419f7..fb2aba19 100755 --- a/requirements.txt +++ b/requirements.txt @@ -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" diff --git a/seleniumbase/__version__.py b/seleniumbase/__version__.py index cd6258b1..fa692aca 100755 --- a/seleniumbase/__version__.py +++ b/seleniumbase/__version__.py @@ -1,2 +1,2 @@ # seleniumbase package -__version__ = "4.29.6" +__version__ = "4.29.7" diff --git a/seleniumbase/console_scripts/sb_install.py b/seleniumbase/console_scripts/sb_install.py index 62fa22d4..6372f5d5 100644 --- a/seleniumbase/console_scripts/sb_install.py +++ b/seleniumbase/console_scripts/sb_install.py @@ -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) diff --git a/seleniumbase/core/browser_launcher.py b/seleniumbase/core/browser_launcher.py index b1b91b0b..87ce5e09 100644 --- a/seleniumbase/core/browser_launcher.py +++ b/seleniumbase/core/browser_launcher.py @@ -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 diff --git a/seleniumbase/fixtures/page_utils.py b/seleniumbase/fixtures/page_utils.py index 57488185..18044a8b 100644 --- a/seleniumbase/fixtures/page_utils.py +++ b/seleniumbase/fixtures/page_utils.py @@ -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) diff --git a/setup.py b/setup.py index d8472c50..548c1533 100755 --- a/setup.py +++ b/setup.py @@ -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]