本文整理汇总了Python中selenium.webdriver.support.expected_conditions.title_contains函数的典型用法代码示例。如果您正苦于以下问题:Python title_contains函数的具体用法?Python title_contains怎么用?Python title_contains使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了title_contains函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_login_and_post
def test_login_and_post(self):
# Go to the coop home page
self.driver.get("https://bc.libraries.coop/")
# Log in
self.driver.find_element_by_id("loginbtn").click()
usernameField_present = EC.presence_of_element_located((By.ID, 'user_login'))
WebDriverWait(self.driver, 10).until(usernameField_present)
self.driver.find_element_by_id("user_login").send_keys(self.config['account']['username'])
time.sleep(2)
self.driver.find_element_by_id("user_pass").send_keys(self.config['account']['password'])
time.sleep(2)
self.driver.find_element_by_id("user-submit").click()
time.sleep(2)
# Navigate to My Dashboard
self.driver.find_element_by_id("loginbtn").click()
dashboardButton_present = EC.presence_of_element_located((By.LINK_TEXT, 'My Dashboard'))
WebDriverWait(self.driver, 10).until(dashboardButton_present)
self.driver.find_element_by_link_text("My Dashboard").click()
WebDriverWait(self.driver, 10).until(EC.title_contains("Dashboard |"))
# Navigate to test group, write and publish a post
self.driver.find_element_by_xpath("//span[@class='group-title']").click()
WebDriverWait(self.driver, 10).until(EC.title_contains("Home | Maple Public Library |"))
self.driver.find_element_by_xpath("//textarea[@id='whats-new'][@name='whats-new']").send_keys(
"This is a test post by Selenium Webdriver")
self.driver.find_element_by_xpath(
"//input[@id='aw-whats-new-submit']").send_keys("\n") # NOTE: Need to send "\n" instead of click for some weird wordpress buttons..
# Check that the post is present, then delete it
post_present = EC.presence_of_element_located((
By.XPATH, "//div[@class='activity-inner']/p[text()='This is a test post by Selenium Webdriver']/../../div[@class='activity-meta']/a[text()='Delete']"))
WebDriverWait(self.driver, 10).until(post_present)
self.driver.find_element_by_xpath(
"//div[@class='activity-inner']/p[text()='This is a test post by Selenium Webdriver']/../../div[@class='activity-meta']/a[text()='Delete']").send_keys("\n")
示例2: listing_type
def listing_type(driver, params):
print(('Listing types:'
'\n\tAll Listings (1)'
'\n\tAuction (2)'
'\n\tBuy It Now (3)'))
user_input = input('Choose 1-3: ')
if user_input == '1':
driver.set_window_size(1440, 900)
button = driver.find_element_by_xpath(r'//*[@title="All Listings"]')
button.click()
WebDriverWait(driver, 10).until(ec.title_contains(params))
elif user_input == '2':
driver.set_window_size(1440, 900)
button = driver.find_element_by_xpath(r'//*[@title="Auction"]')
button.click()
WebDriverWait(driver, 10).until(ec.title_contains(params))
elif user_input == '3':
driver.set_window_size(1440, 900)
button = driver.find_element_by_xpath(r'//*[@title="Buy It Now"]')
button.click()
WebDriverWait(driver, 10).until(ec.title_contains(params))
else:
print('{} does not appear to be a correct choice, please try again'.format(user_input))
listing_type(driver, params)
示例3: testExpectedConditionTitleContains
def testExpectedConditionTitleContains(self, driver, pages):
pages.load("blank.html")
driver.execute_script("setTimeout(function(){document.title='not blank'}, 200)")
WebDriverWait(driver, 1).until(EC.title_contains("not"))
assert driver.title == 'not blank'
with pytest.raises(TimeoutException):
WebDriverWait(driver, 0.7).until(EC.title_contains("blanket"))
示例4: _do_signup
def _do_signup(self):
# Go to the webpage
self.browser.get(self.url)
wait = ui.WebDriverWait(self.browser, self.timeout)
wait.until(expected_conditions.visibility_of_element_located(["id", "logo"]))
# Log out any existing user
if self.browser.find_elements_by_id("nav_logout"):
nav = self.browser.find_element_by_id("nav_logout")
if nav.is_displayed():
self.browser.find_element_by_id("nav_logout").click()
wait = ui.WebDriverWait(self.browser, self.timeout)
wait.until(expected_conditions.title_contains(("Home")))
# Go to the sign-up page
wait = ui.WebDriverWait(self.browser, self.timeout)
wait.until(expected_conditions.visibility_of_element_located(["id", "nav_signup"]))
self.browser.find_element_by_id("nav_signup").click()
wait = ui.WebDriverWait(self.browser, self.timeout)
wait.until(expected_conditions.title_contains(("Sign up")))
# Sign up (don't choose facility or group)
wait = ui.WebDriverWait(self.browser, self.timeout)
wait.until(expected_conditions.visibility_of_element_located(["id", "id_username"]))
self.browser.find_element_by_id("id_username").send_keys(self.username)
wait = ui.WebDriverWait(self.browser, self.timeout)
wait.until(expected_conditions.visibility_of_element_located(["id", "id_password_first"]))
self.browser.find_element_by_id("id_password_first").send_keys(self.password)
self.browser.find_element_by_id("id_password_recheck").send_keys(self.password)
self.browser.find_element_by_id("id_password_recheck").send_keys(Keys.TAB + Keys.RETURN)
wait = ui.WebDriverWait(self.browser, self.timeout)
wait.until(expected_conditions.visibility_of_element_located(["id", "logo"]))
示例5: test_register_as_institution
def test_register_as_institution(self):
# Go to the bcla home page
self.driver.get("https://dev.bclaconnect.ca")
WebDriverWait(self.driver, 10).until(EC.title_contains("BCLA Connect"))
# Hover over myBCLA button, click join button
mouse = webdriver.ActionChains(self.driver)
myBCLA = self.driver.find_element_by_xpath("//a[@href='/mybcla']")
mouse.move_to_element(myBCLA).perform()
joinButton_present = EC.presence_of_element_located((By.XPATH, "//a[@href='/membership/join-bcla/'][@class='bcla-login-link']"))
WebDriverWait(self.driver, 10).until(joinButton_present)
self.driver.find_element_by_xpath("//a[@href='/membership/join-bcla/'][@class='bcla-login-link']").click()
# Choose institutional membership
WebDriverWait(self.driver, 10).until(EC.title_contains("Join BCLA |"))
self.driver.find_element_by_link_text("Institutional Membership").click()
WebDriverWait(self.driver, 10).until(EC.title_contains("Institutional Membership"))
# Fill in form
self.driver.find_element_by_id("CIVICRM_QFID_490_16").click()
randomString = ''.join(random.SystemRandom().choice(string.ascii_lowercase + string.digits) for _ in range(5))
mailAddress = randomString + '@mailinator.com'
self.driver.find_element_by_id("email-5").send_keys(mailAddress)
usrName = self.config['account']['username'] + randomString
self.driver.find_element_by_id("onbehalf_organization_name").send_keys(usrName)
self.driver.find_element_by_id("onbehalf_phone-3-1").send_keys(self.config['account']['phone'])
self.driver.find_element_by_id("onbehalf_email-3").send_keys(mailAddress)
self.driver.find_element_by_id("onbehalf_street_address-3").send_keys(self.config['account']['address'])
self.driver.find_element_by_id("onbehalf_city-3").send_keys(self.config['account']['city'])
self.driver.find_element_by_id("onbehalf_postal_code-3").send_keys(self.config['account']['postal'])
self.driver.find_element_by_id("cms_name").send_keys(usrName)
self.driver.find_element_by_id("cms_pass").send_keys(self.config['account']['password'])
self.driver.find_element_by_id("cms_confirm_pass").send_keys(self.config['account']['password'])
self.driver.find_element_by_id("first_name").send_keys(self.config['account']['firstname'])
self.driver.find_element_by_id("last_name").send_keys(self.config['account']['lastname'])
self.driver.find_element_by_xpath("//a[@class='crm-credit_card_type-icon-mastercard']").click()
self.driver.find_element_by_id("credit_card_number").send_keys('5555555555554444')
self.driver.find_element_by_id("cvv2").send_keys('066')
self.driver.find_element_by_xpath("//select[@id='credit_card_exp_date_M']/option[text()='Jan']").click()
self.driver.find_element_by_xpath("//select[@id='credit_card_exp_date_Y']/option[text()='2026']").click()
self.driver.find_element_by_id("billing_first_name").send_keys(self.config['account']['firstname'])
self.driver.find_element_by_id("billing_last_name").send_keys(self.config['account']['lastname'])
self.driver.find_element_by_id("billing_street_address-5").send_keys(self.config['account']['address'])
self.driver.find_element_by_id("billing_city-5").send_keys(self.config['account']['city'])
self.driver.find_element_by_id("billing_postal_code-5").send_keys(self.config['account']['postal'])
self.driver.find_element_by_id("CIVICRM_QFID_0_12").click()
self.driver.find_element_by_id("_qf_Main_upload-bottom").click()
#Click "make payment"
paymentButton_present = EC.presence_of_element_located((By.ID, "_qf_Confirm_next-top"))
WebDriverWait(self.driver, 10).until(paymentButton_present)
self.driver.find_element_by_id("_qf_Confirm_next-top").click()
# Check that payment went through
WebDriverWait(self.driver, 60).until(EC.title_contains("Welcome to BCLA"))
src = self.driver.page_source
text_found = re.search(r'Your transaction has been processed successfully. Please print this page for your records.', src)
self.assertNotEqual(text_found, None)
# Check the email was sent and received
self.driver.get("https://www.mailinator.com/inbox2.jsp?public_to=" + randomString + "#/#public_maildirdiv")
WebDriverWait(self.driver, 30).until(EC.title_contains("Mailinator"))
print("Mailbox at:")
print("https://www.mailinator.com/inbox2.jsp?public_to=" + randomString + "#/#public_maildirdiv")
print("Should contain a welcome message and receipt for an institutional membership.")
示例6: testLogin
def testLogin(self):
driver = self.browser
driver.get('https://localhost:8000/formular/')
element = WebDriverWait(driver, 10).until(EC.title_contains('OpenID'))
sub = driver.find_element_by_id('j_username').send_keys(id)
driver.find_element_by_id('j_password').send_keys(password)
driver.find_element_by_xpath("html/body/div/div/div/form/div/input").click()
element = WebDriverWait(driver, 10).until(EC.title_contains('HPC'))
self.assertIn('HPC', driver.title)
示例7: testExpectedConditionTitleContains
def testExpectedConditionTitleContains(self, driver, pages):
if driver.capabilities['browserName'] == 'firefox' and driver.w3c:
pytest.xfail("Marionette issue: https://bugzilla.mozilla.org/show_bug.cgi?id=1297551")
pages.load("blank.html")
driver.execute_script("setTimeout(function(){document.title='not blank'}, 200)")
WebDriverWait(driver, 1).until(EC.title_contains("not"))
assert driver.title == 'not blank'
with pytest.raises(TimeoutException):
WebDriverWait(driver, 0.7).until(EC.title_contains("blanket"))
示例8: testExpectedConditionTitleContains
def testExpectedConditionTitleContains(self):
self._loadPage("blank")
self.driver.execute_script("setTimeout(function(){document.title='not blank'}, 200)")
WebDriverWait(self.driver, 1).until(EC.title_contains("not"))
self.assertEqual(self.driver.title, 'not blank')
try:
WebDriverWait(self.driver, 0.7).until(EC.title_contains("blanket"))
self.fail("Expected TimeoutException to have been thrown")
except TimeoutException as e:
pass
示例9: log_user_in
def log_user_in(self, username, password):
self.browser.get(self.url)
self.wait.until(EC.title_contains('Log in'))
login_box = self.wait.until(
EC.presence_of_element_located((By.ID, 'id_username')))
login_box.send_keys(username)
password_box = self.wait.until(
EC.presence_of_element_located((By.ID, 'id_password')))
password_box.send_keys(password)
password_box.send_keys(Keys.ENTER)
self.wait.until(EC.title_contains('Facility Management'))
self.logged_in = True
示例10: _do_login_step_1
def _do_login_step_1(self, args):
wait = ui.WebDriverWait(self.browser, self.timeout)
wait.until(expected_conditions.title_contains(("Log in")))
wait = ui.WebDriverWait(self.browser, self.timeout)
wait.until(expected_conditions.element_to_be_clickable((By.ID, "id_username")))
elem = self.browser.find_element_by_id("id_username")
elem.send_keys(args["username"])
elem = self.browser.find_element_by_id("id_password")
elem.send_keys(args["password"])
elem.send_keys(Keys.RETURN)
wait = ui.WebDriverWait(self.browser, self.timeout)
wait.until(expected_conditions.title_contains(("User report")))
示例11: test_aregister_as_individual
def test_aregister_as_individual(self):
# This test creates the account that "test_donate_as_individual" uses, hence the "a" in the name, so Selenium runs it first
# Go to the bcla home page
self.driver.get("https://dev.bclaconnect.ca")
WebDriverWait(self.driver, 10).until(EC.title_contains("BCLA Connect"))
# Hover over myBCLA button, click join button
mouse = webdriver.ActionChains(self.driver)
myBCLA = self.driver.find_element_by_xpath("//a[@href='/mybcla']")
mouse.move_to_element(myBCLA).perform()
joinButton_present = EC.presence_of_element_located((By.XPATH, "//a[@href='/membership/join-bcla/'][@class='bcla-login-link']"))
WebDriverWait(self.driver, 10).until(joinButton_present)
self.driver.find_element_by_xpath("//a[@href='/membership/join-bcla/'][@class='bcla-login-link']").click()
# Choose individual membership
WebDriverWait(self.driver, 10).until(EC.title_contains("Join BCLA |"))
self.driver.find_element_by_link_text("Individual Membership").click()
WebDriverWait(self.driver, 10).until(EC.title_contains("Individual Membership |"))
# Fill in form
mailAddress = BCLATests.individualRandomString + '@mailinator.com'
self.driver.find_element_by_id("email-5").send_keys(mailAddress)
self.driver.find_element_by_id("cms_name").send_keys(self.config['account']['username'] + BCLATests.individualRandomString)
self.driver.find_element_by_id("cms_pass").send_keys(self.config['account']['password'])
self.driver.find_element_by_id("cms_confirm_pass").send_keys(self.config['account']['password'])
self.driver.find_element_by_id("first_name").send_keys(self.config['account']['firstname'])
self.driver.find_element_by_id("last_name").send_keys(self.config['account']['lastname'])
self.driver.find_element_by_id("street_address-Primary").send_keys(self.config['account']['address'])
self.driver.find_element_by_id("city-Primary").send_keys(self.config['account']['city'])
#self.driver.find_element_by_xpath("//div[@id='s2id_state_province-Primary']").click()
self.driver.find_element_by_id("postal_code-Primary").send_keys(self.config['account']['postal'])
self.driver.find_element_by_xpath("//a[@class='crm-credit_card_type-icon-mastercard']").click()
self.driver.find_element_by_id("credit_card_number").send_keys('5555555555554444')
self.driver.find_element_by_id("cvv2").send_keys('066')
self.driver.find_element_by_xpath("//select[@id='credit_card_exp_date_M']/option[text()='Jan']").click()
self.driver.find_element_by_xpath("//select[@id='credit_card_exp_date_Y']/option[text()='2026']").click()
self.driver.find_element_by_id("CIVICRM_QFID_0_12").click()
self.driver.find_element_by_id("_qf_Main_upload-bottom").click()
#Click "make payment"
paymentButton_present = EC.presence_of_element_located((By.ID, "_qf_Confirm_next-top"))
WebDriverWait(self.driver, 10).until(paymentButton_present)
self.driver.find_element_by_id("_qf_Confirm_next-top").click()
# Check that payment went through
WebDriverWait(self.driver, 60).until(EC.title_contains("Welcome to BCLA"))
src = self.driver.page_source
text_found = re.search(r'Your transaction has been processed successfully. Please print this page for your records.', src)
self.assertNotEqual(text_found, None)
# Check the email was sent and received
self.driver.get("https://www.mailinator.com/inbox2.jsp?public_to=" + BCLATests.individualRandomString + "#/#public_maildirdiv")
WebDriverWait(self.driver, 30).until(EC.title_contains("Mailinator"))
print("Mailbox at:")
print("https://www.mailinator.com/inbox2.jsp?public_to=" + BCLATests.individualRandomString + "#/#public_maildirdiv")
print("Should contain a welcome message and receipt for an individual membership.")
self.driver.quit()
示例12: get_auth_cookie
def get_auth_cookie(domain, login, password):
# configure chrome
options = Options()
#options.add_argument('--headless')
#options.add_argument('--disable-gpu')
options.add_argument('--window-size=700,600')
driver = webdriver.Chrome(chrome_options=options)
# load the login page and wait until the title contains GitLab
driver.get("https://{}/login".format(domain))
WebDriverWait(driver, 10).until(EC.title_contains("GitLab"))
# click on the gitlab button to continue
gitlabElement = driver.find_element_by_partial_link_text("GitLab")
gitlabElement.click()
# wait for the sign in page to load
WebDriverWait(driver, 10).until(EC.title_contains("Sign in"))
# fill out the username
emailElement = driver.find_element_by_id('username')
emailElement.send_keys(login)
# fill out the password
passwordElement = driver.find_element_by_id('password')
passwordElement.send_keys(password)
# submit the form
passwordElement.submit()
# wait until the page loads
WebDriverWait(driver, 600).until(EC.title_contains("User Settings"))
# authorize mattermost to use your account
#elementAuthorize = driver.find_element_by_name('commit')
elementAuthorize = driver.find_element_by_css_selector('input.btn-success')
elementAuthorize.click()
WebDriverWait(driver, 600).until(EC.title_contains("Mattermost"))
auth_cookie = None
for cookie in driver.get_cookies():
if cookie['name'] == 'MMAUTHTOKEN':
auth_cookie = cookie
driver.quit()
return auth_cookie
示例13: test_login_and_create_doc
def test_login_and_create_doc(self):
# Go to the coop home page
self.driver.get("https://bc.libraries.coop/")
# Log in
self.driver.find_element_by_id("loginbtn").click()
usernameField_present = EC.presence_of_element_located((By.ID, 'user_login'))
WebDriverWait(self.driver, 10).until(usernameField_present)
self.driver.find_element_by_id("user_login").send_keys(self.config['account']['username'])
time.sleep(2)
self.driver.find_element_by_id("user_pass").send_keys(self.config['account']['password'])
time.sleep(2)
self.driver.find_element_by_id("user-submit").click()
time.sleep(2)
# Go to Profile, Docs tab, click Create New Doc
self.driver.find_element_by_id("loginbtn").click()
profileButton_present = EC.presence_of_element_located((By.LINK_TEXT, 'My Profile'))
WebDriverWait(self.driver, 10).until(profileButton_present)
self.driver.find_element_by_link_text("My Profile").click()
WebDriverWait(self.driver, 10).until(EC.title_contains("Profile |"))
self.driver.find_element_by_id("user-docs").click()
WebDriverWait(self.driver, 10).until(EC.title_contains("Docs |"))
self.driver.find_element_by_id("bp-create-doc-button").click()
# Fill in Doc creation form
titleField_present = EC.presence_of_element_located((By.ID, 'doc-title'))
WebDriverWait(self.driver, 10).until(titleField_present)
self.driver.find_element_by_id("doc-title").send_keys("Selenium Test Document")
self.driver.find_element_by_id("doc_content-html").click()
contentField_present = EC.presence_of_element_located((By.XPATH, "//textarea[@id='doc_content'][@name='doc_content']"))
WebDriverWait(self.driver, 10).until(contentField_present)
self.driver.find_element_by_xpath("//textarea[@id='doc_content'][@name='doc_content']").send_keys(
"This is a test document created to test site functionality with Selenium Webdriver.")
self.driver.find_element_by_xpath("//select[@id='settings-read']/option[text()='The Doc author only']").click()
# Save doc and check it was succesfully created
self.driver.find_element_by_id("doc-edit-submit").click()
src = self.driver.page_source
text_found = re.search(r'Doc successfully created', src)
self.assertNotEqual(text_found, None)
# Delete the doc and check it was succesfully deleted
self.driver.find_element_by_link_text("Edit").click()
deleteButton_present = EC.presence_of_element_located((By.LINK_TEXT, 'Permanently Delete'))
WebDriverWait(self.driver, 10).until(deleteButton_present)
self.driver.find_element_by_link_text("Permanently Delete").click()
alert = self.driver.switch_to_alert() # This will cause a warning, but the "newer" method of this does not work.
alert.accept()
time.sleep(2)
src = self.driver.page_source
text_found = re.search(r'Doc successfully deleted', src)
self.assertNotEqual(text_found, None)
示例14: _click_sign_in_button
def _click_sign_in_button(self):
"""
Clicks the Sign In button.
"""
self._driver.find_element(*self._sign_in_button).click()
self._wait.until(ec.title_contains(self.page_title), "The page does not contain the " + self.page_title + " title.")
return self
示例15: test_google_search
def test_google_search(self):
# Create a new instance of the Firefox self.driver
#self.driver = webself.driver.Firefox()
# go to the google home page
self.driver.get("http://www.google.com")
# find the element that's name attribute is q (the google search box)
inputElement = self.driver.find_element_by_name("q")
# type in the search
inputElement.send_keys("cheese!")
# submit the form (although google automatically searches now without submitting)
inputElement.submit()
# the page is ajaxy so the title is originally this:
print( self.driver.title )
try:
# we have to wait for the page to refresh, the last thing that seems to be updated is the title
WebDriverWait(self.driver, 10).until(EC.title_contains("cheese!"))
# You should see "cheese! - Google Search"
print( self.driver.title )
self.assertTrue( self.driver.title.find( "cheese!" ) != -1 )
finally:
self.driver.quit()