I'm using Firefox 47.0 with Selenium 2.53. Recently they have been a bug between Selenium and Firefox which make code not working. One of the solution is to use the Marionnette driver.
I followed the instruction of this site to use this new driver with a RemotWebDriver but I keep having the error :
WARN - Exception: Exception in thread "main" org.openqa.selenium.WebDriverException: The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/jgraham/wires. The latest version can be downloaded from ....
The code i've tried so far is very simple :
public class Test { static WebDriver driver; static Wait<WebDriver> wait; public static void main(String[] args) throws MalformedURLException { System.setProperty("webdriver.gecko.driver", "C:\\Selenium\\geckodriver.exe"); DesiredCapabilities cap = DesiredCapabilities.firefox(); cap.setCapability("marionette", true); cap.setBrowserName("firefox"); driver = new RemoteWebDriver(new URL("http://192.168.117.135:5555/wd/hub"), cap);//true to enable the JS wait = new WebDriverWait(driver, 3000); final String url = "https://www.google.com/"; JavascriptExecutor js = (JavascriptExecutor) driver; try { driver.navigate().to(url); } finally { driver.close(); } } }
I'm sure that the path to the geckodriver.exe is right and i don't see where i did the mistake.
EDIT 1: I tried the following code :
public class Test { static WebDriver driver; static Wait<WebDriver> wait; public static void main(String[] args) throws MalformedURLException { System.setProperty("webdriver.gecko.driver", "C:\\Selenium\\geckodriver.exe"); driver = new MarionetteDriver(); wait = new WebDriverWait(driver, 3000); final String url = "https://www.google.com/"; JavascriptExecutor js = (JavascriptExecutor) driver; try { driver.navigate().to(url); } finally { driver.close(); } } }
and it's working it seems that the problem come from the RemoteWebDriver and the gecko driver, any of you have news on it ?
The path of the GeckoDriver executable file should be accessible to the FirefoxDriver, so as when the User creates an instance of the WebDriver using the FirefoxDriver, it should be able to find the path of the GeckoDriver executable file. It will lead to successful initialization.
GeckoDriver serves as a proxy between WebDriver enabled clients and the Firefox browser. In other words, GeckoDriver is a link between Selenium tests and the Firefox browser. It is a proxy for using W3C WebDriver-compatible clients that lets them interact with Gecko-based browsers.
Recently Selenium has launched Selenium 3 and if you are trying to use Firefox latest version then you have to use GeckoDriver:
System.setProperty("webdriver.gecko.driver","G:\\Selenium\\Firefox driver\\geckodriver.exe"); WebDriver driver = new FirefoxDriver();
You can check full documentation from here
I am also facing the same issue and got the resolution after a day :
The exception is coming because System needs Geckodriver to run the Selenium test case. You can try this code under the main Method in Java
System.setProperty("webdriver.gecko.driver","path of/geckodriver.exe"); DesiredCapabilities capabilities=DesiredCapabilities.firefox(); capabilities.setCapability("marionette", true); WebDriver driver = new FirefoxDriver(capabilities);
For more information You can go to this https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver link.
Please let me know if the issue doesn't get resolved.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With