如何更改Webdriver Firefox连接到localhost的端口?

J. *_* K. 6 firefox selenium webdriver

我有一个selenium webdriver测试,转换为maven项目,我想通过Jenkins上的xvfb运行.

显示选择存在问题,但我想尝试其他方法并更改端口,例如.

这是我得到的错误:

org.openqa.selenium.firefox.NotConnectedException:无法连接后45000毫秒到主机端口7055 127.0.0.1.

Firefox控制台输出:

错误:未指定显示

错误:未指定显示

这是我的代码:

File ffExe = new File("/usr/bin/firefox");
FirefoxBinary ffox = new FirefoxBinary(ffExe);
ffox.setEnvironmentProperty("DISPLAY", ":21");
WebDriver driver = new FirefoxDriver(ffox, null);
Run Code Online (Sandbox Code Playgroud)

那么,我如何告诉firefox使用另一个端口以及我应该指定哪个端口?

Akb*_*bar 2

有一个系统属性 -webdriver.firefox.port 可能是 yoru 查询的答案。它列在 wiki - http://code.google.com/p/selenium/wiki/FirefoxDriver上,但没有提供相同的文档。您可以尝试让我们知道它是否有效:)