selenium安装环境
前面说过,selenium支持多种浏览器,所以只需要下载对应的浏览器驱动,将解压得到的exe文件放到python的安装目录下即可;
各个浏览器驱动下载地址(较慢不推荐):http://www.seleniumhq.org/download/
驱动下载地址:
Chrome驱动器下载: https://sites.google.com/a/chromium.org/chromedriver/downloads
放到chrome的安装目录下...\Google\Chrome\Application\ ,然后设置path环境变量
Edge驱动器下载: https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
Firefox驱动器下载: https://github.com/mozilla/geckodriver/releases
放到chrome的安装目录下Firefox所在的安装路径,我的是"E:\Mozilla Firefox\",设置path环境变量
Path:E:\Mozilla Firefox\;
Safari: https://webkit.org/blog/6900/webdriver-support-in-safari-10/
ie驱动器下载:http://www.pc6.com/softview/SoftView_435420.html
验证selenium
1.确保电脑上安装了Firefox浏览器
2.cmd窗口输入如下指令
python
from selenium import webdriver
webdriver.Firefox()
webdriver.Chrome()
webdriver.Ie()
3.如果能启动浏览器,说明环境安装OK。
注意:若用Firefox浏览器,只能用46及46以下的版本(selenium2不兼容47以上)
selenium IDE安装
http://blog.csdn.net/echizen_520/article/details/65444396
配置驱动环境变量(path)
查看驱动浏览器实例:
#coding=utf-8
from selenium import webdriver
import unittest
class VisitGGByIE(unittest.TestCase):
def setUp(self):# unittest包的方法前面小写+后面单词Up首字母大写
#启动ie浏览器
self.driver=webdriver.Ie(executable_path="D:\\Python27\\chromedriver")#注意后面不加.exe
def test_visitGG(self):
#访问搜索首页
self.driver.get("https://97gg.net")
#打印当前网页的网址
print self.driver.current_url
#退出ie浏览器
def tearDown(self):
self.driver.quit()
#pass
if __name__=="__main__":
unittest.main()
selenium IDE安装
http://blog.csdn.net/echizen_520/article/details/65444396
最新文章
- UITextField 的重写
- C#基础02
- java一点小的知识点
- 加州大学伯克利分校Stat2.2x Probability 概率初步学习笔记: Midterm
- android 项目学习随笔四(优化ViewPager)
- Proxmox虚拟机增加硬盘容量
- python迭代器生成器(二)
- 反转字符串的几种实现(Java)
- 【构造】Bzoj1432[ZJOI2009]Function
- COSC2309/2347 Semester 1, 2019
- 快乐的Lambda表达式(二)
- python 新式类的 __getattribute__
- GCC 符号表小结【转】
- centos 7 下多网卡绑定+ vlan 网卡配置
- MVC 5使用ViewData(模型)显示数据
- Apache Rewrite规则详解
- 接口测试中抓包工具Charles的使用
- Python的函数名作为参数传入调用以及map、reduce、filter
- python库安装如:requests,selenium等
- 深圳Uber优步司机奖励政策(12月28日到1月3日)
热门文章
- Magento开发基础知识之RequireJs
- Ubantu问题记录
- Python常用库整理
- C++中如何实现split的效果?
- 编写python爬虫采集彩票网站数据,将数据写入mongodb数据库
- Unicode字符集,utf8编码,base64编码简单了解
- App原生、混合、纯WEB开发模式的优劣分析
- 2019长安大学ACM校赛网络同步赛 J	Binary Number(组合数学+贪心)
- react-native启动时红屏报错:Unable to load script.Make sure you're either running a metro server or that ....
- git每次更新都需要输入账号密码,如何解决?