I've reverted some of my JAR files in order to be able to import the webdrivers within Eclipse (WebDriver, Chromdriver, GeckoDriver)...
I was successful in importing said drivers but am unable to actually launch the browsers associated with them.
My code is:
package webElementsandDrivers;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class wDrivers {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "C:\\Users\\munta\\WebDrivers\\chromedriver");
WebDriver driver = new ChromeDriver();
driver.get("http://www.google.com");
}
}
The error I'm getting in the Eclipse console reads:
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/collect/ImmutableMap
at org.openqa.selenium.remote.service.DriverService$Builder.<init>(DriverService.java:259)
at org.openqa.selenium.chrome.ChromeDriverService$Builder.<init>(ChromeDriverService.java:101)
at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:94)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:123)
at webElementsandDrivers.wDrivers.main(wDrivers.java:12)
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.ImmutableMap
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:520)
... 5 more
Any and all help would be greatly appreciated.
CodePudding user response:
You were pretty close. As you are on windows os along with the executable binary i.e. chromedriver
you also need to pass the extension i.e. exe
.
Effectively, your line of code will be:
System.setProperty("webdriver.chrome.driver", "C:\\Users\\munta\\WebDrivers\\chromedriver.exe");
CodePudding user response:
You might be struggling over different versions.
Example: Your Project startet 2 weeks ago. So you have used chrom-driver Version 101.xxx. In the last days chrom-Browser got an update and is now version 103.xxx.
Your driver will not start with this combination. That was a point last days here on my side.
Please check your driver Version and Browser Version.