本文整理汇总了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
示例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
示例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
示例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