5
votes

I'm using watir-webdriver to navigate around my website and grab screenshots in different browsers.

Sometimes the screenshots taken in IE turn out the right size, but colored entirely black. The firefox tests that get run at the same time look fine.

browser.driver.save_screenshot(screenshot_dir)

Once I remote desktop to the computer running the tests the IE screenshots look okay again. A little bit after leaving remote desktop the IE screenshots go black again.

I'm running these tests on a instance of Windows Server running on ec2.

3

3 Answers

5
votes

Based on your comment that remotely accessing the machine resolves the problem for a little while... disable the screensaver on that box. I'm not sure how (if at all) the screenshot functions on IE and FF differ, but it's worth the time it would take to test the change.

Edit: I still feel like it's windows/power setting related as you logging into the box appears to have an effect, but I don't know what else specifically that could be. I tried a programmatic approach below vvv.

1
votes

From what you are saying, it sounds like the Windows system is automatically locking, like it should. This would explain why screenshots work fine when you remote in, and then go to black several minutes later when the screensaver kicks in and locks your system.

If the Windows system is locked, screenshots are blacked out. This is a Windows security feature.

I would be curious to know if FF really does do screen captures on a locked system.

0
votes

Here's the code I'm using to capture screenshots (Watir-Webdriver, Cucumber). I use remote Windows XP VMs for my test boxes, and have not encountered the issue using Firefox or Internet Explorer.

We did find that when you view the log with the embedded screenshot, it does not seem to work in IE - so you have to use Firefox for viewing. It's base64, so there doesn't seem to be a logical reason for this.

After do |scenario|
   if scenario.failed?
      encoded_img = @browser.driver.screenshot_as(:base64)
      embed("data:image/png;base64,#{encoded_img}", 'image/png') 
   end #
end