本文整理汇总了Python中selenium.webdriver.support.expected_conditions.staleness_of方法的典型用法代码示例。如果您正苦于以下问题:Python expected_conditions.staleness_of方法的具体用法?Python expected_conditions.staleness_of怎么用?Python expected_conditions.staleness_of使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类selenium.webdriver.support.expected_conditions
的用法示例。
在下文中一共展示了expected_conditions.staleness_of方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: wait_for_element_not_present
# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import staleness_of [as 别名]
def wait_for_element_not_present(self, element, timeout):
"""Wait for element not present in the DOM
:Args:
- element: an element tuple, a CSS string or a WebElement object
- timeout: time to wait (in seconds)
"""
found_element = None
try:
found_element = self.find(element, timeout=0)
except ElementNotFound:
pass
if found_element:
wait = WebDriverWait(self, timeout)
message = ('Timeout waiting for element {} to not be present'
.format(found_element.name))
wait.until(ec.staleness_of(found_element), message=message)
示例2: submit_form
# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import staleness_of [as 别名]
def submit_form(self):
"""
Click the submit button on the form and wait for the next page to
load.
"""
html = self.client.find_element_by_tag_name('html')
submit = self.form.find_element_by_tag_name('button')
submit.click()
# Wait for page to start reloading.
WebDriverWait(self.client, timeout=3) \
.until(expected_conditions.staleness_of(html))
# Wait for page to finish reloading.
WebDriverWait(self.client, timeout=20) \
.until(lambda driver: driver.execute_script("return document.readyState;") == "complete")
示例3: wait_for_page_load
# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import staleness_of [as 别名]
def wait_for_page_load(self, timeout=10):
"""
This solution only works for "non-javascript" clicks, ie clicks that will cause the browser to load a brand new page, and thus load a brand new HTML body element.
@see http://www.obeythetestinggoat.com/how-to-get-selenium-to-wait-for-page-load-after-a-click.html
:param self:
:param timeout:
:return:
"""
self.log.debug("Waiting for page to load at {}.".format(self.driver.current_url))
old_page = self.find_element_by_tag_name('html')
yield
WebDriverWait(self, timeout).until(staleness_of(old_page))
示例4: _process_survey_age_country
# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import staleness_of [as 别名]
def _process_survey_age_country(self):
try:
print("* They want to know how old we are.")
age_field = self.wait.until(EC.element_to_be_clickable(
(By.NAME, 'rpAgeAndCountryAgeField')))
age_field.send_keys('55')
age_field.send_keys(Keys.RETURN)
# wait for age_field's DOM element to be removed
self.wait.until(EC.staleness_of(age_field))
except TimeoutException:
print("!!! Something's wrong with the survey")
示例5: _introduce_log_in_parameters
# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import staleness_of [as 别名]
def _introduce_log_in_parameters(cls, username=FILAB2_MAIL, password=FILAB_PASSWORD):
driver = cls.driver
id_username = WebDriverWait(cls.driver, 10).until(EC.presence_of_element_located((By.ID, "id_email")))
id_username.clear()
id_username.send_keys(username)
driver.find_element_by_id("id_password").clear()
driver.find_element_by_id("id_password").send_keys(password)
driver.find_element_by_xpath("//button[@type='submit']").click()
WebDriverWait(driver, 30).until(EC.staleness_of(id_username))
示例6: wait_for_page_load
# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import staleness_of [as 别名]
def wait_for_page_load(self, timeout=30):
old_page = self.driver.find_element_by_tag_name('html')
yield
WebDriverWait(self.driver, timeout).until(
expected_conditions.staleness_of(old_page),
message='waiting for page to load')
self.check_after_wait()