zoukankan      html  css  js  c++  java
  • selenium3.0.1调用firefox

    报错信息如下时:

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

    这是因为在Firefox高版本需要使用 geckodriver 来驱动,不再使用Seleniu默认自带的Firefox webdriver。

    我们只需要在下面这个地址下载 geckodriver 并将 其所在的路径设为环境变量即可解决。

    https://github.com/mozilla/geckodriver/releases

    当报如下错误信息时,则是

    selenium.common.exceptions.WebDriverException: Message: Expected browser binary location, but unable to find binary in default location,
    no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line

    这时我们需要指定Firefox浏览器程序路径。

    binary = FirefoxBinary('D:\Firefox\Firefox\firefox.exe')
    driver = webdriver.Firefox(firefox_binary=binary)

    注:提示找不到"firefoxBinary"可以通过下面语句导入    from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

    这样就能正常使用了。

    另一个处理办法是将firefox的安装路径,直接增加到 python35Libsite-packagesseleniumwebdriverfirefox 目录下的 firefox_binary.py文件中,如下图所示,然后driver = webdriver.Firefox()调用

  • 相关阅读:
    论语言思维的差异
    lua经典问题
    跳槽的故事
    未来一年计划
    腾讯面试题 找重复的数
    nodejs学习
    node记录
    mysql 常用总结
    ubuntu 服务器搭建汇总
    ubuntu下安装golang
  • 原文地址:https://www.cnblogs.com/wangyuqin/p/6099177.html
Copyright © 2011-2022 走看看