1

I'm getting the following error :

Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
WebDriver cannot be resolved to a type. ChromeDriver cannot be resolved to a type   at firstproject/firstprojetone.MyLatestClass.main(MyLatestClass.java:14)

I have Installed Java 11.0.2 version, Ecllipse IDE 2018-12(64 Bit) and Lib and Configured with ecllipse IDE.

Java programs are executing successfully.

Ali
  • 1,689
  • 1
  • 5
  • 12

2 Answers2

0

In general, in case of any problems with your import or package name, it results in the exception. Deletion of the package name or fixing import errors might help resolving the issue.

The problem may be even clear, if you can share your code

Priyanka
  • 31
  • 9
  • Here is the Code Priyanka, Please Review. package firstprojetone; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; public class MyLatestClass { public static void main(String args[]) { System.setProperty("webdriver.chrome.driver", "C:\\Program Files\\Java\\Chromedriver.exe"); WebDriver driver=new ChromeDriver(); driver.get("http://google.com"); } } – Vandana Rani Mar 04 '19 at 10:14
  • Can you share your project structure – Priyanka Mar 04 '19 at 10:17
  • http://www.screencast.com/t/NT3ogLTJ51 – Vandana Rani Mar 04 '19 at 10:29
0
Exception in thread "main" java.lang.Error: Unresolved compilation problems: WebDriver cannot be resolved to a type.

You need to add selenium webdriver jar files to the project to get rid of that

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.

After adding your jar you need to do some modification as per your comments i found, you write

driver.get("google.com");

and it will throw error invalid URL. you need to use below syntax.

driver.get("https://www.google.com");

Hope this helps.

Dhru 'soni
  • 1,024
  • 7
  • 23
KunduK
  • 32,888
  • 5
  • 17
  • 41