码迷,mamicode.com
首页 > Web开发 > 详细

配置webdriver环境

时间:2016-11-18 22:47:03      阅读:2186      评论:0      收藏:0      [点我收藏+]

标签:plugin   nbsp   not   quit   contain   require   find   matching   containe   

安装环境pip install selenium,提示 

Could not find a version that satisfies the requirement selenium (from versions: )

No matching distribution found for selenium,可把我担心了,百度了下没看到什么好的,再次去执行,就正常安装了,然而,安装的是3.0.1,当时没注意,

开始尝试

>>> from selenium import webdriver

>>> dr=webdriver.Firefox()

结果提示

selenium.common.exceptions.WebDriverException: Message: ‘geckodriver‘ executable needs to be in PATH.

就继续百度,说这是selenium3需要额外驱动geckodriver,然后添加到环境变量。作为小白,看着资源都是2的,就降版本了(执行pip install selenium==2.53.0)。

if you specified a log_file in the FirefoxBinary constructor,check it for detail

搜了下,原因是selenium版本和Firefox版本不兼容,然后去装了官网45的Firefox,运行上面两个代码是正常的,

#-*- coding:utf-8 -*-

from selenium import webdriver

driver=webdriver.Firefox()

driver.get("https://www.baidu.com")

driver.find_element_by_id("kw").send_keys("Selenium")

driver.find_element_by_id("su").click()

driver.quit()

写到.py运行就提示plugin container for firefox

百度了下是插件问题,找了几个方法,免沙箱版flash的dll,试了下不行,就去找其他版本浏览器了,找到一个46.0的,用了,很好,新的开始啊。

总之最直接的就是换低版本适合的浏览器

配置webdriver环境

标签:plugin   nbsp   not   quit   contain   require   find   matching   containe   

原文地址:http://www.cnblogs.com/wenermao/p/6078999.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!