在Selenium Grid中我试图执行一个简单的程序,Cannot find firefox binary in PATH虽然我已经在我的代码中添加了二进制路径.
我的代码和错误如下.请帮忙.提前致谢.
码
package Sample;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.AfterTest;
public class sample1 {
WebDriver driver;
String BaseURL,NodeURL;
@BeforeTest
public void beforeTest() throws MalformedURLException {
BaseURL="www.google.com";
NodeURL="http://192.168.10.162:5566/wd/hub";
DesiredCapabilities capa =DesiredCapabilities.firefox();
capa.setBrowserName("firefox");
capa.setCapability("binary", "C:\\Users\\praveenraj.d\\AppData\\Local\\Mozilla Firefox\\firefox.exe");
capa.setPlatform(Platform.ANY);
driver=new RemoteWebDriver(new URL(NodeURL),capa);
}
@Test
public void f() throws InterruptedException {
driver.get(BaseURL);
System.out.println(driver.getTitle());
Thread.sleep(50000);
}
@AfterTest
public void afterTest() {
driver.quit();
}
}
Run Code Online (Sandbox Code Playgroud)
错误 …
我正在尝试配置代理设置,WebDriver所以我使用了以下代码....
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.proxy.type", 1);
profile.setPreference("network.proxy.http","207.229.122.162");
profile.setPreference("network.proxy.http_port", 3128);
WebDriver driver = new FirefoxDriver(profile);
selenium = new WebDriverBackedSelenium(driver, "http://www.example.com/");
Run Code Online (Sandbox Code Playgroud)
并且在对文件执行运行后,我得到例外...
org.openqa.selenium.WebDriverException:在PATH中找不到firefox二进制文件.
确保安装了firefox.操作系统似乎是:MAC
系统信息:os.name:'Mac OS X',os.arch:'x86_64',os.version:'10 .6.8',
java.version:'1.6.0_29'
驱动程序信息:driver.version:FirefoxDriver
任何人都可以帮助我解决如何以及在何处提供路径 firefoxprofile()