Using latest selenium ver with JAva 8 is giving LoggingHandler error

java, selenium

Solution

The error seems to be that it does not find the class `LoggingHandler`. That class is usually in the `selenium-api` dependency. You can try to use `2.53.1` version instead of `3.4.0`. That version has the missing class.

<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-api</artifactId>
    <version>2.53.1</version>
</dependency>

Problem

I am trying to run a simple selenium script which open the chrome driver to navigate to the url. Below is my code: ``` WebDriver driver =new ChromeDriver(); driver.get("http://www.google.com"); WebElement element=driver.findElement(By.name("q")); element.sendKeys("Cheese!!!"); element.submit(); System.out.println("Page title is: " + driver.getTitle()); driver.quit(); ``` On running the code I am getting the following error : ``` Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/logging/LoggingHandler at Main.main(Main.java:16) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140) Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.logging.LoggingHandler at java.net.URLClassLoader$1.run(URLClassLoader.java:372) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:360) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ``` My pom file has these dependencies : ``` <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>3.4.0</version> </dependency> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-server</artifactId> <version>3.4.0</version> </dependency> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-firefox-driver</artifactId> <version>3.4.0</version> </dependency> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-chrome-driver</artifactId> <version>3.4.0</version> </dependency> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-api</artifactId> <version>3.4.0</version> </dependency> ``` What is causing the above error? I have tried searching online but can't find one answer to this.

Original source