Rakesh
Rakesh

Reputation: 171

"The import org cannot be resolved" error with the imports in Eclipse Photon with selenium Standalone server 3.9.1

I'm creating a basic selenium Webdriver program by adding the selenium jars and relative jars, below is my code. but when i try to resolve firefordriver and webdriver for importing them. im getting "The import org cannot be resolved" error.

Environment details:

JavaSe-10.

Eclipse Version Photon Release (4.8.0) Build id: 20180619-1200

Selenium StandAlone server 3.9.1

Code:

package selenium;

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

public class WebDriverBasics {

    public static void main(String[] args) {

        //1. Firefox browser. 
        //geckodriver.
        System.setProperty("webdriver.gecko.driver","d:\\installations\\eclipse\\jars\\geckodriver.exe");
        WebDriver driver = new FirefoxDriver();
    }
}

Upvotes: 4

Views: 11207

Answers (6)

Rahul Khatoliya
Rahul Khatoliya

Reputation: 125

For me, the jar files responsible for spring framework were not their in the JRE, so i downloaded the respective jars and added in the build path.

below is the link which i followed and it worked for me.

Remember to see the section : "2) Add spring jar files" from the below link:

refer this link

Upvotes: 1

Ramesh Korla
Ramesh Korla

Reputation: 64

You have to remove the module-info.java class from project it will works. Module info is not required for selenium project. So you can remove it :)

Upvotes: -2

prashant.kr.mod
prashant.kr.mod

Reputation: 1702

delete module-info.java file or any other module file that was created at the time of creating the project. That will resolve the issue.

module-info.java

error resolved

Upvotes: 6

undetected Selenium
undetected Selenium

Reputation: 193228

This error message...

The import org cannot be resolved

...implies that your program was unable to resolve the following imports:

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

Your main issue for the imports not getting reslved is circular-dependency.

Though you have added all the selenium jars and relative jars but you have named the program Module / Package as selenium as follows:

package selenium;

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

This is causing a circular-dependency hence the imports are not getting resolved through the selenium related jars.

Solution

Changing/Modifying the Module / Package name from selenium to something else, e.g. myProgram will solve the issue.

Upvotes: 0

iamsankalp89
iamsankalp89

Reputation: 4739

Add jars like this

Right click on project --> Configure BuildPath --> Java Build Path Libraries -->

Double click on JRE SYSTEM LIBRARY --> Then select alternate JRE

From C:\Program Files (x86)\Java\jre7\lib your path where you store JRE

Refer this answer

Upvotes: 0

Abhishek_Mishra
Abhishek_Mishra

Reputation: 4621

Add selenium jars and other required jars to build path of your project in Eclipse and Rebuild the project.

Upvotes: 0

Related Questions