mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-24 16:10:02 -06:00
WebUI Tests: changing the ActionsChains.move_to_element to a new approach
The approach ActionChains.move_to_element no longer works as said here [1], so, it's necessary to change it to the new one. This means, running a javascript script to move the page to where the element is. There are more details in the link [1], but in summary the w3c spec is not obvious if a click should scroll the page to the element or not. In one hand Chrome and Edge does that, but Firefox don't. As we use Firefox to run the tests, we need the workaround. [1] https://github.com/mozilla/geckodriver/issues/776 Reviewed-By: Petr Vobornik <pvoborni@redhat.com>
This commit is contained in:
parent
81fb7e5a32
commit
a5bd7bf766
@ -41,7 +41,6 @@ try:
|
||||
from selenium.common.exceptions import InvalidElementStateException
|
||||
from selenium.common.exceptions import StaleElementReferenceException
|
||||
from selenium.common.exceptions import WebDriverException
|
||||
from selenium.webdriver.common.action_chains import ActionChains
|
||||
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
|
||||
from selenium.webdriver.common.keys import Keys
|
||||
from selenium.webdriver.common.by import By
|
||||
@ -362,8 +361,8 @@ class UI_driver(object):
|
||||
# initial page
|
||||
ipa_logo = self.find('.navbar-brand', By.CSS_SELECTOR)
|
||||
if ipa_logo and ipa_logo.is_displayed():
|
||||
# the link is not clickable
|
||||
ActionChains(self.driver).move_to_element(ipa_logo).click().perform()
|
||||
self.move_to_element_in_page(ipa_logo)
|
||||
ipa_logo.click()
|
||||
return
|
||||
|
||||
# already on the first page
|
||||
@ -686,13 +685,19 @@ class UI_driver(object):
|
||||
|
||||
def _button_click(self, selector, parent, name=''):
|
||||
btn = self.find(selector, By.CSS_SELECTOR, parent, strict=True)
|
||||
ActionChains(self.driver).move_to_element(btn).perform()
|
||||
self.move_to_element_in_page(btn)
|
||||
disabled = btn.get_attribute("disabled")
|
||||
assert btn.is_displayed(), 'Button is not displayed: %s' % name
|
||||
assert not disabled, 'Invalid button state: disabled. Button: %s' % name
|
||||
btn.click()
|
||||
self.wait_for_request()
|
||||
|
||||
def move_to_element_in_page(self, element):
|
||||
# workaround to move the page until the element is visible
|
||||
# more in https://github.com/mozilla/geckodriver/issues/776
|
||||
self.driver.execute_script('arguments[0].scrollIntoView(true);',
|
||||
element)
|
||||
|
||||
def profile_menu_action(self, name):
|
||||
"""
|
||||
Execute action from profile menu
|
||||
@ -999,7 +1004,8 @@ class UI_driver(object):
|
||||
input_s = s + " tbody td input[value='%s']" % pkey
|
||||
checkbox = self.find(input_s, By.CSS_SELECTOR, parent, strict=True)
|
||||
try:
|
||||
ActionChains(self.driver).move_to_element(checkbox).click().perform()
|
||||
self.move_to_element_in_page(checkbox)
|
||||
checkbox.click()
|
||||
except WebDriverException as e:
|
||||
assert False, 'Can\'t click on checkbox label: %s \n%s' % (s, e)
|
||||
self.wait()
|
||||
|
Loading…
Reference in New Issue
Block a user