Issue
I'm trying to launch the Firefox browser from Eclipse using Selenium as I'm learning Selenium.
My tutor wrote the below code but when I'm trying the same code I get this exception-
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
Link1. The latest version can be downloaded from
Code:
package appselenium1;
import org.openqa.selenium.firefox.FirefoxDriver;
public class A {
public static void main(String[] args) {
FirefoxDriver driver = new FirefoxDriver();
driver.get("http://www.gmail.com");
}
}
Solution
You are facing this exception, because you have not used gecko driver , which is required for launching and sending command in selenium.
You can download the latest version of gecko version from here
Try this :
package appselenium1;
import org.openqa.selenium.firefox.FirefoxDriver;
public class A {
static WebDriver driver ;
public static void main(String[] args) {
System.setProperty("webdriver.gecko.driver", "C:\\Downloads\\geckodriver-v0.20.1-win64\\geckodriver.exe");
driver = new FirefoxDriver();
driver.get("http://www.gmail.com");
}
}
Answered By - cruisepandey
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.