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

给你一囗甜甜゛ 提交于 2020-03-05 06:45:45

问题


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?


回答1:


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.


来源:https://stackoverflow.com/questions/52014053/exception-in-thread-main-java-lang-nosuchmethoderror-com-google-common-base-p

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!