I am just trying to run a basic webdriver program using the IntelliJ IDE but I get all these errors upon running:
"C:\Program Files\Java\jdk-19\bin\java.exe" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2022.2.3\lib\idea_rt.jar=59762:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2022.2.3\bin" -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 -classpath C:\Users\roone\IdeaProjects\WebDriverDemo\target\classes;C:\Users\roone\.m2\repository\org\seleniumhq\selenium\selenium-java\4.0.0-beta-4\selenium-java-4.0.0-beta-4.jar;C:\Users\roone\.m2\repository\org\seleniumhq\selenium\selenium-chrome-driver\4.0.0-beta-4\selenium-chrome-driver-4.0.0-beta-4.jar;C:\Users\roone\.m2\repository\com\google\auto\service\auto-service-annotations\1.0\auto-service-annotations-1.0.jar;C:\Users\roone\.m2\repository\com\google\auto\service\auto-service\1.0\auto-service-1.0.jar;C:\Users\roone\.m2\repository\com\google\auto\auto-common\1.0\auto-common-1.0.jar;C:\Users\roone\.m2\repository\com\google\guava\guava\30.1.1-jre\guava-30.1.1-jre.jar;C:\Users\roone\.m2\repository\com\google\guava\failureaccess\1.0.1\failureaccess-1.0.1.jar;C:\Users\roone\.m2\repository\com\google\guava\listenablefuture\9999.0-empty-to-avoid-conflict-with-guava\listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar;C:\Users\roone\.m2\repository\com\google\code\findbugs\jsr305\3.0.2\jsr305-3.0.2.jar;C:\Users\roone\.m2\repository\org\checkerframework\checker-qual\3.8.0\checker-qual-3.8.0.jar;C:\Users\roone\.m2\repository\com\google\errorprone\error_prone_annotations\2.5.1\error_prone_annotations-2.5.1.jar;C:\Users\roone\.m2\repository\com\google\j2objc\j2objc-annotations\1.3\j2objc-annotations-1.3.jar;C:\Users\roone\.m2\repository\org\seleniumhq\selenium\selenium-chromium-driver\4.0.0-beta-4\selenium-chromium-driver-4.0.0-beta-4.jar;C:\Users\roone\.m2\repository\org\seleniumhq\selenium\selenium-devtools\4.0.0-beta-4\selenium-devtools-4.0.0-beta-4.jar;C:\Users\roone\.m2\repository\org\seleniumhq\selenium\selenium-http\4.0.0-beta-4\selenium-http-4.0.0-beta-4.jar;C:\Users\roone\.m2\repository\org\seleniumhq\selenium\selenium-json\4.0.0-beta-4\selenium-json-4.0.0-beta-4.jar;C:\Users\roone\.m2\repository\org\seleniumhq\selenium\selenium-devtools-v85\4.0.0-beta-4\selenium-devtools-v85-4.0.0-beta-4.jar;C:\Users\roone\.m2\repository\org\seleniumhq\selenium\selenium-devtools-v88\4.0.0-beta-4\selenium-devtools-v88-4.0.0-beta-4.jar;C:\Users\roone\.m2\repository\org\seleniumhq\selenium\selenium-devtools-v89\4.0.0-beta-4\selenium-devtools-v89-4.0.0-beta-4.jar;C:\Users\roone\.m2\repository\org\seleniumhq\selenium\selenium-devtools-v90\4.0.0-beta-4\selenium-devtools-v90-4.0.0-beta-4.jar;C:\Users\roone\.m2\repository\org\seleniumhq\selenium\selenium-devtools-v91\4.0.0-beta-4\selenium-devtools-v91-4.0.0-beta-4.jar;C:\Users\roone\.m2\repository\org\seleniumhq\selenium\selenium-edge-driver\4.0.0-beta-4\selenium-edge-driver-4.0.0-beta-4.jar;C:\Users\roone\.m2\repository\org\seleniumhq\selenium\selenium-firefox-driver\4.0.0-beta-4\selenium-firefox-driver-4.0.0-beta-4.jar;C:\Users\roone\.m2\repository\org\seleniumhq\selenium\selenium-firefox-xpi-driver\4.0.0-beta-4\selenium-firefox-xpi-driver-4.0.0-beta-4.jar;C:\Users\roone\.m2\repository\org\seleniumhq\selenium\selenium-ie-driver\4.0.0-beta-4\selenium-ie-driver-4.0.0-beta-4.jar;C:\Users\roone\.m2\repository\org\seleniumhq\selenium\selenium-opera-driver\4.0.0-beta-4\selenium-opera-driver-4.0.0-beta-4.jar;C:\Users\roone\.m2\repository\org\seleniumhq\selenium\selenium-remote-driver\4.0.0-beta-4\selenium-remote-driver-4.0.0-beta-4.jar;C:\Users\roone\.m2\repository\com\beust\jcommander\1.81\jcommander-1.81.jar;C:\Users\roone\.m2\repository\io\netty\netty-buffer\4.1.63.Final\netty-buffer-4.1.63.Final.jar;C:\Users\roone\.m2\repository\io\netty\netty-codec-http\4.1.63.Final\netty-codec-http-4.1.63.Final.jar;C:\Users\roone\.m2\repository\io\netty\netty-codec\4.1.63.Final\netty-codec-4.1.63.Final.jar;C:\Users\roone\.m2\repository\io\netty\netty-handler\4.1.63.Final\netty-handler-4.1.63.Final.jar;C:\Users\roone\.m2\repository\io\netty\netty-common\4.1.63.Final\netty-common-4.1.63.Final.jar;C:\Users\roone\.m2\repository\io\netty\netty-transport-native-epoll\4.1.63.Final\netty-transport-native-epoll-4.1.63.Final.jar;C:\Users\roone\.m2\repository\io\netty\netty-transport-native-kqueue\4.1.63.Final\netty-transport-native-kqueue-4.1.63.Final.jar;C:\Users\roone\.m2\repository\io\netty\netty-transport-native-unix-common\4.1.63.Final\netty-transport-native-unix-common-4.1.63.Final.jar;C:\Users\roone\.m2\repository\io\netty\netty-transport\4.1.63.Final\netty-transport-4.1.63.Final.jar;C:\Users\roone\.m2\repository\io\netty\netty-resolver\4.1.63.Final\netty-resolver-4.1.63.Final.jar;C:\Users\roone\.m2\repository\io\opentelemetry\opentelemetry-api\1.2.0\opentelemetry-api-1.2.0.jar;C:\Users\roone\.m2\repository\io\opentelemetry\opentelemetry-context\1.2.0\opentelemetry-context-1.2.0.jar;C:\Users\roone\.m2\repository\io\opentelemetry\opentelemetry-exporter-logging\1.2.0\opentelemetry-exporter-logging-1.2.0.jar;C:\Users\roone\.m2\repository\io\opentelemetry\opentelemetry-sdk-metrics\1.2.0-alpha\opentelemetry-sdk-metrics-1.2.0-alpha.jar;C:\Users\roone\.m2\repository\io\opentelemetry\opentelemetry-sdk-common\1.2.0\opentelemetry-sdk-common-1.2.0.jar;C:\Users\roone\.m2\repository\io\opentelemetry\opentelemetry-sdk-extension-autoconfigure\1.2.0-alpha\opentelemetry-sdk-extension-autoconfigure-1.2.0-alpha.jar;C:\Users\roone\.m2\repository\io\opentelemetry\opentelemetry-sdk-trace\1.2.0\opentelemetry-sdk-trace-1.2.0.jar;C:\Users\roone\.m2\repository\io\opentelemetry\opentelemetry-api-metrics\1.2.0-alpha\opentelemetry-api-metrics-1.2.0-alpha.jar;C:\Users\roone\.m2\repository\io\opentelemetry\opentelemetry-sdk\1.2.0\opentelemetry-sdk-1.2.0.jar;C:\Users\roone\.m2\repository\io\opentelemetry\opentelemetry-semconv\1.2.0-alpha\opentelemetry-semconv-1.2.0-alpha.jar;C:\Users\roone\.m2\repository\io\ous\jtoml\2.0.0\jtoml-2.0.0.jar;C:\Users\roone\.m2\repository\net\bytebuddy\byte-buddy\1.11.0\byte-buddy-1.11.0.jar;C:\Users\roone\.m2\repository\org\apache\commons\commons-exec\1.3\commons-exec-1.3.jar;C:\Users\roone\.m2\repository\org\asynchttpclient\async-http-client\2.12.3\async-http-client-2.12.3.jar;C:\Users\roone\.m2\repository\org\asynchttpclient\async-http-client-netty-utils\2.12.3\async-http-client-netty-utils-2.12.3.jar;C:\Users\roone\.m2\repository\io\netty\netty-codec-socks\4.1.60.Final\netty-codec-socks-4.1.60.Final.jar;C:\Users\roone\.m2\repository\io\netty\netty-handler-proxy\4.1.60.Final\netty-handler-proxy-4.1.60.Final.jar;C:\Users\roone\.m2\repository\io\netty\netty-transport-native-epoll\4.1.60.Final\netty-transport-native-epoll-4.1.60.Final-linux-x86_64.jar;C:\Users\roone\.m2\repository\io\netty\netty-transport-native-kqueue\4.1.60.Final\netty-transport-native-kqueue-4.1.60.Final-osx-x86_64.jar;C:\Users\roone\.m2\repository\org\reactivestreams\reactive-streams\1.0.3\reactive-streams-1.0.3.jar;C:\Users\roone\.m2\repository\com\typesafe\netty\netty-reactive-streams\2.0.4\netty-reactive-streams-2.0.4.jar;C:\Users\roone\.m2\repository\org\slf4j\slf4j-api\1.7.30\slf4j-api-1.7.30.jar;C:\Users\roone\.m2\repository\com\sun\activation\jakarta.activation\1.2.2\jakarta.activation-1.2.2.jar;C:\Users\roone\.m2\repository\org\seleniumhq\selenium\selenium-safari-driver\4.0.0-beta-4\selenium-safari-driver-4.0.0-beta-4.jar;C:\Users\roone\.m2\repository\org\seleniumhq\selenium\selenium-support\4.0.0-beta-4\selenium-support-4.0.0-beta-4.jar;C:\Users\roone\.m2\repository\org\seleniumhq\selenium\selenium-api\3.141.59\selenium-api-3.141.59.jar com.pluralsight.WebDriverDemo
Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/HasAuthentication
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1013)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:862)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1013)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:862)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at com.pluralsight.WebDriverDemo.main(WebDriverDemo.java:11)
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.HasAuthentication
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 19 more
Process finished with exit code 1
As I've read online or in other similar threads, it should be due to the lack of authentication of chrome. I tried different methods but none of them worked. My WebDriverDemo.java file:
package com.pluralsight;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class WebDriverDemo {
public static void main(String[] args) {
WebDriver driver = new ChromeDriver();
driver.get("http://google.com");
}
}
My pom.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.pluralsight</groupId>
<artifactId>WebDriverDemo</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.release>1.11</maven.compiler.release>
</properties>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.0.0-beta-4</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
</plugins>
</build>
</project>
Any help will be greatly appreciated. Thanks
CodePudding user response:
I think this error might be related to the fact, that you do not have specified a chromedriver version. I would suggest using a driver manager. Add this dependency to pom.xml
:
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>5.1.0</version>
<scope>compile</scope>
</dependency>
Then in your WebDriverDemo.java
file you could initiate the webdriver like this:
WebDriverManager.chromedriver().driverVersion("100.0.4896.60").setup();
WebDriver driver = new ChromeDriver();
driver.get("https://www.google.com");
The versions might need updating, this code is copied from an older project of mine.
Also it might be an issue because you are using http
instead of https
in the link, I remember this causing issues as well.