Reputation: 659
I need to run portable Firefox using RemoteWebDriver, but facing the problem:
Here is code for a local run which works perfectly:
FirefoxProfile profile = new FirefoxProfile();
WebDriver driver = new FirefoxDriver(
new FirefoxBinary(
new File(System.getProperty("user.dir"),
"/tools/FirefoxPortable/FirefoxPortable.exe")),profile);
driver.get("http://google.com");
How can I run it on local server? With something like:
WebDriver driver = new RemoteWebDriver(DesiredCapabilities.firefox());
driver.get("http://google.com");
Upvotes: 2
Views: 453
Reputation: 23805
If you are using RemoteWebDriver
, There are two ways to set firefox
binary as below :
You need to set FirefoxBinary
into DesiredCapabilities
as :
FirefoxBinary bin = new FirefoxBinary(
new File(System.getProperty("user.dir"),
"/tools/FirefoxPortable/FirefoxPortable.exe"));
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability(FirefoxDriver.BINARY, bin);
WebDriver driver = new RemoteWebDriver(capabilities);
driver.get("http://google.com");
You need to run selenium-server-standalone-x.jar
with -Dwebdriver.firefox.bin
property which will point to firefox
binary path as :
java -jar selenium-server-standalone-x.jar -Dwebdriver.firefox.bin="path/to/firefox binary"
Now you can instantiate RemoteWebDriver
with firefox
as :
WebDriver driver = new RemoteWebDriver(DesiredCapabilities.firefox());
driver.get("http://google.com");
Upvotes: 2