一、最近要用到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)