WebDriver cannot be resolved to a type FirefoxDriver cannot be resolved to a type
Asked Answered
D

8

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

Dzoba answered 31/7, 2015 at 6:25 Comment(2)
What is the code that u have writtenSalina
Thanks Snadeep ! The issue is resolvedDzoba
B
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.

Banuelos answered 3/8, 2015 at 8:48 Comment(6)
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("only-testing-blog.blogspot.in"); String i = driver.getCurrentUrl(); System.out.println(i); driver.close(); } }Dzoba
Are there any errors when you build the project, displayed in the output windows?Banuelos
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)Dzoba
Hi Anton ,I reconfigured Eclipse with selenium 2 and its working now.Thank you for your helpDzoba
I'm glad that I could help. Can you please mark the question as answered and vote. Thanks :)Banuelos
I have similar problem. Must be following the same duff tutorial. How did you reconfigure Eclipse with Selenium 2, Juvelle?Misvalue
S
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.

Salamanca answered 13/5, 2016 at 5:0 Comment(0)
B
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.

Banuelos answered 3/8, 2015 at 8:48 Comment(6)
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("only-testing-blog.blogspot.in"); String i = driver.getCurrentUrl(); System.out.println(i); driver.close(); } }Dzoba
Are there any errors when you build the project, displayed in the output windows?Banuelos
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)Dzoba
Hi Anton ,I reconfigured Eclipse with selenium 2 and its working now.Thank you for your helpDzoba
I'm glad that I could help. Can you please mark the question as answered and vote. Thanks :)Banuelos
I have similar problem. Must be following the same duff tutorial. How did you reconfigure Eclipse with Selenium 2, Juvelle?Misvalue
D
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

Dunsinane answered 10/1, 2017 at 18:14 Comment(0)
S
1

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.
Sheilahshekel answered 30/7, 2019 at 10:48 Comment(1)
Thanks, I used the latest eclipse where we have two options now where I added external jars under Modulepath and that's why it shows an error. I moved all the jars into Classpath and works fine.Ebonieebonite
E
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.

Embracery answered 3/1, 2017 at 5:47 Comment(0)
O
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/");
Orfield answered 3/1, 2017 at 6:17 Comment(0)
M
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.

Mesothelium answered 15/4, 2019 at 5:58 Comment(0)
K
0

By importing webdriver and chromedriver/firefox dependency this issue can be fixed, but before this lease make sure that @Test is written if you are under TestNG folder.

Ketchup answered 25/8, 2023 at 16:56 Comment(1)
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From ReviewActinotherapy

© 2022 - 2024 — McMap. All rights reserved.