简体   繁体   中英

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. Whatever jar files I'm adding I'm getting the same error message in the Eclipse console.


I have downloaded these following files to my project in Eclipse from

https://www.seleniumhq.org/download/ :


Java file

Geckodriver



So I assume that these above files should be the latest ones?


However when Im running the small Java program below:

    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 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


My Eclipse version: Oxygen.3a Release (4.7.3a)
My Firefox Version: Firefox Quantum (69.0.34, 64-bit)
My Mac OS Version: 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM