简体   繁体   English

如何在 Mac OS 和 Eclipse 中使用 FireFox 运行简单的 Selenium 自动化测试

[英]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/


Java file Java文件

Geckodriver壁虎司机



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.你有一个过时的番石榴版本。

Update guava here .在这里更新番石榴。

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.

相关问题 如何在 Mac 操作系统上运行 Eclipse 内存分析器? - How to run Eclipse memory analyzer on Mac os? Firefox自动化不起作用(在Eclipse中使用Selenium) - Firefox automation not working (using Selenium in Eclipse) 运行Eclipse Mac OS X - Run eclipse mac os x 如何让 Selenium 自动化变得简单? - How to make Selenium automation simple? 如何解决 windows 10 OS 下 selenium 中的连接不安全? 帮助 SLENIUM firefox 测试自动化社区请 - How to solve connection not secure in selenium under windows 10 OS ? HELP SLENIUM firefox tests automation community pleease 如何在Mac OS X 10.7.5上运行Eclipse Oxygen - How to run Eclipse Oxygen on Mac OS X 10.7.5 如何使用Mac OS X在Eclipse中运行现有的Maven项目 - How to run existing maven project in eclipse using mac os X 如何使用Maven在Firefox中运行Selenium WebDriver测试用例? - How to run Selenium WebDriver test cases in Firefox with Maven? 多个Selenium Grid 2测试:如何在带有隐藏Windows浏览器的Firefox中运行 - Multiple Selenium Grid 2 Test: how to run in Firefox with hidden windows Browser 如何在 Mac 上使用 Jenkins 运行 selenium 测试用例? - How do I run a selenium test case using Jenkins, on a mac?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM