def has_item(self, item_names): """Check that navigate menu has item. Args: item_names (list): list of items of navigate menu. Returns: bool: is items in menu """ container = self parent_item = None for item_name in item_names: item = ui.Block(By.XPATH, self._item_selector.format(item_name)) item.container = container try: item.webelement.tag_name except Exception: return False if not item.webelement.is_displayed() and parent_item: parent_item.click() wait(item.webelement.is_displayed, timeout_seconds=10, sleep_seconds=0.1) container = ui.Block(By.XPATH, self._sub_container_selector) container.container = item parent_item = item return True
def go_to(self, item_names): """Go to page via navigate menu. Arguments: - item_names: list of items of navigate menu. """ container = self parent_item = None for item_name in item_names: item = ui.Block(By.XPATH, self._item_selector.format(item_name)) item.container = container if not item.webelement.is_displayed() and parent_item: parent_item.click() time.sleep(1) wait(item.webelement.is_displayed, timeout_seconds=10, sleep_seconds=0.1) container = ui.Block(By.XPATH, self._sub_container_selector) container.container = item parent_item = item item.click()
def go_to(self, item_names): """Go to page via navigate menu. Arguments: - item_names: list of items of navigate menu. """ container = self last_name = item_names[-1] for item_name in item_names: item = ui.UI(By.XPATH, self._item_selector.format(item_name)) item.container = container if item_name == last_name: item.click() break sub_menu = ui.Block(By.XPATH, self._sub_menu_selector.format(item_name)) sub_menu.container = container if not _is_expanded(sub_menu): item.click() wait(lambda: _is_expanded(sub_menu), timeout_seconds=10, sleep_seconds=0.1) container = sub_menu
def go_to(self, item_names): """Go to page via navigate menu. Arguments: - item_names: list of items of navigate menu. """ container = self last_name = item_names[-1] for item_name in item_names: item = ui.UI(By.XPATH, './li/a[contains(., "{}")]'.format(item_name)) item.container = container if item_name == last_name: item.click() break sub_menu = ui.Block( By.XPATH, ('./li/ul[contains(@class, "collapse") and preceding-sibling' '::a[contains(., "{}")]]'.format(item_name))) sub_menu.container = container if not _is_expanded(sub_menu): item.click() wait(lambda: _is_expanded(sub_menu), timeout_seconds=10, sleep_seconds=0.1) container = sub_menu
def get_index(self, name): """Get index by cell name.""" locator = By.XPATH, '*' elements = self.find_elements(locator) element = ui.Block(By.XPATH, self.element_xpath.format(name)) element.container = self if element.webelement in elements: result = elements.index(element.webelement) + 1 else: result = -1 return result
def has_item(self, item_names): """Check that navigate menu has item. Args: item_names (list): list of items of navigate menu. Returns: bool: is items in menu """ container = self last_name = item_names[-1] for item_name in item_names: item = ui.UI(By.XPATH, self._item_selector.format(item_name)) item.container = container if not item.is_present: return False if item_name == last_name: break sub_menu = ui.Block(By.XPATH, self._sub_menu_selector.format(item_name)) sub_menu.container = container if not sub_menu.is_present: return False if not _is_expanded(sub_menu): item.click() wait(lambda: _is_expanded(sub_menu), timeout_seconds=10, sleep_seconds=0.1) container = sub_menu return True