Skip to content
Advertisement

Exception in thread “main” java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;)

I develop the selenium code that:

    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.chrome.ChromeDriver;
    import org.openqa.selenium.edge.EdgeDriver;
    import org.openqa.selenium.firefox.FirefoxDriver;
    import org.openqa.selenium.support.ui.Select;
    import java.util.List;

    public class TestDemoQA {
        public static void main(String[] args) throws InterruptedException{
            System.setProperty("webdriver.edge.driver", "C:\Users\Suganthan\Downloads\MicrosoftWebDriver.exe");
            WebDriver driver = new EdgeDriver();
            driver.get("http://demoqa.com/");
            driver.manage().window().maximize();`

I’m getting the error that is:

Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)

I’m trying to solve this issue according to This Solution by upgrading guava-21.0. But I’m still getting this error. could anyone give a solution to solve it?

Advertisement

Answer

This error message…

Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)

…implies that the JVM was unable to initiate/spawn your program.

As @GhostCat pointed your main issue is the incompatibility between the guava version and other binary versions you are using.

Solution

  • Upgrade JDK to recent levels JDK 8u181.
  • Upgrade Selenium to current levels Version 3.14.0.
  • When you remove the previous version of Selenium Client ensure that all the associated jars are properly removed.
  • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
  • Execute your @Test.
Advertisement