當前位置: 首頁>>代碼示例>>Python>>正文


Python expected_conditions.visibility_of方法代碼示例

本文整理匯總了Python中selenium.webdriver.support.expected_conditions.visibility_of方法的典型用法代碼示例。如果您正苦於以下問題:Python expected_conditions.visibility_of方法的具體用法?Python expected_conditions.visibility_of怎麽用?Python expected_conditions.visibility_of使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在selenium.webdriver.support.expected_conditions的用法示例。


在下文中一共展示了expected_conditions.visibility_of方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: wait_until_visibilty_is_confirmed

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import visibility_of [as 別名]
def wait_until_visibilty_is_confirmed(self, browser_instance,
                                               element, timeout=5):
        try:
            WebDriverWait(browser_instance, int(timeout)).until(EC.visibility_of(element))
            status = True
        except TimeoutException:
            print_error("Element not visible after {0} seconds".format(timeout))
            status = False
        except Exception as e:
            print_error("An Exception Ocurred: {0}".format(e))
            status = "ERROR"
        return status 
開發者ID:warriorframework,項目名稱:warriorframework,代碼行數:14,代碼來源:wait_operations.py

示例2: get_employees

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import visibility_of [as 別名]
def get_employees(self, wait_time=10):
        list_css = "search-results"
        next_xpath = '//button[@aria-label="Next"]'
        driver = self.driver

        see_all_employees = driver.find_element_by_xpath('//a[@data-control-name="topcard_see_all_employees"]')
        driver.get(see_all_employees.get_attribute("href"))

        _ = WebDriverWait(driver, wait_time).until(EC.presence_of_element_located((By.CLASS_NAME, list_css)))

        total = []
        driver.execute_script("window.scrollTo(0, Math.ceil(document.body.scrollHeight/2));")
        time.sleep(1)
        driver.execute_script("window.scrollTo(0, Math.ceil(document.body.scrollHeight*3/4));")
        results_list = driver.find_element_by_class_name(list_css)
        results_li = results_list.find_elements_by_tag_name("li")
        for res in results_li:
            total.append(self.__parse_employee__(res))

        while self.__find_enabled_element_by_xpath__(next_xpath):
            driver.find_element_by_xpath(next_xpath).click()
            _ = WebDriverWait(driver, wait_time).until(EC.presence_of_element_located((By.CLASS_NAME, list_css)))

            driver.execute_script("window.scrollTo(0, Math.ceil(document.body.scrollHeight/4));")
            time.sleep(1)
            driver.execute_script("window.scrollTo(0, Math.ceil(document.body.scrollHeight/3));")
            time.sleep(1)
            driver.execute_script("window.scrollTo(0, Math.ceil(document.body.scrollHeight/2));")
            time.sleep(1)
            driver.execute_script("window.scrollTo(0, Math.ceil(document.body.scrollHeight*2/3));")
            time.sleep(1)
            driver.execute_script("window.scrollTo(0, Math.ceil(document.body.scrollHeight*3/4));")

            results_list = driver.find_element_by_class_name(list_css)
            results_li = results_list.find_elements_by_tag_name("li")
            for res in results_li:
                _ = WebDriverWait(driver, wait_time).until(EC.visibility_of(res))
                total.append(self.__parse_employee__(res))
        return total 
開發者ID:joeyism,項目名稱:linkedin_scraper,代碼行數:41,代碼來源:company.py

示例3: wait_displayed

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import visibility_of [as 別名]
def wait_displayed(self, timeout=30):
        """Wait for element to be displayed

        :Returns:
          The element
        """
        wait = WebDriverWait(self.parent, timeout)
        message = ('Timeout waiting for element {} to be displayed'
                   .format(self.name))
        wait.until(ec.visibility_of(self), message=message)
        return self 
開發者ID:golemhq,項目名稱:golem,代碼行數:13,代碼來源:extended_webelement.py

示例4: wait_not_displayed

# 需要導入模塊: from selenium.webdriver.support import expected_conditions [as 別名]
# 或者: from selenium.webdriver.support.expected_conditions import visibility_of [as 別名]
def wait_not_displayed(self, timeout=30):
        """Wait for element to be not displayed

        :Returns:
          The element
        """
        wait = WebDriverWait(self.parent, timeout)
        message = ('Timeout waiting for element {} to be not displayed'
                   .format(self.name))
        wait.until_not(ec.visibility_of(self), message=message)
        return self 
開發者ID:golemhq,項目名稱:golem,代碼行數:13,代碼來源:extended_webelement.py


注:本文中的selenium.webdriver.support.expected_conditions.visibility_of方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。