Python3.6+selenium3.8+Firefox5.7 环境搭建

  大家好,我是阿哲,本人是从php转岗过来学习测试的一名小菜!

  在学习selenium过程中,发现运行selenium有很多的问题。

  我们在利用pip install selenium 安装的最新版后,默认是不支持最新版本的Firefox浏览器。

  报错提示:

selenium.common.exceptions.WebDriverException: Message: Unable to find a matching set of capabilities

  这时,需要我们去selenium官网下载一个驱动文件,由于官网经常打不开,这边直接提供github的下载地址

     1.chromedriver 下载地址:https://code.google.com/p/chromedriver/downloads/list
     2.Firefox的驱动geckodriver 下载地址:https://github.com/mozilla/geckodriver/releases/
     3.IE的驱动IEdriver 下载地址:http://www.nuget.org/packages/Selenium.WebDriver.IEDriver/


  大家可以根据自己电脑所使用的浏览器下载对应的驱动文件,解压后移到Python安装目录下。

  这时,我们再去IDLE中写入我们的测试代码

from selenium import webdriver     #导入webdriver包
driver =webdriver.Firefox()
driver.get('http://www.baidu.com')

  如果,浏览器自动弹起并且打开了百度,就表明 环境我们已经正常安装。

  由于谷歌浏览器的话会有一个提示,那么在这里建议大家使用Firefox浏览器。

  之后,大家就可以开始任意的使用selenium带给你各种操作浏览器的快感了!

原文地址:https://www.cnblogs.com/testzhe/p/7999213.html