-1

I am fresher in selenium and I am getting this error when I change my system. Please suggest me a solution for this. Thanks in advance.

Selenium - 3.4.0 Firebox browser - 47.0.2 Geckodriver - geckodriver-v0.16.1-win64

Exception in thread "main" java.lang.IllegalStateException: The driver executable is a directory: C:\Users\User\Downloads\geckodriver-v0.16.1-win64
    at com.google.common.base.Preconditions.checkState(Preconditions.java:518)
    at org.openqa.selenium.remote.service.DriverService.checkExecutable(DriverService.java:138)
    at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:131)
    at org.openqa.selenium.firefox.GeckoDriverService.access$100(GeckoDriverService.java:41)
    at org.openqa.selenium.firefox.GeckoDriverService$Builder.findDefaultExecutable(GeckoDriverService.java:115)
    at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:330)
    at org.openqa.selenium.firefox.FirefoxDriver.toExecutor(FirefoxDriver.java:207)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:108)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:104)
    at Facebook_listbox.main(Facebook_listbox.java:12)
Davide Patti
  • 3,391
  • 2
  • 18
  • 20
Roma Kamble
  • 11
  • 1
  • 1
  • your exception clearly says what is the issue. You have it pointed on directory, and should give the path to .exe file – mlecz Oct 11 '17 at 08:00

3 Answers3

1

You have to set the web driver. Try below:

System.setProperty("webdriver.gecko.driver", "Path to .exe");

WebDriver driver = new FirefoxDriver();

driver.get("http://seleniumhq.com");
  • See, i have already set the webdriver but still, the issue is happening. System.setProperty("webdriver.gecko.driver","C:\\Users\\User\\Downloads\\geckodriver-v0.16.1-win64"); driver = new FirefoxDriver(); vURL = "http://www.facebook.com"; driver.navigate().to(vURL); driver.findElement(By.xpath("//*[@id='day']")).sendKeys("9"); – Roma Kamble Oct 11 '17 at 08:58
  • The problem is here: "C:\\Users\\User‌​\\Downloads\\geckodr‌​iver-v0.16.1-win64". It should be: "C:\\Users\\User‌​\\Downloads\\geckodr‌​iver-v0.16.1-win64\\geckodriver.exe" – Anastasios Vlasopoulos Oct 11 '17 at 09:04
  • hi, added .exe and it works partially, it gives another error. pls help me in that. JavaScript error: undefined, line 492: Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsIPrefBranch.getCharPref] Exception in thread "main" org.openqa.selenium.WebDriverException: Failed to interpret value as array – Roma Kamble Oct 11 '17 at 09:23
  • You issue is resolved. Open another explaining your new problem with details. This cannot be solved under a comment conversation – Anastasios Vlasopoulos Oct 11 '17 at 09:48
0

You have to set the geckodriver file in the system property:

System.setProperty("webdriver.gecko.driver","path to geckodriver.exe");

Extract the file geckodriver-v0.16.1-win64.zip and set the path to the geckodriver.exe.

Davide Patti
  • 3,391
  • 2
  • 18
  • 20
  • Hi, I have extracted zip file and set the path but still issue is there. System.setProperty("webdriver.gecko.driver","C:\\Users\\User\\Downloads\\geckodriver-v0.16.1-win64"); driver = new FirefoxDriver(); vURL = "http://www.facebook.com"; driver.navigate().to(vURL); driver.findElement(By.xpath("//*[@id='day']")).sendKeys("9"); – Roma Kamble Oct 11 '17 at 09:00
  • In your System.setProperty("webdriver.gecko.driver","C:\\Users\\User‌​\\Downloads\\geckodr‌​iver-v0.16.1-win64")‌​; you set the path to the folder. Not to the geckodriver.exe – Davide Patti Oct 11 '17 at 09:02
  • like below I have updated this, it runs but again fails with a different error System.setProperty("webdriver.gecko.driver","C:\\Users\\User\\Downloads\\geckodriver-v0.16.1-win64\\geckodriver.exe"); – Roma Kamble Oct 11 '17 at 09:13
  • So this is another issue. You should open another question with this other error. – Davide Patti Oct 11 '17 at 09:14
  • @RomaKamble If this answer or any other one solved your issue, please mark it as accepted: stackoverflow.com/help/someone-answers – Davide Patti Oct 11 '17 at 09:19
0

You are not entering path for geckdriver correctly. Extract the file downloaded for geckodriver and set path up to "geckodriver.exe" in extracted folder. Refer this one.

System.setProperty("webdriver.gecko.driver","G:\\Selenium\\Firefox driver\\geckodriver.exe");//set path as per location of your geckodriver
Shoaib Akhtar
  • 1,393
  • 5
  • 17
  • 46