diff --git a/examples/raw_form_turnstile.py b/examples/raw_form_turnstile.py index 9fbd85464dc..8791a572c0a 100644 --- a/examples/raw_form_turnstile.py +++ b/examples/raw_form_turnstile.py @@ -12,7 +12,7 @@ sb.click('span:contains("9:00 PM")') sb.highlight_click('input[value="AR"] + span') sb.click('input[value="cc"] + span') - sb.scroll_to("iframe") + sb.scroll_to("div.cf-turnstile-wrapper") sb.uc_gui_handle_cf() sb.highlight("img#captcha-success", timeout=3) sb.highlight_click('button:contains("Request & Pay")') diff --git a/requirements.txt b/requirements.txt index e9aa3658893..f45ddc2d92f 100755 --- a/requirements.txt +++ b/requirements.txt @@ -46,7 +46,7 @@ pluggy==1.2.0;python_version<"3.8" pluggy==1.5.0;python_version>="3.8" py==1.11.0 pytest==7.4.4;python_version<"3.8" -pytest==8.2.1;python_version>="3.8" +pytest==8.3.1;python_version>="3.8" pytest-html==2.0.1 pytest-metadata==3.0.0;python_version<"3.8" pytest-metadata==3.1.1;python_version>="3.8" diff --git a/seleniumbase/__version__.py b/seleniumbase/__version__.py index 9149958c85e..5049436fc73 100755 --- a/seleniumbase/__version__.py +++ b/seleniumbase/__version__.py @@ -1,2 +1,2 @@ # seleniumbase package -__version__ = "4.28.6" +__version__ = "4.28.7" diff --git a/seleniumbase/core/browser_launcher.py b/seleniumbase/core/browser_launcher.py index 924b4f534c6..5684068475a 100644 --- a/seleniumbase/core/browser_launcher.py +++ b/seleniumbase/core/browser_launcher.py @@ -680,6 +680,8 @@ def get_gui_element_position(driver, selector): viewport_height = driver.execute_script("return window.innerHeight;") viewport_x = window_rect["x"] + element_rect["x"] viewport_y = window_bottom_y - viewport_height + element_rect["y"] + y_scroll_offset = driver.execute_script("return window.pageYOffset;") + viewport_y = viewport_y - y_scroll_offset return (viewport_x, viewport_y) @@ -688,7 +690,7 @@ def _uc_gui_click_x_y(driver, x, y, timeframe=0.25, uc_lock=False): import pyautogui pyautogui = get_configured_pyautogui(pyautogui) screen_width, screen_height = pyautogui.size() - if x > screen_width or y > screen_height: + if x < 0 or y < 0 or x > screen_width or y > screen_height: raise Exception( "PyAutoGUI cannot click on point (%s, %s)" " outside screen. (Width: %s, Height: %s)" @@ -807,6 +809,16 @@ def _uc_gui_click_captcha( frame = '[data-callback="onCaptchaSuccess"]' else: return + if driver.is_element_present('form[class*=center]'): + script = ( + """var $elements = document.querySelectorAll('form'); + var index = 0, length = $elements.length; + for(; index < length; index++){ + the_class = $elements[index].getAttribute('class'); + new_class = the_class.replaceAll('center', 'left'); + $elements[index].setAttribute('class', new_class);}""" + ) + driver.execute_script(script) if not is_in_frame or needs_switch: # Currently not in frame (or nested frame outside CF one) try: @@ -977,7 +989,7 @@ def uc_gui_handle_cf(driver, frame="iframe"): return try: found_checkbox = False - for i in range(10): + for i in range(24): pyautogui.press("\t") time.sleep(0.02) active_element_css = js_utils.get_active_element_css(driver) @@ -987,7 +999,6 @@ def uc_gui_handle_cf(driver, frame="iframe"): time.sleep(0.02) if not found_checkbox: return - driver.execute_script('document.querySelector("input").focus()') except Exception: try: driver.switch_to.default_content() diff --git a/seleniumbase/fixtures/base_case.py b/seleniumbase/fixtures/base_case.py index 07d07caec98..92e008eba04 100644 --- a/seleniumbase/fixtures/base_case.py +++ b/seleniumbase/fixtures/base_case.py @@ -3418,6 +3418,8 @@ def get_gui_element_rect(self, selector, by="css selector"): viewport_height = self.execute_script("return window.innerHeight;") x = math.ceil(window_rect["x"] + i_x + element_rect["x"]) y = math.ceil(w_bottom_y - viewport_height + i_y + element_rect["y"]) + y_scroll_offset = self.execute_script("return window.pageYOffset;") + y = int(y - y_scroll_offset) if iframe_switch: self.switch_to_frame() if not self.is_element_present(selector, by=by): diff --git a/setup.py b/setup.py index 0afedadac50..a7e6fef81ea 100755 --- a/setup.py +++ b/setup.py @@ -194,7 +194,7 @@ 'pluggy==1.5.0;python_version>="3.8"', "py==1.11.0", # Needed by pytest-html 'pytest==7.4.4;python_version<"3.8"', - 'pytest==8.2.1;python_version>="3.8"', + 'pytest==8.3.1;python_version>="3.8"', "pytest-html==2.0.1", # Newer ones had issues 'pytest-metadata==3.0.0;python_version<"3.8"', 'pytest-metadata==3.1.1;python_version>="3.8"', @@ -262,7 +262,7 @@ 'pdfminer.six==20221105;python_version<"3.8"', 'pdfminer.six==20240706;python_version>="3.8"', 'cryptography==39.0.2;python_version<"3.9"', - 'cryptography==42.0.8;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"', "pycparser==2.22", @@ -300,6 +300,7 @@ # pip install -e .[selenium-wire] "selenium-wire": [ 'selenium-wire==5.1.0', + 'pyOpenSSL==24.2.1', 'Brotli==1.1.0', 'blinker==1.7.0', # Newer ones had issues 'h2==4.1.0',