Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error with selenium webdriver code( geckodriver)

Tags:

selenium

I am trying to run my first webdriver script in eclipse. using jre1.8.0_1111. I used the following code but it shows error.please help me with the code.

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

 public class Trial { 
    static void main(String[] args) { 
    WebDriver driver = new FirefoxDriver(); 
    String baseUrl = "google.com";    
    System.setProperty("webdriver.gecko.driver", "C:\\Users\\Naik\\Downloads\\geckodriver-v0.11.1-win64\\geck‌​odriver.exe"); 
    driver.get(baseUrl); 
   }

Error stack

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 github.com/mozilla/geckodriver. The latest version can be downloaded from github.com/mozilla/geckodriver/releases

like image 822
ayav Avatar asked Jul 02 '26 22:07

ayav


1 Answers

Download the geckodriver from the below URL and save it on your local machine.

https://github.com/mozilla/geckodriver/releases

Then set the right path where the geckodriver.exe is saved.Moreover the set property must be used before declaring the driver!

 public class Trial { 
  public static void main(String[] args) {
    String baseUrl = "google.com";
    System.setProperty("webdriver.gecko.driver", "C:\\Users\\Naik\\Downloads\\geckodriver-v0.11.1-win64\\geck‌​odriver.exe"); 
    WebDriver driver = new FirefoxDriver(); 
    driver.get(baseUrl); 
  }
like image 55
prithvi394 Avatar answered Jul 05 '26 16:07

prithvi394



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!