无法在我的macbook中的firefox浏览器上打开网页

时间:2017-12-06 09:00:25

标签: java macos selenium firefox

我试图在我的MacBook上打开谷歌页面收到错误

package practice;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class Test {

    public static void main(String[] args) {

        System.setProperty("webdriver.firefox.marionette", "/Users/swapnilasingh/eclipse-workspace/practice/practice/geckodriver");
        WebDriver driver = new FirefoxDriver();
        driver.get("http://www.google.com");
    }
}

期待在Firefox上打开谷歌主页

Exception in thread "main" org.openqa.selenium.WebDriverException: Timed out waiting 45 seconds for Firefox to start.
Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T16:15:26.402Z'
System info: host: 'swapnilas-MBP.Dlink', ip: '192.168.0.25', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.1', java.version: '1.8.0_152'
Driver info: driver.version: FirefoxDriver
    at org.openqa.selenium.firefox.XpiDriverService.waitUntilAvailable(XpiDriverService.java:112)
    at org.openqa.selenium.firefox.XpiDriverService.start(XpiDriverService.java:97)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:79)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:586)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:217)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:140)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:120)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:98)
    at practice.Test.main(Test.java:19)
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:43144/hub/status] to be available after 45007 ms
    at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:100)
    at org.openqa.selenium.firefox.XpiDriverService.waitUntilAvailable(XpiDriverService.java:110)
    ... 8 more
Caused by: java.util.concurrent.TimeoutException
    at java.util.concurrent.FutureTask.get(FutureTask.java:205)
    at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:147)
    at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:75)
    ... 9 more

1 个答案:

答案 0 :(得分:0)

请像这样重写你的代码。

 public static void main(String[] args) {

    System.setProperty("webdriver.gecko.driver", "/Users/swapnilasingh/eclipse-workspace/practice/practice/geckodriver");
    WebDriver driver = new FirefoxDriver();
    driver.get("http://www.google.com");
}