import org.openqa.selenium.webdriver cannot be resolved

42,612 views
Skip to first unread message

ama...@bufetedemarketing.com

unread,
May 4, 2017, 7:32:27 AM5/4/17
to Selenium Users
Hi guys!

I've tried to install Selenium Webdriver, with Java, Eclipse, but when I start to do the following code, I get the error: "import org.openqa.selenium.webdriver cannot be resolved"

I don't know how resolve it because I've followed all steps of: http://www.assertselenium.com/eclipse-2/how-to-setup-a-webdriver-project-in-eclipse/ 
To configure my Eclipse with Java...

The code: 

package newpackage;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class PG1 {


    public static void main(String[] args) {
        // declaration and instantiation of objects/variables
    WebDriver driver ;
    System.setProperty("webdriver.firefox.bin","C:\\Program Files (x86)\Mozilla Firefox");
    driver = new FirefoxDriver();
        String baseUrl = "http://newtours.demoaut.com";
        String expectedTitle = "Welcome: Mercury Tours";
        String actualTitle = "";

        // launch Fire fox and direct it to the Base URL
        driver.get(baseUrl);

        // get the actual value of the title
        actualTitle = driver.getTitle();

        /*
         * compare the actual title of the page with the expected one and print
         * the result as "Passed" or "Failed"
         */
        if (actualTitle.contentEquals(expectedTitle)){
            System.out.println("Test Passed!");
        } else {
            System.out.println("Test Failed");
        }
       
        //close Fire fox
        driver.close();
       
        // exit the program explicitly
        System.exit(0);
    }

I've proved a lot of things but I'm not able to solve it. Anyone knows?

Thanks so much!! 

Anish Pillai

unread,
May 4, 2017, 9:18:57 PM5/4/17
to Selenium Users
Hi,

The article you referred is old and the steps have changed. Better approach would be to use the latest version of Selenium and GeckoDriver if you want to run your scripts on Firefox. You can check this article which gives the setup details for the latest versions - Selenium WebDriver 3.4 Setup (specifically points 3 and 4 in the article).

Cheers, Anish
AutomationTestingHub

ama...@bufetedemarketing.com

unread,
May 5, 2017, 4:43:09 AM5/5/17
to Selenium Users
Thanks so much, I resolved with that article!!! :)

Have a nice day!

SeleniumNewbie

unread,
May 31, 2020, 7:51:29 AM5/31/20
to Selenium Users
Hi Anish,

I'm getting the same issue while using the current latest version of Eclipse v4.15.0 and Java Client & WebDriver bindings v4.0.0.-alpha-6. I've added all the files on my Java Build path under Project properties but the issue doesn't budge. Please help!! 

Regards
Selenium Newbie..

Sumit Bhatia

unread,
Jun 17, 2020, 6:57:16 AM6/17/20
to Selenium Users
@Selenium Newbie....did you find  a way out? . I am also struggling with the same issue and have tried all .

SeleniumNewbie

unread,
Jun 17, 2020, 9:41:08 AM6/17/20
to Selenium Users
Hey Sumit,

I did find the solution to this problem. Quite a silly one!

Eclipse takes up the highest JavaSE version for execution. Now Java had released JDK-13 earlier and JDK-1.8 just recently.

If you have been using all the latest software releases like me, it is highly probable your Eclipse is also picking up the incorrect version.

No worries!! Just scrap this Java project, create a new one and while setting it up select the correct JavaSE (1.8 in my case) for execution and you should be good to go. Eclipse will set this as default and use it for all your future projects.

Let me know if this worked for you too. Happy Coding!!

Sumit Bhatia

unread,
Jun 26, 2020, 12:43:03 AM6/26/20
to Selenium Users
Thanks a ton @SeleniumNewbee.This has really worked👍👍🙂. Had wasted a lot of time over this.Thanks again!
Reply all
Reply to author
Forward
0 new messages