Merge pull request #2948 from seleniumbase/handle-uc-mode-edge-cases
Handle UC Mode edge cases
This commit is contained in:
commit
c495286cb1
|
@ -12,7 +12,7 @@ with SB(uc=True, test=True) as sb:
|
|||
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")')
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
# seleniumbase package
|
||||
__version__ = "4.28.6"
|
||||
__version__ = "4.28.7"
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -3418,6 +3418,8 @@ class BaseCase(unittest.TestCase):
|
|||
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):
|
||||
|
|
5
setup.py
5
setup.py
|
@ -194,7 +194,7 @@ setup(
|
|||
'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 @@ setup(
|
|||
'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 @@ setup(
|
|||
# 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',
|
||||
|
|
Loading…
Reference in New Issue