Firefox browser is not opening with selenium webbrowser code [duplicate]

0
0

Need guidance and help in the below one.

When the below code is executed, I am getting error. I am using the latest version of java, eclipse, firefox, and WebDrive jar file.

package firsttest1;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class helloselenium {
public static void main(String[] args) {
WebDriver driver;
driver
=new FirefoxDriver();
String url ="http://www.google.com";
driver
.get(url);
}
}

error….

Exception in thread “main” java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/mozilla/geckodriver. The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases
at com.google.common.base.Preconditions.checkState(Preconditions.java:199)
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:109)
at org.openqa.selenium.firefox.GeckoDriverService.access$100(GeckoDriverService.java:38)
at org.openqa.selenium.firefox.GeckoDriverService$Builder.findDefaultExecutable(GeckoDriverService.java:91)
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:296)
at org.openqa.selenium.firefox.FirefoxDriver.createCommandExecutor(FirefoxDriver.java:245)
at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:220)
at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:215)
at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:211)
at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:124)
at firsttest1.helloselenium.main(helloselenium.java:12)

Version used:
eclipse : neon version
java : jdk1.8
fire fox: v48
WebDrive jar file : v 3.0.0 beta2

guide me in resolving this issue.

  • You must to post comments
0
0

You are using latest version of Selenium WebDriver i.e. Selenium 3.x, this version of webdriver doesn’t support direct firefox launch. You have to set the SystemProperty for webdriver.gecko.driver.

Replace the Code:-

WebDriver driver;
driver
=new FirefoxDriver();

With This code:-

WebDriver driver;
System.setProperty("webdriver.gecko.driver", "<Path to your WebDriver>");
driver
=new FirefoxDriver();

You can get the information about latest changes here

You can download the latest Gecko driver from here

  • You must to post comments
Showing 1 result
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Website