使用jenkins集成Selenium测试套件的问题

时间:2013-04-24 05:39:03

标签: jenkins selenium-rc

我正在尝试将Jenkins与Selenium集成。我准备了以下命令:

java -jar "D:\CI\TWCP\Selenium plugins\selenium-server-standalone-2.32.0.jar" -htmlSuite *firefox "http://www.google.co.in"  "C:\Users\....\Desktop\Test suites\GoogleTestSuite.html" "C:\Users\.....\Desktop\results.html" -firefoxProfileTemplate "C:\....\Mozilla\Firefox\Profiles\s980v5zn.default"

当我在命令行中执行命令时,它的工作原理非常好。然后我通过Jenkins调用了相同的命令,我收到了以下错误:

    Started by user anonymous
Building in workspace D:\CI\Jenkins\jobs\Google Test\workspace
[workspace] $ cmd /c call C:\Windows\TEMP\hudson600399625489206831.bat

D:\CI\Jenkins\jobs\Google Test\workspace>java -jar "D:\CI\TWCP\Selenium plugins\selenium-server-standalone-2.32.0.jar" -htmlSuite *firefox "http://www.google.co.in"  "C:\Users\N_chandanKumar\Desktop\Test suites\GoogleTestSuite.html" "C:\Users\N_chandanKumar\Desktop\results.html" -firefoxProfileTemplate "C:\Users\N_chandanKumar\AppData\Roaming\Mozilla\Firefox\Profiles\s980v5zn.default" 
Apr 24, 2013 10:54:07 AM org.openqa.grid.selenium.GridLauncher main
INFO: Launching a standalone server
10:54:08.647 INFO - Java: Sun Microsystems Inc. 1.6.0-b105
10:54:08.647 INFO - OS: Windows Vista 6.1 x86
10:54:08.662 INFO - v2.32.0, with Core v2.32.0. Built from revision 6c40c18
10:54:08.756 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
10:54:08.756 INFO - Version Jetty/5.1.x
10:54:08.756 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
10:54:08.756 INFO - Started HttpContext[/selenium-server,/selenium-server]
10:54:08.756 INFO - Started HttpContext[/,/]
10:54:08.787 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler@13c1b02
10:54:08.787 INFO - Started HttpContext[/wd,/wd]
10:54:08.787 INFO - Started SocketListener on 0.0.0.0:4444
10:54:08.787 INFO - Started org.openqa.jetty.jetty.Server@7ced01
jar:file:/D:/CI/TWCP/Selenium%20plugins/selenium-server-standalone-2.32.0.jar!/customProfileDirCUSTFFCHROME
10:54:09.941 INFO - Preparing Firefox profile...
10:54:12.041 INFO - Launching Firefox...
10:54:14.242 INFO - Checking Resource aliases
10:54:37.079 INFO - Checking Resource aliases
10:54:37.079 INFO - Received posted results
GoogleTestCase.html
<a href="GoogleTestCase.html">GoogleTestCase</a></td></tr>
</tbody></table>


10:54:37.297 INFO - Killing Firefox...
Tests failed, see result file for details: C:\Users\N_chandanKumar\Desktop\results.html
10:54:37.921 INFO - Shutting down...
10:54:37.921 INFO - Stopping Acceptor ServerSocket[addr=0.0.0.0/0.0.0.0,port=0,localport=4444]

D:\CI\Jenkins\jobs\Google Test\workspace>exit 1 
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE

result.html显示以下日志失败

info: Starting test /selenium-server/tests/GoogleTestCase.html
info: Executing: |setTimeout | 1000000 |  |
info: Executing: |openAndWait | http://www.google.co.in/ |  |
info: Executing: |setTimeout | 1000000 |  |
info: Executing: |pause | 20000 |  |
info: Executing: |verifyTextPresent | India |  |
warn: currentTest.recordFailure: false
info: Executing: |assertTitle | Google |  |
error: Actual value &apos;Error Message&apos; did not match &apos;Google&apos;
warn: currentTest.recordFailure: Actual value &apos;Error Message&apos; did not match &apos;Google&apos;

如果我运行相同的代码添加 debug 标签,即

java -jar "D:\CI\TWCP\Selenium plugins\selenium-server-standalone-2.32.0.jar" -htmlSuite *firefox "http://www.google.co.in"  "C:\Users\....\Desktop\Test suites\GoogleTestSuite.html" "C:\Users\....\Desktop\results.html" -firefoxProfileTemplate "C:\Users\.....\AppData\Roaming\Mozilla\Firefox\Profiles\s980v5zn.default" -debug

我最后得到以下日志

GoogleTestCase.html
<a href="GoogleTestCase.html">GoogleTestCase</a></td></tr>
</tbody></table>



10:58:56.737 DEBUG - Handled by org.openqa.selenium.server.htmlrunner.SeleniumHTMLRunnerResultsHandler@14b7453
10:58:56.737 DEBUG - RESPONSE:
HTTP/1.1 200 OK
Date: Wed, 24 Apr 2013 05:28:56 GMT
Server: Jetty/5.1.x (Windows Vista/6.1 x86 java/1.6.0
Cache-Control: no-cache
Pragma: no-cache
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Type: text/html
Transfer-Encoding: chunked


10:58:57.002 INFO - Killing Firefox...
10:58:57.018 DEBUG - java.net.SocketException: Connection reset
10:58:57.018 DEBUG - java.net.SocketException: Connection reset
10:58:57.018 DEBUG - java.net.SocketException: Connection reset
10:58:57.018 DEBUG - java.net.SocketException: Connection reset
10:58:57.033 DEBUG - java.net.SocketException: Connection reset
10:58:57.033 DEBUG - java.net.SocketException: Connection reset
Tests failed, see result file for details: C:\Users\N_chandanKumar\Desktop\results.html
D:\CI\Jenkins\jobs\Google Test\workspace>exit 1 
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE

我有jenkins 1.509和seleniumHQ2.32.0

无法弄清楚我是如何得到&#34; java.net.SocketException:连接重置&#34; 在这方面的任何帮助将不胜感激。

谢谢&amp;问候, 的cK

1 个答案:

答案 0 :(得分:1)

要检查问题,我在交互模式下运行了jenkins服务器。当你去services.msc - &gt;时可以看到设置。詹金斯进程 - &gt;属性 - &GT;单击登录选项卡,您可以选择本地系统帐户并勾选“允许服务与桌面交互”。

这使得jenkins以交互方式运行selenium测试,而不是在后台运行。

我可以观察到浏览器无法打开网站。这是通过以下设置service.msc - &gt;解决的。詹金斯进程 - &gt;属性 - &GT;单击登录选项卡 - &gt;选择此帐户并提供您已登录此系统的帐户。