如何在Linux中的硒中设置Firefox的Firefox Firefox二进制路径? [英] How to set Firefox Binary path of firefox in selenium in Linux?
本文介绍了如何在Linux中的硒中设置Firefox的Firefox Firefox二进制路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Exception in thread "main" org.openqa.selenium.WebDriverException: Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: LINUX Build info: version: 'unknown', revision: '1969d75', time: '2016-10-18 09:43:45 -0700'
System info: host: 'skalia', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.19.0-25-generic', java.version: '1.8.0_111'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.firefox.internal.Executable.<init>(Executable.java:75)
at org.openqa.selenium.firefox.FirefoxBinary.<init>(FirefoxBinary.java:60)
at org.openqa.selenium.firefox.FirefoxBinary.<init>(FirefoxBinary.java:56)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:127)
at pack.SeleTest.main(SeleTest.java:10)
这是我在运行Selenium脚本期间在Windows PC上正常运行时遇到的错误.我设置了所有的构建路径.添加所有硒罐. 帮我解决.
This is the error i get during running selenium script which is working Fine on Window PC. I set all the Build path. Add all selenium jars. Help me to solve it.
推荐答案
IN JAVA语言:
IN JAVA Language:
如果您将firefox安装在默认位置,则只需编写:
If you install firefox in default location you just write:
WebDriver driver = new FirefoxDriver();
对于其他位置,您可以像下面这样编码:
For other location you can coding like below:
File browserAppPath = null;
if (Platform.getCurrent().is(Platform.WINDOWS)) {
browserAppPath = new File("C:\\Program Files\\Mozilla Firefox\\firefox.exe");
if (!browserAppPath.exists()) {
browserAppPath = new File("C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");
}
} else {
// Ubuntu
browserAppPath = new File("/usr/bin/firefox/firefox-bin");
}
WebDriver driver = new FirefoxDriver( new FirefoxBinary(browserAppPath), new FirefoxProfile());
这篇关于如何在Linux中的硒中设置Firefox的Firefox Firefox二进制路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文