Exemplo n.º 1
0
 def _select_by(self, by_attr, val):
   """Selects dropdown element based on dropdown attr"""
   for element in self.find_options():
     if element.get_attribute(by_attr) == val:
       element.click()
       break
   else:
     exception.ElementNotFound(val)
Exemplo n.º 2
0
 def select(self, member_name):
     """Selects dropdown element based on dropdown element name."""
     for element in self.elements_dropdown:
         if element.get_attribute("value") == member_name:
             element.click()
             break
     else:
         exception.ElementNotFound(member_name)
Exemplo n.º 3
0
 def select(self, member_name):
     """Selects the dropdown element based on dropdown element name"""
     for element in self.elements_dropdown:
         if element.text == member_name:
             element.click()
             break
     else:
         exception.ElementNotFound(member_name)
Exemplo n.º 4
0
 def expand_collapse_group(self, item_title, expand=True):
   """Expand/collapse 2-nd tier of Tree View item."""
   items = self.get_items_list()
   for i in items:
     if i.text == item_title:
       if expand:
         return i.expand()
       return i.collapse()
   raise exception.ElementNotFound('{} in list {}'.format(item_title, items))
Exemplo n.º 5
0
 def expand_collapse_group(self, item_title, expand=True):
   """Expand/collapse 2-nd tier of Tree View item."""
   items = self.get_items_list()
   for i in items:
     if i.text == item_title:
       if expand:
         i.expand()
         return widget_base.CustomAttributesItemContent(self._driver, i.text)
       return i.collapse()
   raise exception.ElementNotFound('{} in list {}'.format(item_title, items))
Exemplo n.º 6
0
 def find_elements_by_visible_locator(self, locator):
     """Sometimes we have to find in list of elements only that one that is
 visible to user.
 Args: locator (tuple)
 Return: selenium.webdriver.remote.webelement.WebElement
 Raises: exception.ElementNotFound
 """
     # pylint: disable=invalid-name
     elements = self.find_elements(*locator)
     for element in elements:
         if element.is_displayed():
             return element
     raise exception.ElementNotFound(locator)
Exemplo n.º 7
0
def click_on_staleable_element(driver, el_locator):
    """Click element that can be modified between time we find it and when
 we click on it."""
    time_start = time.time()
    while time.time() - time_start < constants.ux.MAX_USER_WAIT_SECONDS:
        try:
            driver.find_element(*el_locator).click()
            break
        except exceptions.StaleElementReferenceException as err:
            LOGGER.error(err)
            time.sleep(0.1)
    else:
        raise exception.ElementNotFound(el_locator)