Selenium学习(Python)
2016-05-24 22:09
585 查看
#从Selenium中导入Webdriver类,该类中定义了selenium支持的浏览器 # webdriver.Firefox # webdriver.FirefoxProfile # webdriver.Chrome # webdriver.ChromeOptions # webdriver.Ie # webdriver.Opera # webdriver.PhantomJS # webdriver.Remote # webdriver.DesiredCapabilities # webdriver.ActionChains # webdriver.TouchActions # webdriver.Proxy from selenium import webdriver #Keys类中包含键盘上所有的键的常量 from selenium.webdriver.common.keys import Keys #调用Firefox的webdriver browser = webdriver.Firefox() #访问baidu.com browser.get('http://www.baidu.com') #判断title assert '百度一下, 你就知道' in browser.title #利用find_element_by_xx获取网页页面的元素(本例是获取百度页面上的搜索框) elem = browser.find_element_by_name('wd') # Find the search box #send_keys用来进行键盘的操作,下面是在输入框中写入"seleniumhq",然后点击return,进行搜索 elem.send_keys('seleniumhq' + Keys.RETURN) #退出Firefox浏览器 browser.quit()
相关文章推荐
- python读写操作文件
- Python学习笔记(二)在线用pip下载第三方包
- Python实现各种排序算法
- Python 2.7.x 和 3.x 版本的重要区别
- python 2.7中安装mysql
- python 2.7中安装mysql
- python 2.7中安装mysql
- Python之时间处理模块time
- Python -- 文件/目录 方法
- Python爬虫实战一之爬取糗事百科段子
- Python Tricks(十四)—— list 逆序的实现
- LeetCode Min Stack
- Python 面向对象 —— 静态方法和类方法
- 从底层理解Python的执行
- 查询本地文件信息
- 计量金融与pandas玩转a股
- 3.第一个python程序
- Numpy基础
- 10款Web开发最佳的Python框架
- Python中的字符编码问题