Selenium安装

一、最近要用到selenium来搞自动化测试,小白一枚,简单总结了自己安装的流程
二、安装Selenium(前提是已安装python、pip)
1、使用pip安装:python -m pip install selenium
备注:这样可以直接安装到python下面
2、下载selenium包安装
通过下载包安装或者直接下载selenium包:https://pypi.python.org/pypi/selenium,解压,cmd进入目 录:C:\selenium\selenium2.53.5> python3 setup.py install
三、 下载chromedriver.exe 地址 http://chromedriver.storage.googleapis.com/index.html?path=2.27/
此步需要提前查看google的版本信息,然后进到上面的地址找到对应的chromedriver.exe(如果没有自己google的版本,可以选择接近的)
1、解压下载的chromedriver.exe压缩文件,将chromedriver.exe放到google安装目录或者python的安装目录
a、放到google安装目录:C:\Program Files (x86)\Google\Chrome\Application(本人自己的),然后将C:\Program Files (x86)\Google\Chrome\Application放到环境变量PATH中
b、放到python下面(推荐此方法):D:\Python27\Lib\site-packages\selenium\webdriver\chrome,然后将D:\Python27\Lib\site-packages\selenium\webdriver\chrome放到PATH中
四、验证 脚本demo_selenium.py

from selenium import webdriver

chrome_driver = r"C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe"
#chrome_driver = r"D:\Python27\Lib\site-packages\selenium\webdriver\chrome\chromedriver.exe"

browser = webdriver.Chrome(executable_path=chrome_driver)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值