• webdriver问题汇总


    如果你的selenium是3.X版本的火狐浏览器需要geckodriver这个组件的支持而谷歌浏览器需要chromedriver的支持,selenium是2.X版本则不需要。

    使用selenium自动打开Google浏览器错误提示:

    WebDriverException: Message: 'chromedriver' executable needs to be in PATH.
    打开火狐浏览器错误提示:
    复制代码
    C:Python36libsite-packagesseleniumwebdriverfirefoxwebdriver.py in __init__(self, firefox_profile, firefox_binary, timeout, capabilities, proxy, executable_path, firefox_options, log_path)
        140             capabilities.pop("marionette")
        141             self.service = Service(executable_path, log_path=log_path)
    --> 142             self.service.start()
        143 
        144             capabilities.update(firefox_options.to_capabilities())
    
    C:Python36libsite-packagesseleniumwebdrivercommonservice.py in start(self)
         79                 raise WebDriverException(
         80                     "'%s' executable needs to be in PATH. %s" % (
    ---> 81                         os.path.basename(self.path), self.start_error_message)
         82                 )
         83             elif err.errno == errno.EACCES:
    
    WebDriverException: Message: 'geckodriver' executable needs to be in PATH. 
    复制代码

     1、

    所以如果是使用selenium3.X版本的火狐浏览器需要网上下载geckodriver

    这给出Windows64位下载地址:https://pan.baidu.com/s/1gfP8CON

    其他系统的以及最新的geckodriver可以到:https://github.com/mozilla/geckodriver/releases下载/

    2、

    谷歌浏览器chromedriver下载地址:http://npm.taobao.org/mirrors/chromedriver/

    3、

    Windows下下载好软件直接解压然后复制geckodriver.exe(或chromedriver.exe)到任何已添加到【环境变量的文件夹】比如下图的:C:Python36 等文件夹。

    再次输入以下代码运行一下看是不是自动打开了火狐浏览器

    1
    2
    from selenium import webdriver
    browser = webdriver.Firefox()

     转自http://www.cnblogs.com/lvzuwen/

    逆风的方向更适合飞翔,不怕千万人阻挡,只怕自己投降!
  • 相关阅读:
    js原生图片拼图Demo
    display:inline-block在ie7下的解决办法
    Apollo 配置中心部署注意事项
    chrony 时间同步配置
    IPv6基础介绍
    Rabbitmq 报错 nodedown
    Maven 私服你应该不陌生吧,可你会用 Artifactory 搭建吗?
    你 MySQL 中重复数据多吗,教你一招优雅的处理掉它们!
    MySQL 数据库的基本使用
    自建 yum 源
  • 原文地址:https://www.cnblogs.com/jackzz/p/9508955.html
Copyright © 2020-2023  润新知