0
votes

I am using Selenium version 3.11, gecko driver v0.20 and Firefox version 59. I used the system.setproperty script but I'm still getting this error:

Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.gecko.driver system property

I also tried this with Firefox v40. Please help me sort out this issue. Thanks.

The syntax i used is as follows : System.setProperty("webdriver. gecko.driver","C:\geckodriver.exe");

2
Please show us how you set the path to the driver executable. - user5956451
Hi i set the path as follows: System.setProperty("webdriver. gecko.driver","C:\\geckodriver.exe"); - Rasika Sawant
See this SO answer: stackoverflow.com/a/38937934/5956451 - user5956451

2 Answers

0
votes

Try to do something like that:

public void loadSystemProperties() {
        try {
            InputStream in = getClass().getResourceAsStream("/geckodriver");
            File file = stream2file(in);
            System.setProperty("webdriver.gecko.driver", file.getAbsolutePath());
            LOGGER.info("Geckdriver found at {}", file.getAbsoluteFile());
        } catch (IOException e) {
            LOGGER.error(e.getMessage());
        }
}


static File stream2file(InputStream in) throws IOException {
        String PREFIX = "stream2file";
        String SUFFIX = ".tmp";
        final File tempFile = File.createTempFile(PREFIX, SUFFIX);
        tempFile.deleteOnExit();
        try (FileOutputStream out = new FileOutputStream(tempFile)) {
            IOUtils.copy(in, out);
        }
        tempFile.setExecutable(true);
        return tempFile;
    }

I'm using commons-io, version 2.6. In addition, my geckodriver is in my resource folder.

0
votes

Thanks for your response.My issue stands resolved after setting the geckodriver path in the environment variable settings. But can anyone help me with one question: which latest firefox version will support firebug and xpath addons?