black screenshots
Hi,
I faced with a problem all my screenshots almost black(see an example in the attachments). We run UI tests for pywinauto lib, the tests fails time to time. I've added screenshot creation on failure and collection them into the artifacts.
The problem is all the screenshots almost black, only one small visible piece of the expected image.
I've tried different approaches:
- via PIL (ImageGrab.grab())
- pyscreenshot.grab()
- win32 (hwindc = win32gui.GetWindowDC(hwin)
# srcdc = win32ui.CreateDCFromHandle(hwindc))
All have the same result - black images.
In the other project (also on AppVeyor) a was able to get useful screenshots using PIL.
Please, point me to the solution.
PS. I tried RDP, but could not connect - 104.197.110.30:3389
Thanks in advance
Denis M.
-
scr-testFriendlyClass.jpg
12.9 KB
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
| ? | Show this help |
|---|---|
| ESC | Blurs the current field |
Comment Form
| r | Focus the comment reply box |
|---|---|
| ^ + ↩ | Submit the comment |
You can use Command ⌘ instead of Control ^ on Mac

Support Staff 1 Posted by Feodor Fitsner on 16 Nov, 2015 06:12 PM
I've just fixed RDP script to correctly identify port on those VMs. Please try to RDP again.
What's the URL of other project?
2 Posted by moden.py on 16 Nov, 2015 07:07 PM
Works fine for - https://github.com/pywinauto/SWAPY
Black screenshots for - https://github.com/pywinauto/pywinauto
There are some difference in appveyor.yml. I tried use latest Pillow version and disable os: - Windows Server 2012 section. Unfortunately it did not help.
Thanks for the RDP, trying...
Support Staff 3 Posted by Feodor Fitsner on 16 Nov, 2015 08:53 PM
What's AppVeyor project URL for this repo: https://github.com/pywinauto/SWAPY ?
4 Posted by moden.py on 17 Nov, 2015 06:47 AM
https://ci.appveyor.com/project/moden-py/swapy-pwvh2
It is my fork. The last build has good screenshots in the artifact.
Support Staff 5 Posted by Feodor Fitsner on 17 Nov, 2015 07:48 PM
The account has been moved to a new environment - there might be some differences.
Can you run swapy build once again to generate screenshots?
6 Posted by moden.py on 17 Nov, 2015 08:55 PM
Feodor, many thanks. The black screenshot now in SWAPY. ;-)
https://ci.appveyor.com/project/moden-py/swapy-pwvh2/build/1.0.134
Suppose, for testing, you have switched the environment like for pywinauto.
Support Staff 7 Posted by Feodor Fitsner on 17 Nov, 2015 09:29 PM
Well, actually this is the only environment we are going to have for OSS from now :-)
But what's the difference? Does it expect some drivers or what? Have you tried looking via RDP?
8 Posted by moden.py on 18 Nov, 2015 05:02 PM
I suppose something has changed in the new environment. For example, Desktop Window Manager (DWM) some functions has been changed in Windows 8.1 it may cause the problem in Windows Server 2012 R2 we using.
RDP works fine. More, the problem does not affect when I connect a RDP session.
It seems like some driver sees that there is nobody to draw a picture. )))
Please, take a look at the attachment, maybe it is a clue. I've not seen that table while was connecting by RDP.
9 Posted by moden.py on 18 Nov, 2015 07:04 PM
send again
Support Staff 10 Posted by Feodor Fitsner on 18 Nov, 2015 07:20 PM
That attachment looks OK to me - this is, actually, what you should see when logged in via RDP.
11 Posted by rami.abughazale... on 26 Nov, 2015 04:36 AM
I'm experiencing similar behavior when running CodedUI tests.
It works only if I connect to RDP before the tests are run.
Most of the CodedUI tests fail if I don't connect to RDP and the screen is just black.
This wasn't happening a month ago.
I'm wondering if there are some power configuration settings, display settings, or screen saver settings that need to be turned off.
12 Posted by rami.abughazale... on 26 Nov, 2015 08:38 AM
Here is an example log file that contains a screenshot:
https://ci.appveyor.com/api/buildjobs/fvqvyklag2w4a11p/artifacts/a2838df1-316d-4c1c-b38c-1c091a3241da_UITestActionLog.html
Notice it is all black, no wallpaper, taskbar, desktop icons, etc.
13 Posted by rami.abughazale... on 26 Nov, 2015 06:19 PM
Here is an example log file that contains what I expected screenshots to look like:
https://ci.appveyor.com/api/buildjobs/jfaaa3dtequwi4ah/artifacts/80d4a023-7495-4a95-92e8-78d1229aca3c_UITestActionLog.html
That test was run and log created while logged into the build server using RDP.
Support Staff 14 Posted by Feodor Fitsner on 02 Dec, 2015 01:12 AM
Hi guys,
If you are willing to help with solving "black screenshots" problem on OSS environment I have a deal for you! :)
Whoever solves this problem first will get a free one-year subscription to AppVeyor Pro plan ($590 value).
Please drop me a message if you'd like to participate.
Your help is really appreciated!
15 Posted by rami.abughazale... on 02 Dec, 2015 01:31 AM
Hi Feodor, I'm willing to try to resolve this issue.
Are there any additional debugging tricks/access I can use to help resolve this issue?
Thank you.
Support Staff 16 Posted by Feodor Fitsner on 02 Dec, 2015 01:34 AM
Great, thank you for willing to help with that!
I've moved your account to Pro environment. Now, without operating system selected builds will be run on Pro environment and to run on OSS environment select, say, "Visual Studio 2013" OS image.
These are instructions on how to access build workers via RDP: http://www.appveyor.com/docs/how-to/rdp-to-build-worker
Let me know if you have any questions.
17 Posted by rami.abughazale... on 02 Dec, 2015 05:39 AM
Thank you.
After some investigation, it seems the issue may be related to file integrity levels.
In my case, it is specifically on the TestResults directory, where the tests files are, within the clone directory.
Previously, to circumvent the "Open File - Security Warning" dialog that appears (and requires user input) when launching exe files from within the TestResults directory, I had to run the following before the tests are run:
icacls TestResults /setintegritylevel (CI)(OI)Low
But for some reason, now I have to run the following:
icacls TestResults /setintegritylevel (CI)(OI)Medium
For reference, the "Open File - Security Warning" dialog can also be circumvented on a larger scope by launching Internet Explorer > Tools > Internet Options > Security > Internet > Custom level... > Launching applications and unsafe files > Enabled (not secure).
However, now when opening HTML files within the TestResults directory, I get the "Internet Explorer restricted this webpage from running scripts or ActiveX controls." warning message which was not happening previously, when the file integrity level was set to Low, and the HTML files had the appropriate "Mark-of-the-Web" (MOTW), <!-- saved from url=(0016)http://localhost -->
Thank you.
18 Posted by rami.abughazale... on 03 Dec, 2015 08:06 AM
Has anyone else encountered this issue?
Can this issue still be reproduced?
Which project can I fork and test with to reproduce the issue?
Thank you.
19 Posted by moden.py on 03 Dec, 2015 09:51 AM
Hi Rami,
I am still see the problem.
Here is today's try - https://ci.appveyor.com/project/moden-py/swapy-pwvh2/build/1.0.138
You may try to fork from https://github.com/moden-py/SWAPY/tree/dev
Commit d6f6baf102eac217e6b1497e2b1b8d4d12c0344d generates the black screenshots.
Thanks
20 Posted by rami.abughazale... on 03 Dec, 2015 08:06 PM
Thank you, moden.py, I had to explicitly set the build to use the Operating System labeled "Visual Studio 2013" in order to reproduce the issue.
When the build was set to use "Windows Server 2012 R2" or "Visual Studio 2015", I was not able to reproduce it.
Also, trying to set the build to use "Previous Visual Studio 2013" will also cause black screenshots.
Support Staff 21 Posted by Feodor Fitsner on 04 Dec, 2015 01:32 AM
Hey guys,
Looks like I've got something! Take a look at these build results: https://ci.appveyor.com/project/FeodorFitsner/swapy/build/1.0.4
In short, to make UI tests work add this line to your appveyor.yml
installsection:The script downloads FreeRDP client and connects via RDP to localhost thus creating a new RDP session. All build commands following this line will be running in that RDP session.
I'm not yet completely sure how that works, but it works :) Maybe the approach could be further improved/optimized as, for instance, active RDP client adds some CPU overhead to the build worker.
Anyway, give it a try for your builds and let me know how it worked. I'm going to document it.
Btw, there is a "bonus" - you can set desired screen size like that:
22 Posted by moden.py on 05 Dec, 2015 01:54 PM
Hi Feodor,
It does work for me!
Thank you very much.
Indeed, it seems like some optimization disables desktop drawing when nobody attached to the desktop.
The possible slowdown is not a problem (at least now :-)))), so I am marking the issue as FIXED.
Support Staff 23 Posted by Feodor Fitsner on 05 Dec, 2015 04:57 PM
Great, thanks for the update!
- Feodor
24 Posted by rami.abughazale... on 05 Dec, 2015 09:23 PM
Thank you.
I found this related issue / feature request:
https://code.google.com/p/google-compute-engine/issues/detail?id=184
25 Posted by rami.abughazale... on 21 Dec, 2015 06:45 AM
Unfortunately, I'm still having issues even when using FreeRDP and it seems to be directly related to the keyboard.
For example, sometimes a call to Keyboard.SendKeys would cause my coded ui tests to fail unless I'm actually connected using Microsoft's RDP implementation.
Support Staff 26 Posted by Feodor Fitsner on 21 Dec, 2015 09:25 PM
Can you provide a sample of such test?
27 Posted by rami.abughazale... on 22 Dec, 2015 07:33 AM
See the failed tests here:
https://ci.appveyor.com/project/icnocop/cuite-cdb3i/build/tests
The corresponding github project is here:
https://github.com/icnocop/cuite/tree/specs
Thank you.
Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 02:03 AM.