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
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(); } }
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的值
- package selenium.test.googleSearch;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.firefox.*;
- public class BaiduFirefoxDriver {
- /**
- * @param args
- */
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- System.setProperty("webdriver.firefox.bin", "D:\\Program Files\\Mozilla Firefox\\firefox.exe");
- WebDriver driver=new FirefoxDriver();
- driver.get("http://www.baidu.com/");
- }
- }
3.利用setCapability进行设置
- package selenium.test.googleSearch;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.firefox.*;
- import org.openqa.selenium.remote.DesiredCapabilities;
- public class BaiduFirefoxDriver {
- /**
- * @param args
- */
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- DesiredCapabilities capability=DesiredCapabilities.firefox();
- capability.setCapability("firefox_binary",
- "D:\\Program Files\\Mozilla Firefox\\firefox.exe");
- WebDriver driver = new FirefoxDriver(capability);
- driver.get("http://www.baidu.com/");
- }
- }
4.用FirefoxBinary类和public FirefoxDriver(FirefoxBinary binary, FirefoxProfile profile)这个构造方法
- package selenium.test.googleSearch;
- import java.io.File;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.firefox.*;
- public class BaiduFirefoxDriver {
- /**
- * @param args
- */
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- File pathToFirefoxBinary = new File("D:\\Program Files\\Mozilla Firefox\\firefox.exe");
- FirefoxBinary firefoxbin = new FirefoxBinary(pathToFirefoxBinary);
- WebDriver driver = new FirefoxDriver(firefoxbin,null);
- driver.get("http://www.baidu.com/");
- }
- }
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的更多相关文章
- 解决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 ...
- selenium启动IE浏览器报错:Unexpected error launching Internet Explorer. Browser zoom level was set to
解决此问题的方法就是查看自己的浏览器是否没有放大至100%,如下 如果不是100%就会报错
- 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设置 将所有区域的保护模式勾选去掉即可
- webdriver驱动火狐浏览器报错:Unable to find a matching set of capabilities
raise exception_class(message, screen, stacktrace)selenium.common.exceptions.SessionNotCreatedExcept ...
- 使用selenium启动火狐浏览器,解决Unable to create new remote session问题
今天用火狐浏览器来做自动化,才启动就报错,提示不能创建新的session,不能启动浏览器 问题原因: 火狐driver与火狐浏览器与selenium版本的不兼容 我使用的火狐driver是0.21.0 ...
- 火狐浏览器报错“support.mozilla.org
火狐浏览器有时候再打开新网页会报此错“support.mozilla.org 有时候火狐浏览器会出现如下状况 解决方法 在地址栏键入”about:config” 点击“我了解此风险” 在下方任意位置右 ...
- [转]bootstrap-datetimepicker 火狐浏览器报错
本文转自:https://segmentfault.com/a/1190000008457568 使用bootstrap-datetimepicker日期选择插件时发现在火狐浏览器下报错: 未压缩版报 ...
- 安装火狐浏览器报错找不到VCRUNTIME140_1.DLL
产生原因参考及下载地址:https://cn.dll-files.com/vcruntime140_1.dll.html vcruntime140_1.dll 相关的错误可能源于多种不同原因.比如,错 ...
- vue ui 启动,浏览器报错Unexpected token <
可能的解决办法: 选择清空缓存并硬性重新加载页面. 如果不行,全局卸载@vue/cli,重新安装.
随机推荐
- 微信小程序——weui的使用
使用在根目录中复制weui.wxss,app.wxss中引入 在weui.io中查看到自己想要的样式表后,到第二个网站复制代码,复制到自己的项目中即可 <!--pages/register/re ...
- hdu 2084 数塔(简单dp)
题目 简单dp //简单的dp #include<stdio.h> #include<string.h> #include<algorithm> using nam ...
- [HDU] 4507 恨7不成妻
吉哥系列故事——恨7不成妻 Time Limit: 1000/500 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Tota ...
- 非常简单的Python HTTP服务
如果你急需一个简单的Web Server,但你又不想去下载并安装那些复杂的HTTP服务程序,比如:Apache,ISS等.那么, Python 可能帮助你.使用Python可以完成一个简单的内建 HT ...
- JPA学习(基于hibernate)
参考博客:https://blog.csdn.net/baidu_37107022/article/details/76572195 常用注解: https://blog.csdn.net/eastl ...
- 清北学堂模拟赛d3t5 c
分析:其实就是一道数学题.如果以左下角的点为原点建立平面直角坐标系,那么点(b,a)是最容易卡住棺材的.我们求出棺材左边到点(b,a)的距离最小值,只有w小于等于这个最小值才能被拉过去.那么先求出左面 ...
- hdu_1014_Uniform Generator_201310141958
Uniform Generator Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...
- uva A Spy in the Metro(洛谷 P2583 地铁间谍)
A Spy in the Metro Secret agent Maria was sent to Algorithms City to carry out an especially dangero ...
- RDS MySQL 表上 Metadata lock 的产生和处理
https://help.aliyun.com/knowledge_detail/41723.html?spm=5176.7841698.2.18.vNfPM3
- Verilog堵塞赋值与非堵塞赋值
verilog设计进阶 时间:2014年5月6日星期二 主要收获: 1.堵塞赋值与非堵塞赋值: 2.代码測试: 3.组合逻辑电路和时序逻辑电路. 堵塞赋值与非堵塞赋值: 1.堵塞赋值"=&q ...