watir-webdriver black screenshots
Asked Answered
V

3

5

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.

Vulgarity answered 1/11, 2011 at 17:33 Comment(0)
B
5

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.

Blakeney answered 1/11, 2011 at 18:26 Comment(3)
good instincts, it will be interesting to see if that's the issueStylopodium
This issue happens to me if the screen locks, so I'd also throw in ensuring the power settings are set to keep the monitor on.Arezzo
Turning off the screensaver was the first thing I tried... :( Good idea thoughVulgarity
H
1

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.

Heavyset answered 5/11, 2011 at 5:56 Comment(1)
I started running the tests as a service (not logging into the machine for days). The FF tests still work.Vulgarity
B
0

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
Blakeney answered 2/11, 2011 at 23:8 Comment(3)
I have, but I'm not sure about the OP. Win7 64-bit, XP 32-bit.Blakeney
I was referring specifically to the browser. On a 64 bit OS you will usually have a 32 bit version of IE that opens by default, and a 64 bit version you can invoke as well. See Start => All Programs, and look near the top of the list, you should see both versions indicated. My thought was that the 64 bit version might work better to view the file you seem to only be able to see in FFStylopodium
Oh, I see. No, there is no difference there. Aslak discusses the issue in the comments here: #6229571Blakeney

© 2022 - 2024 — McMap. All rights reserved.