package exsc;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.By;

public class S1 {

   public static void main(String[] args) {
          // TODO Auto-generated method stub
          // Give me the count of Links on a page  

      WebDriver driver = (WebDriver) new ChromeDriver();
      String url= "http://qaclickacademy.com/practice.php";

Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/chrome/ChromeDriver at exsc.S1.main(S1.java:13) Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.chrome.ChromeDriver at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ... 1 more

  • WebDriver driver = (WebDriver) new ChromeDriver(); - why are you casting your driver object here? WebDriver driver = new ChromeDriver(); should work fine.
    – Brian
    Commented Sep 9, 2019 at 21:23
  • 1
    Earlier it forced me to cast in order to compile successfully. Now the issue is resolved.
    – Mani
    Commented Sep 9, 2019 at 21:39

2 Answers 2


Just a minor point, instead of using xpath it'll be good if you use tagName in this scenario to find all the links. Something like this:


Issue found with JAR mappings to the current project. Instead of importing external JARs to classpath in Build Path, it got imported to Modulepath.

Rearranging JARs solved the issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.