python selenium
来源:互联网 发布:mac os 10.11.6 镜像 编辑:程序博客网 时间:2024/05/18 19:19
- 使用chrome打开百度,并点击登录输入用户名与密码。
#/usr/bin/env python# -*- coding: UTF-8 -*-from selenium import webdriverfrom selenium.webdriver.common.keys import Keysfrom time import sleepfrom selenium.webdriver.common.action_chains import ActionChainsfrom selenium.webdriver.support.ui import Selectdriver=webdriver.Chrome()#需要使用chromedriver.exe,将其下载后存放到python安装目录下,如C:\Python27driver.get("http://www.baidu.com")sleep(2)#睡2s才可加载出对话框driver.find_element_by_link_text("登录").click()driver.find_element_by_id("TANGRAM__PSP_8__userName").send_keys("username")#也可使用css选择器来定位driver.find_element_by_css_selector("#TANGRAM__PSP_8__userName").send_keys("username"),但有id时建议直接使用find_element_by_id,有超链接直接使用find_element_by_link_textdriver.find_element_by_id("TANGRAM__PSP_8__password").send_keys("passwd")driver.find_element_by_id("TANGRAM__PSP_8__submit").click()driver.close()
0 0
- Selenium python
- python selenium
- python+selenium
- python + selenium
- Python Selenium
- python selenium
- Python selenium
- python+selenium
- selenium-python
- Python selenium
- Python+selenium
- Python+selenium
- python+selenium
- Python selenium
- python selenium
- Python+selenium
- python中使用selenium
- Python + Selenium环境搭建
- iOS7.0之后tableview的cell分割线不靠边问题
- 自己写的一种字符串搜索
- Git操作——分支管理(一)
- 使用Builder模式进行美化代码
- 用分治法查找数组元素的最大值和最小值
- python selenium
- QT小结
- 程序员怎样迈出从5K到1W的重要一步
- Error:Execution failed for task ':app:dexDebug'.
- POJ1012 Joseph
- Cocos2d-x 中Android.mk自动生成.cpp与.c类路径
- Servlet方法对象总结
- 在Android中使用SharedPreferences保存简单的数据
- 在一台电脑上开启多个tomcat