Make i9n tests correctly recognize the deletion of a last row in a table

First, .is_displayed() method inside RowRegion needs to be invoked
correctly. Second, we need to distinguish an .empty placeholder row
from the last deleted row which contents are replaced with .empty row
contents from inside. Otherwise these 2 rows are considered the same
by tests. This is done by checking first for empty_table_selector.

Change-Id: I1abeb9f5ffc94213011e24eda99bb8a1ca8bfaeb
Closes-Bug: #1564405
This commit is contained in:
Timur Sufiev 2016-03-31 16:35:20 +03:00
parent 8fcfa8050c
commit e63b5d86ac
2 changed files with 35 additions and 18 deletions
openstack_dashboard/test/integration_tests

@ -9,10 +9,12 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import contextlib
import unittest
import selenium.common.exceptions as Exceptions
from selenium.webdriver.common import by
from selenium.webdriver.remote import webelement
import selenium.webdriver.support.ui as Support
from selenium.webdriver.support import wait
@ -27,14 +29,12 @@ class BaseWebObject(unittest.TestCase):
self.explicit_wait = self.conf.selenium.explicit_wait
def _is_element_present(self, *locator):
try:
self._turn_off_implicit_wait()
self._get_element(*locator)
return True
except Exceptions.NoSuchElementException:
return False
finally:
self._turn_on_implicit_wait()
with self.waits_disabled():
try:
self._get_element(*locator)
return True
except Exceptions.NoSuchElementException:
return False
def _is_element_visible(self, *locator):
try:
@ -44,9 +44,15 @@ class BaseWebObject(unittest.TestCase):
return False
def _is_element_displayed(self, element):
if element is None:
return False
try:
return element.is_displayed()
except Exception:
if isinstance(element, webelement.WebElement):
return element.is_displayed()
else:
return element.src_elem.is_displayed()
except (Exceptions.ElementNotVisibleException,
Exceptions.StaleElementReferenceException):
return False
def _is_text_visible(self, element, text, strict=True):
@ -117,18 +123,24 @@ class BaseWebObject(unittest.TestCase):
self._wait_until(lambda x: not self._is_element_displayed(element),
timeout)
def wait_till_element_disappears(self, element_getter):
@contextlib.contextmanager
def waits_disabled(self):
try:
self._turn_off_implicit_wait()
self._wait_till_element_disappears(element_getter())
except Exceptions.NoSuchElementException:
# NOTE(mpavlase): This is valid state. When request completes
# even before Selenium get a chance to get the spinner element,
# it will raise the NoSuchElementException exception.
pass
yield
finally:
self._turn_on_implicit_wait()
def wait_till_element_disappears(self, element_getter):
with self.waits_disabled():
try:
self._wait_till_element_disappears(element_getter())
except Exceptions.NoSuchElementException:
# NOTE(mpavlase): This is valid state. When request completes
# even before Selenium get a chance to get the spinner element,
# it will raise the NoSuchElementException exception.
pass
def wait_till_spinner_disappears(self):
getter = lambda: self.driver.find_element(*self._spinner_locator)
self.wait_till_element_disappears(getter)

@ -138,8 +138,13 @@ class TableRegion(baseregion.BaseRegion):
for elem in self._get_elements(*self._rows_locator)]
def is_row_deleted(self, row_getter):
def predicate(driver):
if self._is_element_present(*self._empty_table_locator):
return True
with self.waits_disabled():
return not self._is_element_displayed(row_getter())
try:
self.wait_till_element_disappears(row_getter)
self._wait_until(predicate)
except exceptions.TimeoutException:
return False
except IndexError: