WebDriver出错

问题描述 投票:-1回答:1

我有以下错误:

Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;)V
    at org.openqa.selenium.remote.service.DriverService.checkExecutable(DriverService.java:136)
    at org.openqa.selenium.firefox.GeckoDriverService.access$000(GeckoDriverService.java:41)
    at org.openqa.selenium.firefox.GeckoDriverService$Builder.usingFirefoxBinary(GeckoDriverService.java:134)
    at org.openqa.selenium.firefox.FirefoxDriver.toExecutor(FirefoxDriver.java:155)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:120)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:98)
    at automationFramework.SecondTest.main(SecondTest.java:20)

我的代码:

package automationFramework;

import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.DesiredCapabilities;

import junit.runner.Version;
public class SecondTest {

    public static void main(String[] args) throws Exception {



        System.out.println("JUnit version is: " + Version.id());

    DesiredCapabilities capabilities = DesiredCapabilities.firefox();
    capabilities.setCapability("marionette", true);

    FirefoxDriver driver = new FirefoxDriver();


    //System.setProperty("webdriver.gecko.driver", "C:\\\\Program Files\\Firefox Developer Edition\\firefox.exe");  
    System.setProperty("webdriver.gecko.driver", "E:\\\\Projects\\WebDriver\\geckodriver.exe"); 

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




    }

}
java selenium selenium-webdriver
1个回答
0
投票

这看起来像是Guava库的一个问题。如果您使用maven来管理依赖项,请手动设置Guava版本,如下所示:

<dependency>
    <groupId>com.google.guava</groupId>
    <artifactId>guava</artifactId>
    <version>22.0</version>
</dependency>

另外,从系统属性中删除\\部件。它应该只是\\

© www.soinside.com 2019 - 2024. All rights reserved.