Selenium + Jenkins:缺少位置标题

时间:2013-10-02 13:16:41

标签: java selenium jenkins

我正在尝试将Selenium Grid与Jenkins一起使用。 当我使用服务器独立的2.35.0 jar启动Selenium Hub和Node时,一切都很完美。 但是,当我使用Jenkins Selenium Grid Plugin作为集线器时,它不起作用。

错误出现在这里:

  

driver = new RemoteWebDriver(new URL(gridURL),capabilities);

网格网址为"http://localhost:4444/wd/hub"

能力是这样的:

DesiredCapabilities capabilities = DesiredCapabilities.firefox ();
capabilities.setPlatform ( Platform.LINUX );

抛出此异常:

org.openqa.selenium.WebDriverException: Error forwarding the new session new session request for webdriver should contain a location header with the session.
Command duration or timeout: 25.28 seconds
Build info: version: '2.35.0', revision: '8df0c6bedf70ff9f22c647788f9fe9c8d22210e2', time: '2013-08-17 12:46:41'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '3.8.0-31-generic', java.version: '1.7.0_40'
Driver info: org.openqa.selenium.remote.RemoteWebDriver

作为Hub我使用Jenkins Selenium插件版本2.3 作为Node I,使用selenium-server-standalone-2.35.0.jar。

当我使用浏览器打开http://localhost:4444/时,它会显示:You are using grid 2.29.0 所以我下载了selenium-server-standalone-2.29.0.jar并让它作为集线器运行。该节点仍为版本2.35.0。 然后我有同样的例外。我尝试使用2.29.0节点和集线器,但似乎我的Firefox太新了。

我搜索了几个小时,但没有找到任何有关此错误的内容。

编辑: 由Jenkins安装的插件是2013年8月18日:https://wiki.jenkins-ci.org/display/JENKINS/Selenium+Plugin

开发人员在2013年8月20日的两天后更新了该插件:https://github.com/jenkinsci/selenium-plugin/commit/316eccdef608e855863cf04b1c240fa2c7b8b762

我不知道这是否会导致我的错误,但这是可能的。我还不知道如何做到这一点,但我将尝试从github上的源代码构建我自己的插件版本。

3 个答案:

答案 0 :(得分:2)

我现在肯定知道问题是什么:

如上所述,节点是Selenium Version 2.35。目前的Jenkins Selenium插件是使用Selenium 2.29的2.3版本。这导致错误。

现在我使用Selenium Version 2.29作为节点。并安装了Firefox版本18.现在一切正常。我联系了开发人员,我正在尝试从git构建当前的插件版本。现在没有成功,但我想我会打开另一个线程。

感谢您的帮助。

答案 1 :(得分:1)

您可以在jenkins插件中更新selenium版本,在下面提到的路径中将2.9.0替换为2.29.0:

[JenkinsFolder] \插件\硒\ WEB-INF \ lib中

你会在这里找到旧罐子。用最新的jar替换它。 它会正常工作。

答案 2 :(得分:0)

此错误表示您没有连接到集线器的节点。集线器 UP 并接收连接,但无法将请求转发给节点。

确保已将节点连接到集线器。你可以通过 -

来做到这一点
java -jar selenium-server-2.29.0.jar -role node -hubUrl http://ip-of-hub:4444/wd/register

此命令可能不准确。咨询官方文档。