-1

I have downloaded all the necessary jar files from here

I am unable to import and start a new instance of Firefox driver even though I am able too see that the jar(client-combined-3.4.0-nodeps.jar) have FirefoxDriver class as well.

Line import org.openqa.selenium.firefox.FirefoxDriver is giving compilation error. Unable to resolve error.

Complete code:

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

public class FirstTestCase {

    public static void main(String[] args) {
        System.setProperty("webdriver.gecko.driver", "D:\\\\ToolsQA\\trunk\\Library\\drivers\\geckodriver.exe");


        //This line is giving the error. I can see FirfoxDriver class inside Jar.

        WebDriver driver = new FirefoxDriver();

        //Launch the Online Store Website
        driver.get("http://www.store.demoqa.com");

        // Print a Log In message to the screen
        System.out.println("Successfully opened the website www.Store.Demoqa.com");

        //Wait for 5 Sec
        Thread.sleep(5);

        // Close the driver
        driver.quit();
    }
}

wondering why this error is coming

shantanu
  • 1,748
  • 3
  • 19
  • 34

2 Answers2

0

What IDE do you use?

I tried with Eclipse by manually importing the jar (Project > Properties > Java Build Path > Libraries > Add External JARS...) or through a Maven dependency. Both worked.

Seems that your project is corrupted. Try cleaning/refreshing it.

If using Maven, sometimes, when downloading dependencies, they are stored corrupted. Try erasing the directory org.seleniumhq into your local Maven repository to force Maven to download it again. Please, refer to this post about details.

And finally, try to download the ZIP again and re-importing it again.

Community
  • 1
  • 1
Bob Rivers
  • 5,261
  • 6
  • 47
  • 59
  • I am doing it Manually in Eclipse on Windows 10. Going to try using Maven as well. – shantanu Apr 27 '17 at 01:35
  • @BobRivers doesn't `mvn clean` flushes out all the previous dependencies clean? – undetected Selenium Apr 27 '17 at 05:43
  • @Dev No. It will clean the generated files inside targer directory. Dependencies are managed by 'install' goal. This post (http://stackoverflow.com/questions/7959499/force-re-download-of-release-dependency-using-maven) has great tips about how troubleshoot it. – Bob Rivers Apr 27 '17 at 12:24
0

It was problem with eclipse Version. I was using eclipse helios. I replaced it with Neon and it started working fine.

shantanu
  • 1,748
  • 3
  • 19
  • 34