Error when runs the code

Hi, im new to selenium and i have rite the first code in java and when i run is is shows ‘The path to the driver executable must be set by webdriver.gecko.driver system property: ” erorr and i have followed your steps to resolve it.but still, im having errors.please help me to solve this.below attached the erro that i have after followed your steps.

 

Java version is 9 , Selenium version is 3.8.1 and the firefox version is 57

 

 

This is my code ========================================= package test; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.remote.DesiredCapabilities; public class loginNavigation { public static void main(String[] args) throws InterruptedException { DesiredCapabilities capabilities = DesiredCapabilities.firefox(); capabilities.setCapability(“marionette”, true); WebDriver driver = new FirefoxDriver(capabilities); driver.get(“http://www.toolsqa.com”); Thread.sleep(5000); driver.quit(); } } ====================================================== =============== this is the error ===== selenium.remote.DesiredCapabilities firefox INFO: Using new FirefoxOptions() is preferred to DesiredCapabilities.firefox() 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:754) at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:124) at org.openqa.selenium.firefox.GeckoDriverService.access$100(GeckoDriverService.java:41) at org.openqa.selenium.firefox.GeckoDriverService$Builder.findDefaultExecutable(GeckoDriverService.java:141) at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:339) at org.openqa.selenium.firefox.FirefoxDriver.toExecutor(FirefoxDriver.java:158) at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:120) at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:106) at test.loginNavigation.main(loginNavigation.java:16)

Default Asked on January 4, 2018 in Selenium WebDriver.
Add Comment
  • 1 Answer(s)

    download geckodriver.exe….and set the path

     

    System.setProperty(“webdriver.gecko.driver”, “path of the geckodriver.exe”);

     

    it might be  solve your issue

    Default Answered on January 6, 2018.

    Do i set the path in environmental variable ?? Once i did and compile the code again it shows error as  below  

     

    this is my path – E:\Selenium\geckodriver-v0.19.1-win64

     

    Exception in thread “main” java.lang.Error: Unresolved compilation problems: Exception in thread “main” java.lang.Error: Unresolved compilation problems:  Syntax error on token “Invalid Character”, delete this token Syntax error on tokens, delete these tokens Syntax error on token “.19”, -> expected Syntax error on token “Invalid Character”, ElidedSemicolonAndRightBrace expected at test.loginNavigation.main(loginNavigation.java:18)  

    on January 9, 2018.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.