本文整理汇总了Python中selenium.webdriver.support.expected_conditions.title_is方法的典型用法代码示例。如果您正苦于以下问题:Python expected_conditions.title_is方法的具体用法?Python expected_conditions.title_is怎么用?Python expected_conditions.title_is使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类selenium.webdriver.support.expected_conditions
的用法示例。
在下文中一共展示了expected_conditions.title_is方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: wait_for_page
# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import title_is [as 别名]
def wait_for_page(self, title=None, element_id=None):
if title:
WebDriverWait(self.selenium, 10).until(
EC.title_is(title)
)
WebDriverWait(self.selenium, 10).until(
EC.presence_of_element_located((By.ID, 'div-spinner'))
)
WebDriverWait(self.selenium, 10).until(
EC.invisibility_of_element_located((By.ID, 'img-spinner'))
)
if element_id:
WebDriverWait(self.selenium, 10).until(
EC.presence_of_element_located((By.ID, element_id))
)
示例2: run_for_driver
# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import title_is [as 别名]
def run_for_driver(driver, test):
driver.implicitly_wait(30)
driver.get("http://127.0.0.1:" + test.port)
wait = WebDriverWait(driver, 30)
wait.until(EC.title_is("tqsdk-python-web")) # k线图显示
logo = driver.find_element_by_tag_name("img")
test.assertEqual("Tianqin", logo.get_attribute("alt"))
# K线是否有成交箭头
chart_main_marks = driver.find_element_by_css_selector("svg.tqchart>g.root g.main.marks")
trade_arrow_paths = chart_main_marks.find_element_by_css_selector("g.tradearrow")
wait = WebDriverWait(driver, 30)
wait.until(element_has_child(trade_arrow_paths, "path"))
# 成交列表是否显示
trades_table = driver.find_element_by_css_selector("div.reports.trades-table>table")
wait = WebDriverWait(driver, 30)
wait.until(element_has_child(trades_table, "tbody>tr"))
driver.close()
示例3: run_for_driver
# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import title_is [as 别名]
def run_for_driver(driver, test):
driver.implicitly_wait(30)
driver.get("http://127.0.0.1:" + test.port)
wait = WebDriverWait(driver, 30)
wait.until(EC.title_is("tqsdk-python-web")) # k线图显示
logo = driver.find_element_by_tag_name("img")
test.assertEqual("Tianqin", logo.get_attribute("alt"))
account_info = driver.find_element_by_class_name("account-info")
accounts = account_info.find_elements_by_tag_name("div")
test.assertEqual(5, len(accounts))
# 测试K线图是否显示
chart_main_candle = driver.find_element_by_css_selector("svg.tqchart>g.root g.plot.main.candle")
main_candle_paths = chart_main_candle.find_elements_by_tag_name("path")
test.assertEqual(6, len(main_candle_paths))
up_body = chart_main_candle.find_element_by_css_selector("path.candle.body.up")
down_body = chart_main_candle.find_element_by_css_selector("path.candle.body.down")
up_line = chart_main_candle.find_element_by_css_selector("path.candle.line.equal")
down_line = chart_main_candle.find_element_by_css_selector("path.candle.line.equal")
wait = WebDriverWait(driver, 30)
wait.until(path_element_has_d(up_body)) # k线图显示
wait.until(path_element_has_d(down_body))
wait.until(path_element_has_d(up_line))
wait.until(path_element_has_d(down_line))
driver.close()
示例4: test01RegisterNewUser
# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import title_is [as 别名]
def test01RegisterNewUser(self):
self.browser.get('http://'+self.URL)
self.browser.find_element_by_link_text('Register').click()
WebDriverWait(self.browser, 5).until(EC.title_is('anvio account registration'))
self.browser.find_element_by_id('inputFirstname').send_keys('Test')
self.browser.find_element_by_id('inputLastname').send_keys('User')
self.browser.find_element_by_id('inputAffiliation').send_keys('anvio')
self.browser.find_element_by_id('inputLogin').send_keys(self.USER+'2')
self.browser.find_element_by_id('inputPassword').send_keys('test')
self.browser.find_element_by_id('inputRepeatPassword').send_keys('test')
self.browser.find_element_by_id('inputEmail').send_keys(self.EMAIL)
self.browser.find_element_by_id('submit').click()
WebDriverWait(self.browser, 5).until(EC.presence_of_element_located((By.XPATH, '//div[@class="alert alert-success col-sm-6"]')))
self.assertTrue(self.browser.find_element_by_xpath('//div[@class="alert alert-success col-sm-6"]'))
示例5: test02Login
# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import title_is [as 别名]
def test02Login(self):
self.login()
WebDriverWait(self.browser, 5).until(EC.title_is('anvio user home'))
self.assertIn('anvio user home', self.browser.title)
示例6: test03ForgotPasswordInvalid
# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import title_is [as 别名]
def test03ForgotPasswordInvalid(self):
self.browser.get('http://'+self.URL)
self.browser.find_element_by_link_text('forgot password?').click()
WebDriverWait(self.browser, 5).until(EC.title_is('anvio forgot password'))
self.browser.find_element_by_id('inputEmail').send_keys('invalid@email.com')
self.browser.find_element_by_id('submit').click()
WebDriverWait(self.browser, 5).until(EC.alert_is_present())
self.assertEqual('Resetting password failed: No user has been found for email address "invalid@email.com"', Alert(self.browser).text)
示例7: test04ForgotPasswordValid
# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import title_is [as 别名]
def test04ForgotPasswordValid(self):
self.browser.get('http://'+self.URL)
self.browser.find_element_by_link_text('forgot password?').click()
WebDriverWait(self.browser, 5).until(EC.title_is('anvio forgot password'))
self.browser.find_element_by_id('inputEmail').send_keys(self.USER+'@email')
self.browser.find_element_by_id('submit').click()
WebDriverWait(self.browser, 5).until(EC.presence_of_element_located((By.XPATH, '//div[@class="alert alert-success col-sm-6"]')))
self.assertTrue(self.browser.find_element_by_xpath('//div[@class="alert alert-success col-sm-6"]'))
示例8: test07SelectProject
# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import title_is [as 别名]
def test07SelectProject(self):
self.login()
WebDriverWait(self.browser, 5).until(EC.presence_of_element_located((By.LINK_TEXT, 'test_project_with_all_files')))
self.browser.find_element_by_link_text('test_project_with_all_files').click()
WebDriverWait(self.browser, 5).until(EC.title_is('test_project_with_all_files'))
self.assertIn('test_project_with_all_files', self.browser.title)
示例9: wait_for_title
# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import title_is [as 别名]
def wait_for_title(self, title, **kwargs):
'''
Wait for the page title to match given title.
Parameters
----------
title: str
The page title to wait for
kwargs:
Passed on to _wait_for
'''
self._wait_for(EC.title_is(title), **kwargs)
示例10: wait_for_title
# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import title_is [as 别名]
def wait_for_title(self, title, timeout):
"""Wait for page title to be the given value
:Args:
- title: expected title
- timeout: time to wait (in seconds)
"""
wait = WebDriverWait(self, timeout)
message = 'Timeout waiting for title to be \'{}\''.format(title)
wait.until(ec.title_is(title), message=message)
示例11: wait_for_title_is_not
# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import title_is [as 别名]
def wait_for_title_is_not(self, title, timeout):
"""Wait for page title to not be the given value
:Args:
- title: not expected title
- timeout: time to wait (in seconds)
"""
wait = WebDriverWait(self, timeout)
message = 'Timeout waiting for title to not be \'{}\''.format(title)
wait.until_not(ec.title_is(title), message=message)
示例12: login
# 需要导入模块: from selenium.webdriver.support import expected_conditions [as 别名]
# 或者: from selenium.webdriver.support.expected_conditions import title_is [as 别名]
def login(self):
print("正在打开二维码登陆界面,请稍后")
self.driver.get("https://pc.xuexi.cn/points/login.html")
try:
remover = WebDriverWait(self.driver, 30, 0.2).until(
lambda driver: driver.find_element_by_class_name("redflagbox"))
except exceptions.TimeoutException:
print("网络缓慢,请重试")
else:
self.driver.execute_script('arguments[0].remove()', remover)
try:
remover = WebDriverWait(self.driver, 30, 0.2).until(
lambda driver: driver.find_element_by_class_name("header"))
except exceptions.TimeoutException:
print("当前网络缓慢...")
else:
self.driver.execute_script('arguments[0].remove()', remover)
try:
remover = WebDriverWait(self.driver, 30, 0.2).until(
lambda driver: driver.find_element_by_class_name("footer"))
except exceptions.TimeoutException:
print("当前网络缓慢...")
else:
self.driver.execute_script('arguments[0].remove()', remover)
self.driver.execute_script('window.scrollTo(document.body.scrollWidth/2 - 200 , 0)')
try:
WebDriverWait(self.driver, 270).until(EC.title_is(u"我的学习"))
cookies = self.get_cookies()
return cookies
except:
print("扫描二维码超时")