selenium webdriver python 操作IE浏览器
2015-12-07 11:25
691 查看
Step1:下载IEDriverServer
下载路径:http://selenium-release.storage.googleapis.com/index.html我下载的是2.48版本的IEDriverServer_Win32_2.48.0.zip ,解压之后得到IEDriverServer.exe 。打开2.48,可以看到两个IEDriverServer:
32bit: IEDriverServer_Win32_2.48.0.zip
64bit: IEDriverServer_x64_2.48.0.zip
选择一个合适的下载即可。
Step2: 放置IEDriverServer
在跟项目包平行的地方新建一个包,比如”lib",然后将 IEDriverServer.exe拷贝到lib下。Step3: 更改保护模式
Win+R打开“运行”,输入“regedit.exe",打开注册表找到HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones
可以看到5个文件夹,分别为: 0 1 2 3 4 。
在1-4号Key下面都有名叫2500的属性,则将其值改为相同的非零值。一般情况下,系统上默认的是1,2号key 2500属性值为3,3,4号key 2500属性为0,将3,4号key的值该成3就可以。
Step4: 添加 webdriver.ie.driver 属性设置
#encoding:utf-8from selenium import webdriver
import time
driver=webdriver.Ie(executable_path="./../lib/IEDriverServer.exe")
driver.get("http://www.baidu.com")
time.sleep(3)
print driver.title
assert "百度一下" in driver.title
elem=driver.find_element_by_id("kw")
elem.send_keys("selenium")
driver.find_element_by_id("su").click()
time.sleep(3)
print driver.title
assert "selenium" in driver.title
driver.close()
Step5: 运行
结果: 运行通过百度一下,你就知道
selenium_百度搜索
相关文章推荐
- Python语言assert用法
- Python的数据类型 字符串和编码
- selenium webdriver python 操作Chrome浏览器
- numpy数组 ndarray对象基本知识
- python之Lambda函数---笔记
- python --闭包
- 两个实用的Python的装饰器
- python pandas 自动填充,重新采样 resample
- Python关键字yield的解释
- python --对象的属性
- Python发送邮件
- python 利用time模块获取当前 日期时间
- python --上下文管理器
- python
- Python进阶09 动态类型
- Python进阶08 异常处理
- Python进阶07 函数对象
- Python进阶06 循环对象与迭代
- [python爬虫] 爬取图片无法打开或已损坏的简单探讨
- python找出列表重复值