How do I find total number of links on a web page using selenium and java 11?



  • 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  
    
              System.setProperty("webdriver.chrome.driver","C:\\JARs\\chromedriver_win32\\chromedriver.exe");
          WebDriver driver = (WebDriver) new ChromeDriver();
          String url= "http://qaclickacademy.com/practice.php";
          driver.get(url);
          System.out.println(driver.findElements(By.xpath("a")).size());
       }
    }
    

    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



  • 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.



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2