Black screenshots of watir-webdriver

I use watir-webdriver to navigate my site and capture screenshots in different browsers.

Sometimes screenshots taken in IE have the right size, but are completely painted black. Firefox tests that run at the same time look great.

browser.driver.save_screenshot(screenshot_dir) 

As soon as I remove the desktop to the computer that runs the tests, IE screenshots look good. A little after exiting the remote desktop, the IE screenshot again turns black.

I run these tests on a Windows Server instance running on ec2.

+5
source share
3 answers

Based on your comment that remote access to the machine solves the problem for a while ... turn off the screensaver in this field. I'm not sure how (if at all) the screenshot functions on IE and FF are different, but it's worth the time it takes to verify the changes.

Edit: It still seems to me that the windows / power settings are related to the fact that you are entering the window, it looks like this has an effect, but I don't know what else exactly could be. I tried the programmatic approach below vvv.

+5
source

From what you say, it looks like Windows is automatically locked, as it should. This explains why the screenshots work fine when you delete, and then go black after a few minutes when the splash screen starts and locks your system.

If Windows is locked, the screenshots are darkened. This is a Windows security feature.

I would be interested to know if FF really takes screenshots in a locked system.

+1
source

Here is the code that I use to capture screenshots (Watir-Webdriver, Cucumber). I use remote Windows XP virtual machines for my test fields and have not encountered a problem using Firefox or Internet Explorer.

We found that when viewing a log with a built-in screenshot, it does not work in IE, so you need to use Firefox to view it. It is base64, so there is no 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 
0
source

Source: https://habr.com/ru/post/906595/


All Articles