当前位置: 首页>>代码示例>>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;未经允许,请勿转载。