我想要一个基于 Selenium RC 的自动化 Web 测试套件,以便在遇到一些错误时对页面进行截图.测试套件是持续集成过程的一部分,在技术上由作为 Windows 服务 运行的 CruiseControl 执行.
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 手动运行相同的测试时,屏幕截图是可以的(尽管它们是整个桌面而不是浏览器窗口的屏幕截图,但这是一个不同的故事和一个小问题).所以我猜这个问题的原因是 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 服务(由 TanukiSoftware Java Service Wrapper 管理)由 wrapper.ntservice.interactive 启动code> 设置为
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 服务运行以截取错误截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!