8

I found a similar error as mine on stackoverflow and added selenium webdriver jar files to the project using the below method :

right click on project--> goto build path--> configure build path--> click on "Add external jars"--> add selenium jar files from your local machine--> click ok--> now mouseover on WebDriver in your code--> click "import webdriver"--now run your code-->you will get rid of the exception.

However, I am still getting an error. Here's the error :

Exception in thread "main" java.lang.Error: Unresolved compilation problems: WebDriver cannot be resolved to a type FirefoxDriver cannot be resolved to a type

Gautam Savaliya
  • 1,209
  • 2
  • 17
  • 28
Juvelle Mendes
  • 113
  • 1
  • 1
  • 9

7 Answers7

3

even i got the the same error but then i realised that i missed 2 additional JAR files from Selenium 2.53.0.

selenium-java-2.53.0-srcs.jar selenium-java-2.53.0.jar

these are not in the sub library " libs" in selenium 2.53.0 but listed separately in the same folder.

ram
  • 39
  • 1
2

This error happens when you use Eclipse as IDE and try to run code that doesn't even compile. Check your Problems view in Eclipse, and fix the compilation errors before executing the application.

Anton Angelov
  • 1,687
  • 12
  • 16
  • Hi Anton, I have used the below code :package Testing_Pack; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; public class mytestclass { public static void main(String[] args) { WebDriver driver = new FirefoxDriver(); driver.get("http://only-testing-blog.blogspot.in"); String i = driver.getCurrentUrl(); System.out.println(i); driver.close(); } } – Juvelle Mendes Aug 04 '15 at 08:47
  • Are there any errors when you build the project, displayed in the output windows? – Anton Angelov Aug 04 '15 at 08:51
  • Here are the errors:Exception in thread "main" java.lang.Error: Unresolved compilation problems: FirefoxDriver cannot be resolved to a type The method get(String) is undefined for the type WebDriver The method getCurrentUrl() is undefined for the type WebDriver The method close() is undefined for the type WebDriver at Testing_Pack.mytestclass.main(mytestclass.java:9) – Juvelle Mendes Aug 04 '15 at 09:06
  • Hi Anton ,I reconfigured Eclipse with selenium 2 and its working now.Thank you for your help – Juvelle Mendes Aug 04 '15 at 10:06
  • I'm glad that I could help. Can you please mark the question as answered and vote. Thanks :) – Anton Angelov Aug 04 '15 at 10:16
  • I have similar problem. Must be following the same duff tutorial. How did you reconfigure Eclipse with Selenium 2, Juvelle? – Steve Staple Dec 11 '17 at 14:46
1

I had the same problem but then i came to know that i was missing a jar to add, this jar is not inside the lib folder you can find it immediately outside the lib folder: client-combined-3.0.1-nodeps.jar

Atul Chavan
  • 1,424
  • 14
  • 12
0

I had the problem of WebDriver cannot be resolved to a type FirefoxDriver cannot be resolved to a type.I was using Selenium -java 3.0.1 jars.Also the jars client-combined-3.0.1-nodeps are required to to added .hence problem solved.

0

WebDriver3.0 will support the latest firefox also. but you have to set the properties for that

download "geckodriver.exe" file and you can try this.

System.setProperty("webdriver.firefox.marionette",
            "E:\\SeleniumAutomation\\geckodriver-v0.9.0-win64\\geckodriver.exe");
    driver = new FirefoxDriver();
    driver.get("http://stackoverflow.com/");
Sasi Reddy
  • 11
  • 3
0

You just need to import two links:

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

or you can follow that tutorial:

https://www.youtube.com/watch?v=7yYDOja8n_k

It works for me.

barbsan
  • 3,238
  • 11
  • 18
  • 27
Aditi
  • 71
  • 6
0

Please follow the below steps:

  1. right-click on project--> goto build path--> configure build path
  2. Click on Classpath node which is just below the Modulepath node.
  3. click "Add external jars"--> add selenium jar files from your local machine-->
  4. Click Apply and Close button.
user3729220
  • 160
  • 1
  • 7