java.lang.Error: Unresolved compilation problems : WebDriver/ChromeDriver cannot be resolved to a type error while executing selenium tests

This error message…

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

…implies that WebDriver and ChromeDriver wasn’t resolved at compiletime.

As per the snapshot you have shared your main issue is the presence of multiple similar binaries within your project space as follows :

  • You have included selenium-server-standalone-3.11.0 as a dependency.
  • Additionally you have included the Java Client JARs from selenium-java-3.11.0 as a dependency.

As a result it is pretty much possible that you have resolved the WebDriver and ChromeDriver from one JAR resource (i.e. either selenium-server-standalone-3.11.0 or selenium-java-3.11.0 JARs) but compiletime the Classes are trying to get resolved from the other JAR. Hence you see java.lang.Error: Unresolved compilation problems

Solution

  • Either keep only selenium-server-standalone-3.11.0 JAR as an external JAR.
  • Or keep only selenium-java-3.11.0 JARs as an external JARs.
  • Remove all the other Selenium Java Client JARs.
  • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
  • Take a System Reboot.
  • Execute your @Test.

Leave a Comment