Selenium 3.0.1与新的FirefoxDriver + Marionette卡在起始页面上

时间:2017-02-10 08:06:32

标签: java selenium firefox selenium-webdriver geckodriver

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

这是我的代码

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\51.0\FirefoxPortable.exe
1486713046782   geckodriver::marionette INFO    Connecting to Marionette on localhost:52818

为什么Geckodriver会在127.0.0.1:12466上收听,但它正试图通过localhost:52818连接到Marionette?

这是我遇到困难的页面: enter image description here

编辑: 它停留在RemoteWebDriver startSession方法中:

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

2 个答案:

答案 0 :(得分:0)

我已经使用Selenium V 3.0.1和Firefox 51.0.1(32位)尝试了您的代码,并成功访问了URL /其他Web驱动程序功能/无阻塞。

<强>更新

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");

这与Portable Firefox版本(51.0.1)完美配合

答案 1 :(得分:0)

Firefox的便携版似乎与Gecko Driver不兼容 它与传统的Firefox(51.0.1)一样正常工作。