Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: VISTA Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:14.666Z'

解决方法:

package my_automation;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver; public class open_browser_01 { public static void main(String[] args) throws InterruptedException {
// E:\Program Files (x86)\Mozilla Firefox
//System.setProperty("webdriver.gecko.driver", "E:\\webdriver\\geckodriver.exe");
System.setProperty("webdriver.firefox.bin", "E:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");
WebDriver driver = new FirefoxDriver();
driver.get("https://www.baidu.com");
driver.manage().window().maximize();
Thread.sleep(5000);
driver.quit(); } }
FirefoxDriver调用firefox浏览器的安装路径应为C盘的默认目录下,若firefox安装在其他目录下执行时会报错: 
Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: XP 
Build info: version: '2.25.0', revision: '17482', time: '2012-07-18 21:09:54' 
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_10' 
这是因为找不到firefox的原因。 
解决办法: 
1.重新安装firefox在默认路径下;

OS Expected Location of Firefox
Linux firefox (found using "which")
Mac /Applications/Firefox.app/Contents/MacOS/firefox
Windows %PROGRAMFILES%\Mozilla Firefox\firefox.exe

2.直接用System.setProperty方法设置webdriver.firefox.bin的值

  1. package selenium.test.googleSearch;
  2. import org.openqa.selenium.WebDriver;
  3. import org.openqa.selenium.firefox.*;
  4. public class BaiduFirefoxDriver {
  5. /**
  6. * @param args
  7. */
  8. public static void main(String[] args) {
  9. // TODO Auto-generated method stub
  10. System.setProperty("webdriver.firefox.bin", "D:\\Program Files\\Mozilla Firefox\\firefox.exe");
  11. WebDriver driver=new FirefoxDriver();
  12. driver.get("http://www.baidu.com/");
  13. }
  14. }

3.利用setCapability进行设置

  1. package selenium.test.googleSearch;
  2. import org.openqa.selenium.WebDriver;
  3. import org.openqa.selenium.firefox.*;
  4. import org.openqa.selenium.remote.DesiredCapabilities;
  5. public class BaiduFirefoxDriver {
  6. /**
  7. * @param args
  8. */
  9. public static void main(String[] args) {
  10. // TODO Auto-generated method stub
  11. DesiredCapabilities capability=DesiredCapabilities.firefox();
  12. capability.setCapability("firefox_binary",
  13. "D:\\Program Files\\Mozilla Firefox\\firefox.exe");
  14. WebDriver driver = new FirefoxDriver(capability);
  15. driver.get("http://www.baidu.com/");
  16. }
  17. }

4.用FirefoxBinary类和public FirefoxDriver(FirefoxBinary binary, FirefoxProfile profile)这个构造方法

  1. package selenium.test.googleSearch;
  2. import java.io.File;
  3. import org.openqa.selenium.WebDriver;
  4. import org.openqa.selenium.firefox.*;
  5. public class BaiduFirefoxDriver {
  6. /**
  7. * @param args
  8. */
  9. public static void main(String[] args) {
  10. // TODO Auto-generated method stub
  11. File pathToFirefoxBinary = new File("D:\\Program Files\\Mozilla Firefox\\firefox.exe");
  12. FirefoxBinary firefoxbin = new FirefoxBinary(pathToFirefoxBinary);
  13. WebDriver driver = new FirefoxDriver(firefoxbin,null);
  14. driver.get("http://www.baidu.com/");
  15. }
  16. }
 
 

