带有新 FirefoxDriver 的 Selenium 3.0.1 + Marionette 卡在起始页上

Selenium 3.0.1 with new FirefoxDriver + Marionette stuck on start page

我正在将我的 Selenium 应用程序从 2.53 迁移到 3.0.1。首先,我想在一个启动浏览器并导航到特定页面的小应用程序中对其进行测试。
此外,我想为 Firefox(版本 51.0,便携式应用程序)使用自定义二进制文件。

这是我的代码:

public class Selenium {

        public static void main(String[] args) {
            WebDriver driver = createFFDriver();
            driver.navigate().to("http:....");
            System.out.println("Finished");
        }

        public static WebDriver createFFDriver(){
            System.setProperty(GeckoDriverService.GECKO_DRIVER_EXE_PROPERTY,"foo/geckodriver64.exe");
            DesiredCapabilities capabilities = DesiredCapabilities.firefox();
            capabilities.setCapability("firefox_binary","foo/firefox.exe");
            return new FirefoxDriver(capabilities);
        }
}

浏览器实际打开,但被阻止。
日志:

1486713046153   geckodriver INFO    Listening on 127.0.0.1:12466 
Feb 10, 2017 8:50:46 AM org.openqa.selenium.remote.ProtocolHandshake
createSession INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
1486713046731   mozprofile::profile INFO    Using profile path foo\AppData\Local\Temp\rust_mozprofile.p25D0Gb1sBQm
1486713046752   geckodriver::marionette INFO    Starting browser foo\firefox.0\FirefoxPortable.exe
1486713046782   geckodriver::marionette INFO    Connecting to Marionette on localhost:52818

为什么 Geckodriver 在 127.0.0.1:12466 上侦听,但它正在尝试连接到 localhost:52818 上的 Marionette?

这是我卡住的页面:

编辑: 它卡在 RemoteWebDriver startSession 方法中:

Response response = this.execute("newSession", parameters);

我已经使用 Selenium V 3.0.1 和 Firefox 51.0.1(32 位)尝试了您的代码,并成功访问了 URL/other 网络驱动程序 functions/no 阻塞。

更新

WebDriver firefox; System.setProperty(GeckoDriverService.GECKO_DRIVER_EXE_PROPERTY,"pathtogeckodriver"); FirefoxProfile profile = new FirefoxProfile(); firefox = new FirefoxDriver( new FirefoxBinary( new File(System.getProperty("user.dir"), "\FirefoxPortable\FirefoxPortable.exe")), profile); driver.get("http://www.google.com");

这与便携式 Firefox 版本 (51.0.1) 完美配合

Firefox 便携版似乎不能很好地与 Gecko Driver 配合使用。
它与传统 Firefox (51.0.1) 一起正常工作。