0

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

This is my code.

package newpackage;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class MyClass {

    public static void main(String[] args) {
        //declaration and instatiation of objects/variables

        WebDriver driver = new FirefoxDriver();
        String baseUrl = "http://newtours.demoaut.com";
        String expectedTitle = "Welcome: Mercury Tours";
        String actualTitle ="";

        //launch firefox and direct it to the URL

        driver.get(baseUrl);

        //get the actual value of the title

        actualTitle = driver.getTitle();



        if (actualTitle.contentEquals(expectedTitle)){
            System.out.println("Test Passed");

        }else {
            System.out.println("Test failed");
        }


        //close firefox

        driver.close();

        //exit the program

        System.exit(0);

    }

}
Borodin
  • 126,100
  • 9
  • 70
  • 144
Aju
  • 5
  • 7
  • And when you followed its directions...? – nitind Oct 18 '16 at 17:16
  • 3
    It's important that you add appropriate tags to your questions. Most people looking for problems that they can answer will search for languages that they are familiar with, so you should include at least that as a tag. You should also read up on Stack Overflow's *markdown* formatting to make your question more readable. I've edited your question for you this time; please learn to do it for yourself. – Borodin Oct 18 '16 at 17:17
  • Possible duplicate of [Fail to Launch Mozilla with selenium](http://stackoverflow.com/questions/38676719/fail-to-launch-mozilla-with-selenium) – Saurabh Gaur Oct 18 '16 at 17:30

1 Answers1

0

For selenium 3.0 and above it is mandatory to specify gecko.driver path. Add below lines to your code before initializing driver and error will not appear.

System.setProperty("webdriver.firefox.marionette","xxx\geckodriver.exe");
//xxx - path to geckodriver.exe file
WebDriver driver = new FirefoxDriver();
Shivraj
  • 1
  • 1