Hi.. I am new to Automation Testing.Please let me know what is the mistake in the code. Screenshot attached.

Answered

Hi.. I am new to Automation Testing.Please let me know what is the mistake in the code.

[/code]

package Test;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.DesiredCapabilities;

public class TestFaceBookRegistration {

public static void main(String[] args) throws InterruptedException {

System.setProperty(“webdriver.gecko.driver”, “C:\\Marionette\\geckodriver-v0.16.1-win64”);
WebDriver driver = new FirefoxDriver();
driver.get(“http://www.wikipedia.org”);
WebElement link;
link = driver.findElement(By.linkText(“English”));
((WebElement) driver).click();
Thread.sleep(5000);
WebElement searchbox;
searchbox = driver.findElement(By.id(“searchInput”));
searchbox.sendKeys(“Software”);
Thread.sleep(5000);
driver.quit();
}

}

 


Error

 

Exception in thread “main” java.lang.IllegalStateException: The driver executable is a directory: C:\Marionette\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 Test.TestFaceBookRegistration.main(TestFaceBookRegistration.java:15)

Hi.. I am new to Automation Testing.Please let me know what is the mistake in the code. Screenshot attached.Error

 

 

 

 

 

 

Default Asked on May 12, 2017 in Selenium WebDriver.
Add Comment
  • 1 Answer(s)
    Best answer

    Hi Ankur12,

    While specifying gecko driver we need to give path including name of the .exe file.

    replace below line:

    System.setProperty(“webdriver.gecko.driver”, “C:\\Marionette\\geckodriver-v0.16.1-win64”);

    with

    System.setProperty(“webdriver.gecko.driver”, “C:\\Marionette\\geckodriver-v0.16.1-win64\\geckodriver.exe”);

     

    Also there is one more mistake in code.

    replace below line:

    ((WebElement) driver).click();

    with

    link.click();

    As you need to specify the WebElement on which you need to perform click operation.

    Train Answered on May 15, 2017.
    Add Comment
  • Your Answer

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