diff options
author | Felipe Barreto <fbarreto@redhat.com> | 2018-01-23 21:45:03 -0200 |
---|---|---|
committer | Christian Heimes <cheimes@redhat.com> | 2018-02-16 09:57:07 +0100 |
commit | a5bd7bf7668092d9b329e640b656f23b8bf7bfe6 (patch) | |
tree | 8d7c2e4df9765d484a2025c0ce58c68ecc2d6e74 | |
parent | 81fb7e5a321e2f4fa0e4112bea073c30dbe9d54e (diff) | |
download | freeipa-a5bd7bf7668092d9b329e640b656f23b8bf7bfe6.tar.gz freeipa-a5bd7bf7668092d9b329e640b656f23b8bf7bfe6.tar.xz freeipa-a5bd7bf7668092d9b329e640b656f23b8bf7bfe6.zip |
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>
-rw-r--r-- | ipatests/test_webui/ui_driver.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/ipatests/test_webui/ui_driver.py b/ipatests/test_webui/ui_driver.py index d5420defd..38dc2d766 100644 --- a/ipatests/test_webui/ui_driver.py +++ b/ipatests/test_webui/ui_driver.py @@ -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() |