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. 1 Web 知识基础

    一.什么是跨域访问举个栗子:在A网站中,我们希望使用Ajax来获得B网站中的特定内容.如果A网站与B网站不在同一个域中,那么就出现了跨域访问问题.你可以理解为两个域名之间不能跨过域名来发送请求或者请求 ...

  2. C语言比较好的风格梳理

    errno int err; tb = malloc(sizeof(struct xtracer_table)); if (!tb) { err = errno; fprintf(stderr, &q ...

  3. sysbench_memory

    对于内存而言,这里--memory-total-size=100G 就是 意味着 total number of events: 104857600 1. --memory-total-size=10 ...

  4. uva 202(Repeating Decimals UVA - 202)

    题目大意 计算循环小数的位数,并且按照格式输出 怎么做 一句话攻略算法核心在于a=a%b*10,用第一个数组记录被除数然后用第二个数组来记录a/b的位数.然后用第三个数组记录每一个被除数出现的位置好去 ...

  5. 原来PHP对象比数组用更少的内存

    一直以为php的数组更节省内存,从来没有测试过,今天因为要读取一个大配置文件作为pool.做了一次测试: 得出结论是 使用对象保存数据更好,花费的内存是数组array的1/4. 测试代码 class ...

  6. scp相关命令总结

    scp 跨机远程拷贝scp是secure copy的简写,用于在Linux下进行远程拷贝文件的命令,和它类似的命令有cp,不过cp只是在本机进行拷贝不能跨服务器,而且scp传输是加密的.当你服务器硬盘 ...

  7. qwb与整数对

    qwb与整数对 Time Limit: 1 Sec  Memory Limit: 128 MB Description qwb又遇到了一道数学难题,你能帮助他吗? 给出两个整数n和m,请统计满足0&l ...

  8. noip模拟赛 黑骑士

    题目描述江爷爷给你出了一道题:给你一个图,保证每个点最多属于一个简单环,每个点度数最多为3,求这个图有多少“眼镜图形个数”保证图联通哦~其中“眼镜图形个数”,定义为三元组(x,y,S),其中x和y表示 ...

  9. Spring Boot访问mysql(JPA方式)最简单配置

    0.先推荐一个工具--lombok,pom文件如下: <dependency> <groupId>org.projectlombok</groupId> <a ...

  10. python 类中的方法

    首先,方法是类内部定义的函数,所以方法是类的属性而不是实例的属性. 其次,方法只能在所属的类拥有实例的时候才能被调用.当存在一个实例的时候,我们可以说方法被绑定到实例.如果没有实例,那么我们就说方法是 ...