public class selenium {
public static void main(String[] args) {
WebDriver driver = new ChromeDriver();
driver.get("http://www.google.com");
}
}
发生以下错误
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;)V
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:124)
at org.openqa.selenium.chrome.ChromeDriverService.access$000(ChromeDriverService.java:32)
at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:137)
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:339)
at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:88)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:123)
答案 0 :(得分:0)
我发现我的问题的答案如下 首先在下面的链接中下载chrome驱动程序并保存到d / firefox等仲裁驱动器 https://sites.google.com/a/chromium.org/chromedriver/downloads 2- 我们应该通过setpropertycode将selenium设置为我们的chrome驱动程序,如下所示 System.setProperty(&#34; webdriver.chrome.driver&#34;&#34; d:\火狐\ chromedriver.exe&#34);
最后我们的代码聘用没有任何错误
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver","D:\\Firefox\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("http://www.google.com");