0

So, right now I have been able to make some progress, but just one more step to go.

I got the error message below after making my changes:

Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable 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 org.openqa.selenium.internal.Require$StateChecker.nonNull(Require.java:247)

at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:142)

at org.openqa.selenium.firefox.GeckoDriverService.access$100(GeckoDriverService.java:45)

at org.openqa.selenium.firefox.GeckoDriverService$Builder.findDefaultExecutable(GeckoDriverService.java:186)

at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:405)

at org.openqa.selenium.firefox.FirefoxDriver.toExecutor(FirefoxDriver.java:206)

at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:176)

at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:154)

at com.simplilearn.day2.oops.LaunchBrowser.main(LaunchBrowser.java:16)

public class LaunchBrowser {

    public static void main(String[] args) {

        WebDriver driver = new FirefoxDriver();

        System.setProperty("webdriver.gecko.driver", "./drivers/geckoriver");

        driver.manage().window().maximize();
        driver.manage().timeouts().implicitlyWait(40,TimeUnit.SECONDS);
        driver.manage().timeouts().pageLoadTimeout(90, TimeUnit.SECONDS);
        driver.get("https://www.google.com");

    }
}
Giorgi Tsiklauri
  • 9,715
  • 8
  • 45
  • 66
oluscott
  • 19
  • 3

1 Answers1

1

You have to first set the path, then you can create a new FirefoxDriver(). So just switch these two lines, like this:

System.setProperty("webdriver.gecko.driver", "./drivers/geckoriver/geckodriver.exe");
WebDriver driver = new FirefoxDriver();

Btw it seems that you have a spelling error ("geckoriver") in your path, maybe that causes a problem too. Notice too that you should set the path to the .exe file, not just the folder where the .exe file is in.

Michael S
  • 104
  • 11
  • Thanks alot. you just made my day. it was due to the (geckoriver) spelling error. well spotted. Its working now. i can lunch the browser but i can still see some errors on my console. – oluscott Aug 21 '20 at 08:44
  • Glad to help. Please mark my answer as accepted, so others can see that your problem has been solved. :) – Michael S Aug 21 '20 at 11:29