[英]How to run a simple Selenium automation test with FireFox in Mac OS and Eclipse
Im having an issue with running automation test with Selenium in Firefox adding the Geckodriver to my Java project that I have downloaded.我在使用 Firefox 中的 Selenium 运行自动化测试时遇到问题,将 Geckodriver 添加到我下载的 Java 项目中。 Whatever jar files I'm adding I'm getting the same error message in the Eclipse console.
无论我添加什么 jar 文件,我都会在 Eclipse 控制台中收到相同的错误消息。
I have downloaded these following files to my project in Eclipse from我已从 Eclipse 将以下文件下载到我的项目中
https://www.seleniumhq.org/download/ : https://www.seleniumhq.org/download/ :
So I assume that these above files should be the latest ones?所以我假设以上这些文件应该是最新的?
However when Im running the small Java program below:但是,当我运行下面的小 Java 程序时:
public static void main(String[] args) {
System.setProperty("webdriver.gecko.driver", "/Users/myName/Desktop/geckodriver");
System.setProperty("webdriver.firefox.bin", "/Applications/Firefox.app/Contents/MacOS/firefox-bin");
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com");
}
...Im getting the following error: ...我收到以下错误:
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:146) at org.openqa.selenium.firefox.GeckoDriverService.access$000(GeckoDriverService.java:44) at org.openqa.selenium.firefox.GeckoDriverService$Builder.usingFirefoxBinary(GeckoDriverService.java:160) at org.openqa.selenium.firefox.FirefoxDriver.toExecutor(FirefoxDriver.java:187) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.Z93F725A07 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:146) at org.openqa.selenium.firefox.GeckoDriverService.access$000(GeckoDriverService.java:44) at org.openqa.selenium.firefox.GeckoDriverService$Builder.usingFirefoxBinary(GeckoDriverService.java:160) at org.openqa.selenium.firefox.FirefoxDriver.toExecutor(FirefoxDriver.java:187) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.Z93F725A07 423FE1C889F448B33D21F46Z:147) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:125) at test.SeleniumTest.main(SeleniumTest.java:14)
423FE1C889F448B33D21F46Z:147) at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:125) at test.SeleniumTest.main(SeleniumTest.java:14)
These are the jars in my Build path: Build path in Eclipse这些是我的构建路径中的 jars : Eclipse 中的构建路径
My Eclipse version: Oxygen.3a Release (4.7.3a)我的 Eclipse 版本: Oxygen.3a Release (4.7.3a)
My Firefox Version: Firefox Quantum (69.0.34, 64-bit)我的 Firefox 版本: Firefox 量子(69.0.34,64 位)
My Mac OS Version: OS X El Capitan (10.11.6)我的 Mac OS 版本: OS X El Capitan (10.11.6)
Im still confused why because I just followed a lot of tutorials out there explaining it on how to achieve the automation test.我仍然很困惑为什么,因为我只是按照那里的很多教程来解释如何实现自动化测试。
Did I just missed to add something to my project?我只是错过了为我的项目添加一些东西吗?
All help and advice would be highly appreciated所有帮助和建议将不胜感激
Read this trouble ticket .阅读此故障单。 You have an outdated version of guava.
你有一个过时的番石榴版本。
You should be able to add the guava JAR file to your Eclipse project by right clicking on the project name and selecting Build Path > Libraries > Add External JAR.您应该能够通过右键单击项目名称并选择 Build Path > Libraries > Add External Z529E625C8C2BF37C6334AAE495A1D0 将番石榴 JAR 文件添加到 Eclipse 项目中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.