Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
129 views
in Technique[技术] by (71.8m points)

java - Unable to instantiate FirefoxDriver class in selenium even though class is present inside JAR

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...