Reputation: 171
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
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:
Upvotes: 1
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
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.
Upvotes: 6
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.
Changing/Modifying the Module / Package name from selenium
to something else, e.g. myProgram
will solve the issue.
Upvotes: 0
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
Reputation: 4621
Add selenium jars and other required jars to build path of your project in Eclipse and Rebuild the project.
Upvotes: 0