1

Code trials:

package SeleniumSessions;

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


public class TestChrome {

    public static void main(String[] args) {
       System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");

        WebDriver driver=new ChromeDriver();

        driver.get("https://www.google.com");

    }
}

Error:

Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/collect/ImmutableMap
    at org.openqa.selenium.chrome.ChromeDriver$ChromeDriverCommandExecutor.getExtraCommands(ChromeDriver.java:122)
    at org.openqa.selenium.chrome.ChromeDriver$ChromeDriverCommandExecutor.<init>(ChromeDriver.java:118)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:106)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:93)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:48)
    at SeleniumSessions.TestChrome.main

Error snapshot: enter image description here

0

1 Answer 1

0

This error message...

Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/collect/ImmutableMap

...implies that the file com/google/common/collect/ImmutableMap might be corrupted or there is some incompatibility between the version of the binaries you are using.


Further you need to take care of a couple of things as follows:

  • Instead of storing the chromedriver.exe binary right under C:\ try to put it within a directory as C:\\BrowserDrivers\\chromedriver.exe and change the System.setProperty() line accordingly. So effectively, the line of code will be:

    System.setProperty("webdriver.gecko.driver","C:\\BrowserDrivers\\chromedriver.exe");
    

Also ensure that:


Reference

You can find a relevant discussion in:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.