首页 > 其他 > 详细

selennuim,

时间:2019-11-27 21:48:11      阅读:68      评论:0      收藏:0      [点我收藏+]
from selenium import webdriver

import time
bro=webdriver.Chrome()
bro.get("http://www.baidu.com")
bro.implicitly_wait(10)
# 1、find_element_by_id   根据id找
# 2、find_element_by_link_text     根据链接名字找到控件(a标签的文字)
# 3、find_element_by_partial_link_text   根据链接名字找到控件(a标签的文字)模糊查询
# 4、find_element_by_tag_name       根据标签名
# 5、find_element_by_class_name     根据类名
# 6、find_element_by_name           根据属性名
# 7、find_element_by_css_selector   根据css选择器
# 8、find_element_by_xpath          根据xpath选择

dl_button=bro.find_element_by_link_text("登录")
dl_button.click()
user_login=bro.find_element_by_id(TANGRAM__PSP_10__footerULoginBtn)
user_login.click()
time.sleep(1)
input_name=bro.find_element_by_name(userName)
input_name.send_keys("30323545@qq.com")
input_password=bro.find_element_by_id("TANGRAM__PSP_10__password")
input_password.send_keys("xxxxxx")
submit_button=bro.find_element_by_id(TANGRAM__PSP_10__submit)
time.sleep(1)
submit_button.click()

time.sleep(100)

print(bro.get_cookies())
bro.close()

#显示等待和隐示等待
#隐式等待:在查找所有元素时,如果尚未被加载,则等10秒
# browser.implicitly_wait(10)   表示等待所有,

#显式等待:显式地等待某个元素被加载
# wait=WebDriverWait(browser,10)
# wait.until(EC.presence_of_element_located((By.ID,‘content_left‘)))

 

selennuim,

原文:https://www.cnblogs.com/yangxinpython/p/11945609.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!