【自动化测试】selenium安装环境
本来在win8.1的那台机上安装的selenium,但是那台陈年老本不堪重负,就换成x1c那台机,结果又报错了了一堆bug,quq,特此汇总一下selenium安装的注意事项:
参考文章:https://www.jianshu.com/p/3ce95cbc65be
环境搭建步骤
1.安装python
自行到python官网下载安装包,https://www.python.org/
配置好环境变量
检测是否安装好python:win+R,cmd指令,python查看
(我的python是3.6.5)
2.安装Selenium
(1)pip指令安装,打开命令行
pip install -U selenium
(2)在pycharm编译器的setting中也可以安装
3.安装浏览器驱动
下载对应版本安装到 C:\python36
Google Chrome driver:https://sites.google.com/a/chromium.org/chromedriver/downloads
Mozilla GeckoDriver:https://github.com/mozilla/geckodriver/releases
Internet Explorer Driver:http://selenium-release.storage.googleapis.com/3.13/IEDriverServer_x64_3.13.0.zip
Selenium 出现的问题以及解决
测试用例
'''WebDriver'''
from selenium import webdriver
#使用webdriver打开浏览器
#火狐
browser = webdriver.Firefox()
browser.get("http://www.baidu.com/")
1.报错内容:
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
Solution:将火狐的安装路径放到path,然后重启(必须重启电脑)
2.报错内容:
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
Geckodirver的下载地址:https://github.com/mozilla/geckodriver/releases
下载geckodriver.exe。放置在Path 环境变量可以访问到的地方。例如 C:\python36