mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
tests: functional: Handle obscured elements when submitting forms
In some cases in the backup page, when trying to restore a backup, the button is obscured and trying to click it fails. Handle such situations by scrolling the element into view first and try to click on the element again. Ensure that our navigation header does not obscure the element when scrolling it into view. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
170685c806
commit
dd6b865de6
@ -203,6 +203,17 @@ def download_file_outside_browser(url):
|
||||
###########################
|
||||
# Form handling utilities #
|
||||
###########################
|
||||
def click(browser, element):
|
||||
"""Click an element after scrolling it into view considering header."""
|
||||
try:
|
||||
element.click()
|
||||
except ElementClickInterceptedException:
|
||||
script = 'arguments[0].style.scrollMarginTop = "4.3125rem";' \
|
||||
'arguments[0].scrollIntoView(true);'
|
||||
browser.execute_script(script, element._element)
|
||||
element.click()
|
||||
|
||||
|
||||
def submit(browser, element=None, form_class=None, expected_url=None):
|
||||
"""Submit a specific form in the current page and wait for page change."""
|
||||
if not (element or form_class):
|
||||
@ -210,7 +221,7 @@ def submit(browser, element=None, form_class=None, expected_url=None):
|
||||
|
||||
with wait_for_page_update(browser, expected_url=expected_url):
|
||||
if element:
|
||||
element.click()
|
||||
click(browser, element)
|
||||
elif form_class:
|
||||
browser.find_by_css(
|
||||
'.{} input[type=submit]'.format(form_class)).click()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user