我将我的Selenium应用程序从2.53迁移到3.0.1。首先,我想在一个小应用程序中测试它,只需启动浏览器并导航到特定页面即可。
此外,我想使用Firefox的自定义二进制文件(版本51.0,便携式应用程序)。Selenium 3.0.1与新的FirefoxDriver + Marionette卡在开始页面
这是我代码:
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
?
编辑: 它卡在RemoteWebDriver startSession方法:
Response response = this.execute("newSession", parameters);
它不起作用。你使用的是便携式应用程序版本的Firefox? – buzz2buzz
我试过了,但它也不能正常工作......当浏览器启动时,仍然停留在用户配置文件页面。你有没有关于什么配置点可以区分我们的想法? – buzz2buzz
你会得到什么例外? /你卡在哪里? –