Selenium作为Windows服务运行,以获取错误屏幕截图 [英] Selenium run as a Windows service to take screenshots on errors

查看:402
本文介绍了Selenium作为Windows服务运行,以获取错误屏幕截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个基于Selenium RC的自动化网络测试套件,以便在遇到某些错误时截取网页。测试套件是持续集成过程的一部分,技术上由CruiseControl作为 Windows服务运行。

I would like an automated web tests suite based on Selenium RC to take screenshots of pages when some errors are encountered. The test suite is a part of the continuous integration process and technically is executed by CruiseControl running as a Windows service.

调用 selenium.captureScreenshot()方法触发实际的屏幕截图。我注册了一个JUnit RunListener 在任何测试失败时调用它。

The selenium.captureScreenshot() method is called to trigger the actual screenshot. I've registered a JUnit RunListener to call it on any test failure.

问题是截图只是空白文件 - PNG文件完全为黑色。尺寸为1440x900。

The problem is the screenshots are just blank files - PNG files totally black. The dimensions are 1440x900.

当从Eclipse手动运行相同的测试时,屏幕截图是OK的(虽然它们是整个桌面的屏幕截图,而不是浏览器窗口,故事和一个小问题)。所以我猜这个问题的原因是Selenium作为Windows服务运行。

When manually running the same tests from Eclipse the screenshots are OK (althought they are screenshots of the whole desktop not the browser window, but that's a different story and a minor issue). So I guess the cause of the problem is the Selenium being run as a Windows service.

如何在Selenium测试中发生异常时获取页面截图?

How can I have the screenshots of pages taken when exceptions in Selenium tests happen?

使用的软件:


  • Windows 2003 Server

  • Selenium 1.0.1

推荐答案

看起来有一个完全不同的答案。 Windows服务(由 TanukiSoftware Java服务包装器管理)由 wrapper.ntservice启动。 interactive 设置为 false 。将其设置为 true 有帮助。最终屏幕截图包含实际屏幕内容。

Looks like there's a completely different answer. The Windows service (managed by TanukiSoftware Java Service Wrapper) was started with wrapper.ntservice.interactive set to false. Setting it to true has helped. Eventually the screenshots contain real screen content.

请参阅 wrapper.ntservice.interactive 。对包装器代码的分析导致[ SERVICE_INTERACTIVE_PROCESS ]( http://msdn.microsoft.com/en-us/library/ms683502(VS.85).aspx)启动Windows服务时设置的标志。

Consult the wrapper.ntservice.interactive for details. The analysis of the wrapper code leads to [SERVICE_INTERACTIVE_PROCESS](http://msdn.microsoft.com/en-us/library/ms683502(VS.85).aspx) flag being set when starting the Windows service.

这篇关于Selenium作为Windows服务运行,以获取错误屏幕截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