java 需要帮助解决 webdriver 中的问题(在 PATH 中找不到 firefox 二进制文件。确保安装了 firefox。)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39875072/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Need help to resolve issue in webdriver(Cannot find firefox binary in PATH. Make sure firefox is installed.)
提问by Loga
Below is my code. I am using FF version 49.0.1 and am using selenium server 3.0 beta version .Have added geckodriver.exe in my code using system.setProperty. Also i have my FF.exe in my system PATH variable too. Even though i am getting below error . Anyone help to resolve this
下面是我的代码。我使用的是 FF 版本 49.0.1,并且使用的是 selenium 服务器 3.0 测试版。使用 system.setProperty 在我的代码中添加了 geckodriver.exe。我的系统 PATH 变量中也有我的 FF.exe。即使我低于错误。任何人都可以帮助解决这个问题
Exception in thread "main" org.openqa.selenium.WebDriverException: Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: VISTA Build info: version: 'unknown', revision: 'c7b525d', time: '2016-09-01 14:52:30 -0700' os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_77' Driver info: driver.version: FirefoxDriver at org.openqa.selenium.firefox.internal.Executable.(Executable.java:75) at org.openqa.selenium.firefox.FirefoxBinary.(FirefoxBinary.java:60) at org.openqa.selenium.firefox.FirefoxBinary.(FirefoxBinary.java:56) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:123) at Learning.Day1.main(Day1.java:13)
线程“main”org.openqa.selenium.WebDriverException 中的异常:在 PATH 中找不到 firefox 二进制文件。确保安装了火狐。操作系统似乎是:VISTA 构建信息:版本:'未知',修订:'c7b525d',时间:'2016-09-01 14:52:30 -0700' os.name:'Windows 7',os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_77' 驱动程序信息:driver.version: FirefoxDriver at org.openqa.selenium.firefox.internal.Executable.(Executable.java:75) at org.openqa.selenium.firefox.FirefoxBinary.(FirefoxBinary.java:60) 在 org.openqa.selenium.firefox.FirefoxBinary.(FirefoxBinary.java:56) 在 org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java :123) 在 Learning.Day1.main(Day1.java:13)
package Learning;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Day1 {
public static void main(String[] args)
{
System.setProperty("webdriver.gecko.driver","PATH OF geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.get("URL ");
if(driver.getTitle().equals(" Home Page "))
{
System.out.print("Welcome to page");
}
else
{
System.out.println("We are not in required page");
}
driver.findElement(By.name("uid")).sendKeys("username");
driver.findElement(By.name("password")).sendKeys("pwd");
driver.findElement(By.name("btnLogin")).click();
}
}
回答by Vikrantsinh Karande
Type this:
输入:
"System.setProperty("webdriver.firefox.bin", "C:\Program Files\Mozilla Firefox\firefox.exe");"
before your set property for Gecko driver.
在您为 Gecko 驱动程序设置属性之前。
This issue is for some systems who cannot find the path for the installed Firefox.
此问题适用于某些找不到已安装 Firefox 路径的系统。
回答by XorX
Take a look at this post:
看看这个帖子:
https://stackoverflow.com/a/23910165/5729951
https://stackoverflow.com/a/23910165/5729951
It seems that your firefox installation dir isn't the typical one. You have to tell selenium where the firefox binary file is.
看来您的 firefox 安装目录不是典型的安装目录。你必须告诉 selenium firefox 二进制文件在哪里。