java selenium启动火狐浏览器报错:Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: VISTA Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:14.666Z的更多相关文章

  1. 解决selenium 启动ie浏览器报错:Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones

    启动ie代码: System.setProperty("webdriver.ie.driver", "bin/IEDriverServer.exe"); Web ...

  2. selenium启动IE浏览器报错:Unexpected error launching Internet Explorer. Browser zoom level was set to

    解决此问题的方法就是查看自己的浏览器是否没有放大至100%,如下 如果不是100%就会报错

  3. selenium启动IE浏览器报错:selenium.common.exceptions.WebDriverException: Message: Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones. Enable Protected Mode mu

    意思是浏览器的保护模式设置不一致所导致 解决方案-->修改IE设置 将所有区域的保护模式勾选去掉即可

  4. webdriver驱动火狐浏览器报错:Unable to find a matching set of capabilities

    raise exception_class(message, screen, stacktrace)selenium.common.exceptions.SessionNotCreatedExcept ...

  5. 使用selenium启动火狐浏览器,解决Unable to create new remote session问题

    今天用火狐浏览器来做自动化,才启动就报错,提示不能创建新的session,不能启动浏览器 问题原因: 火狐driver与火狐浏览器与selenium版本的不兼容 我使用的火狐driver是0.21.0 ...

  6. 火狐浏览器报错“support.mozilla.org

    火狐浏览器有时候再打开新网页会报此错“support.mozilla.org 有时候火狐浏览器会出现如下状况 解决方法 在地址栏键入”about:config” 点击“我了解此风险” 在下方任意位置右 ...

  7. [转]bootstrap-datetimepicker 火狐浏览器报错

    本文转自:https://segmentfault.com/a/1190000008457568 使用bootstrap-datetimepicker日期选择插件时发现在火狐浏览器下报错: 未压缩版报 ...

  8. 安装火狐浏览器报错找不到VCRUNTIME140_1.DLL

    产生原因参考及下载地址:https://cn.dll-files.com/vcruntime140_1.dll.html vcruntime140_1.dll 相关的错误可能源于多种不同原因.比如,错 ...

  9. vue ui 启动,浏览器报错Unexpected token <

    可能的解决办法: 选择清空缓存并硬性重新加载页面. 如果不行,全局卸载@vue/cli,重新安装.

随机推荐

  1. EF入门

    1.(安装EF)右键项目

  2. Free中的buffer和cache理解

    吐血推荐文章: Linux内存中的Cache真的能被回收么? free中的buffer和cache: redhat对free输出的解读 两者都是RAM中的数据.简单来说,buffer是即将要被写入磁盘 ...

  3. 1040 有几个PAT (25 分)

    题目链接:1040 有几个PAT (25 分) 做这道题目,遇到了新的困难.解决之后有了新的收获,甚是欣喜! 刚开始我用三个vector数组存储P A T三个字符出现的位置,然后三层for循环,根据字 ...

  4. HDU114 - Piggy-Bank 【完全背包】

    在 ACM 能够开展之前,必须准备预算,并获得必要的财力支持.该活动的主要收入来自于 Irreversibly Bound Money (IBM).思路很简单.任何时候,某位 ACM 会员有少量的钱时 ...

  5. 取代PHP原生函数的一些扩展包

    前言 虽然程序员无时无刻都在造轮子,但造轮子也有效率之分,用好轮子才能造出好"

  6. 使用androidstudio 分析内存泄漏

    分析内存泄漏 http://www.jianshu.com/p/c49f778e7acf

  7. 【无限滚动加载数据】—infinite-scroll插件的使用

    网上对于infinite-scroll插件使用的例子不多.但由于它的出现,鼓吹了瀑布流形式的页面展示方式,所以不得不了解了解这种新的分页方式. 官网上有对infinite-scroll的详细描述,但一 ...

  8. Spring Boot开发HTTPS协议的REST接口

    Spring Boot开发HTTP的REST接口流程在前文中已经描述过,见<SpringBoot开发REST接口>. 如需要支持HTTPS,只需要在如上基础上进行设置.修改/resourc ...

  9. POJ 3252 Round Numbers 组合数学

    Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 13381   Accepted: 5208 Description The ...

  10. 不修改代码就能优化ASP.NET网站性能的一些方法 [转]

    不修改代码就能优化ASP.NET网站性能的一些方法 阅读目录 开始 配置OutputCache 启用内容过期 解决资源文件升级问题 启用压缩 删除无用的HttpModule 其它优化选项 本文将介绍一 ...