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.
The selenium.captureScreenshot() method is called to trigger the actual screenshot. I’ve registered a JUnit RunListener to call it on any test failure.
The problem is the screenshots are just blank files – PNG files totally black. The dimensions are 1440×900.
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.
How can I have the screenshots of pages taken when exceptions in Selenium tests happen?
The software used:
- Windows 2003 Server
- Selenium 1.0.1
Looks like there’s a completely different answer. The Windows service (managed by TanukiSoftware Java Service Wrapper) was started with
wrapper.ntservice.interactiveset tofalse. Setting it totruehas helped. Eventually the screenshots contain real screen content.Consult the
wrapper.ntservice.interactivefor 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.