Beispiel #1
0
 def __call__(self, driver):
     elements = driver.find_elements(*self.locator)
     if len(elements) - 1 > self.prev_length:
         self.prev_length = len(elements) - 1
         print(self.prev_length)
         elements = wait.until(
             EC.presence_of_all_elements_located(self.locator))
         print(len(elements) - 1)
         if len(elements) - 1 == self.prev_length:
             return elements
     else:
         return False
Beispiel #2
0
def open_edit_component_dialog(component_name):
    all_tr = wait.until(
        EC.presence_of_element_located(
            (By.CSS_SELECTOR,
             '#vui-workspace-grid-body > div > table > tbody')))

    i = binary_search_web_element_list(
        all_tr, 1,
        len(all_tr) - 1, (By.CSS_SELECTOR, 'td:nth-child(3) > div > div'),
        component_name)
    # Click pencil edit buttton
    all_tr[i].find_element_by_css_selector(
        'td:nth-child(2) > div > ul > li:nth-child(1)').click()
Beispiel #3
0
def navigate_to_directory_in_sidebar(directory_path: List[str]) -> None:
    all_tr_xpath = (  # Sidebar "Category Tree"
        '//div[@class="x-panel-body x-grid-body x-panel-body-default x-panel-body-default x-layout-fit"]' + \
        '[starts-with(@id, "vui-vcm-ui-picker-")]//div//table//tbody//tr')
    all_tr = find_all_e(all_tr_xpath, By.XPATH)
    start, end = 2, len(all_tr) - 1
    for directory in directory_path:
        index_of_directory = binary_search_web_element_list(
            all_tr, start, end, (By.CSS_SELECTOR, 'td > div'), directory)

        # If list item is second to last in the list
        if directory_path.index(directory) == len(directory_path) - 2:
            e = all_tr[index_of_directory].find_element(
                By.CSS_SELECTOR, 'td > div')
            e.click()
            wait_for_loading_dialog()
            return

        e = all_tr[index_of_directory].find_elements(By.CSS_SELECTOR,
                                                     'td > div > img')[-2]
        e.click()

        prev_all_tr_length = len(all_tr) - 1
        # Custom wait function
        all_tr = wait.until(
            nodes_have_been_added((By.XPATH, all_tr_xpath),
                                  prev_all_tr_length))
        time.sleep(
            2)  # Possibly change poll time for custom wait function to 1 sec
        start = index_of_directory + 1
        end = len(all_tr) - 1 - prev_all_tr_length + index_of_directory

    # Upon clicking category, element is detached from DOM. Selector below necessary before another click
    all_categories_expand = all_tr.find_element_by_css_selector(
        'tr:nth-child(2) > td > div')
    all_categories_expand.click(
    )  # Sometimes click does not register even when scrolled into view :thinking: ...
Beispiel #4
0
def find_all_e_wait(selector, by=By.CSS_SELECTOR):
    return wait.until(EC.presence_of_all_elements_located((by, selector) ))