获得验证信心的方式分别是:title URL text
from selenium import webdriver
from time import *
driver = webdriver.Chrome()
url = 'http://home.51cto.com/index?reback=http://9603083.blog.51cto.com/'
driver.get(url)
#打印当前页面
title = driver.title
print(title)
#打印当前页面URL
now_url = driver.current_url
print(now_url)
#执行登陆
driver.find_element_by_xpath('//*[@id="loginform-username"]').clear()
driver.find_element_by_xpath('//*[@id="loginform-username"]').send_keys('91ctt')
driver.find_element_by_xpath('//*[@id="loginform-password"]').clear()
driver.find_element_by_xpath('//*[@id="loginform-password"]').send_keys('CTT1106648034')
driver.find_element_by_xpath('//*[@id="login-form"]/div[3]/input').click()
sleep(3)
#再次打印当前页面
title = driver.title
print(title)
#打印当前页面URL
now_url = driver.current_url
print(now_url)
#获取用户名
usr = driver.find_element_by_xpath('/html/head/meta[3]').text
print(usr)
sleep(3)
driver.quit()
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。