在虚拟机上运行Selenium Grid时出现问题
我正在使用Vagrant在虚拟机上尝试Selenium Grid。我做的步骤是按照这里的说明进行的:https://code.google.com/p/selenium/wiki/Grid2。我先启动了一个中心(hub),命令是 sudo java -jar selenium-server-standalone-2.41.0.jar -role hub
。
然后在同一台虚拟机上定义了一个节点,命令是 sudo java -jar selenium-server-standalone-2.41.0.jar -role node -hub http://10.0.2.2:4444/grid/register
,其中 http://10.0.2.2:4444/
是这台虚拟机的私有IP,用来让节点注册到中心。
我的问题是,当我想运行一个用Python写的Selenium测试时,出现了这个错误:
Exception: <html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
<title>Error 500 org.openqa.grid.common.exception.GridException: Error forwarding the new session The server returned an error : Failed to start new browser session: org.openqa.selenium.server.RemoteCommandException: Error while launching browser</title>
</head>
<body>
<h2>HTTP ERROR: 500</h2>
<p>Problem accessing /selenium-server/driver/. Reason:
<pre> org.openqa.grid.common.exception.GridException: Error forwarding the new session The server returned an error : Failed to start new browser session: org.openqa.selenium.server.RemoteCommandException: Error while launching browser</pre></p>
<hr /><i><small>Powered by Jetty://</small></i>
而且当我在浏览器中运行这个链接: http://10.0.2.2:4444/selenium-server/driver/?cmd=getNewBrowserSession&1=*firefox&2=http://www.google.com
时,我也得到了这个错误: Error forwarding the new session Empty pool of VM for setup Capabilities
。
我觉得节点可能没有成功注册到中心。我还尝试把它改成公共IP,使用了类似 http://X.X.X.106:4444/grid/register
的地址,但错误依然存在。不过,当我在虚拟机外面尝试时,一切正常!有没有什么办法可以解决虚拟机上的Selenium Grid问题?