如何在远程机器上设置网格并运行webdriver测试用例?

时间:2013-09-18 14:08:12

标签: jenkins webdriver maven-3 selenium-grid

我拥有的;我有putty.exe访问远程ubuntu机器xxx.xx.xxx.xx.
我想要的是;我希望当我使用jenkins在这台远程计算机上运行我的测试用例时,它会启动一个浏览器,我可以在我的Windows机器上看到它。 我尝试过的;我曾尝试将firefox与Xvfb一起使用(两者都位于远程机器上),但这是无头的,我无法看到错误,我无法从报告中得到很多帮助。我想看看UI上发生了什么 所以我想使用远程webdriver。我尝试在远程计算机上注册;使用putty.exe

sudo java -jar selenium-server-standalone-2.35.0.jar -role node  -hub http://localhost/xxx.xx.xxx.xx:4444/grid/register

但是这给了错误:

Sep 27, 2013 9:24:24 AM org.openqa.grid.selenium.GridLauncher main
INFO: Launching a selenium grid node
Sep 27, 2013 9:24:24 AM org.openqa.grid.internal.utils.SelfRegisteringRemote startRemoteServer
WARNING: error getting the parameters from the hub. The node may end up with wrong timeouts.The target server failed to respond
09:24:24.961 INFO - Java: Oracle Corporation 23.7-b01
09:24:24.962 INFO - OS: Linux 3.5.0-21-generic amd64
09:24:24.971 INFO - v2.35.0, with Core v2.35.0. Built from revision c916b9d
09:24:25.111 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:5555/wd/hub
09:24:25.113 INFO - Version Jetty/5.1.x
09:24:25.114 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
09:24:25.115 INFO - Started HttpContext[/selenium-server,/selenium-server]
09:24:25.116 INFO - Started HttpContext[/,/]
09:24:36.415 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler@49af0a45
09:24:36.416 INFO - Started HttpContext[/wd,/wd]
09:24:36.423 INFO - Started SocketListener on 0.0.0.0:5555
09:24:36.426 INFO - Started org.openqa.jetty.jetty.Server@1f4a8824
09:24:36.428 INFO - using the json request : {"class":"org.openqa.grid.common.RegistrationRequest","capabilities":[{"platform":"LINUX","seleniumProtocol":"Selenium","browserName":"*firefox","maxInstances":5},{"platform":"LINUX","seleniumProtocol":"Selenium","browserName":"*googlechrome","maxInstances":5},{"platform":"LINUX","seleniumProtocol":"Selenium","browserName":"*iexplore","maxInstances":1},{"platform":"LINUX","seleniumProtocol":"WebDriver","browserName":"firefox","maxInstances":5},{"platform":"LINUX","seleniumProtocol":"WebDriver","browserName":"chrome","maxInstances":5},{"platform":"LINUX","seleniumProtocol":"WebDriver","browserName":"internet explorer","maxInstances":1}],"configuration":{"port":5555,"register":true,"host":"10.158.96.150","proxy":"org.openqa.grid.selenium.proxy.DefaultRemoteProxy","maxSession":5,"role":"node","hubHost":"localhost","registerCycle":5000,"hub":"http://localhost/184.73.224.98:4444/grid/register","hubPort":-1,"url":"http://10.158.96.150:5555","remoteHost":"http://10.158.96.150:5555"}}
09:24:36.430 INFO - Starting auto register thread. Will try to register every 5000 ms.
09:24:36.430 INFO - Registering the node to hub :http://localhost:-1/grid/register
09:24:36.446 INFO - couldn't register this node : Error sending the registration request.
09:24:41.479 INFO - couldn't register this node : Hub is down or not responding: Hub is down or not responding.

我已经尝试过: http://rationaleemotions.wordpress.com/2012/01/23/setting-up-grid2-and-working-with-it/ https://code.google.com/p/selenium/wiki/Grid2
Understanding Selenium Grid2 implementation running on EC2

但是当我必须在远程ubuntu机器上注册节点时,这些在初始步骤失败。

1 个答案:

答案 0 :(得分:0)

你的错误是什么并不完全清楚。这可能有助于您使用ssh隧道进入无头Xvfb盒子的位置

在远程服务器上安装任何缺少的软件包之后

Xvfb -screen 0 800x600x16 -ac &
export DISPLAY=:0
xterm &
java -jar selenium-server-standalone-2.35.0.jar -role node  -hub http://mywebsiteip:4444/grid/register

然后从您自己的计算机隧道到您的服务器

ssh -l kaltpost -L 5900:localhost:5900 mywebsiteip 'x11vnc -localhost -display :0'

会等待,所以在另一个终端

vncviewer localhost&

这一切都取自http://gpio.kaltpost.de/?page_id=84

++编辑 我刚刚看到你用主机的ip启动你的selenium服务器,当你把测试连接到它时,这需要是localhost然后是mywebsite id