Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Black screen when taking screenshot with Internet Explorer driver on Windows build server

I am running several automated browser tests with selenium on our build server. There is no problems taking screenshots while running Chrome or Firefox driver, but when running Internet Explorer driver I just get a black screen.

Virtual Machine

Selenium version: 2.53.0 IEDriver: 2.53.0

OS: Windows Server 2012

Browser: Internet Explorer 11

I have gone through all the required configuration in the documentation https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver

I have also tried the third option here: https://lostechies.com/keithdahlby/2011/08/13/allowing-a-windows-service-to-interact-with-desktop-without-localsystem/

I have also enabled service interaction globally: https://msdn.microsoft.com/en-us/library/windows/desktop/ms683502(v=vs.85).aspx

When I remotely access the build server, I can trigger running the tests manually. This works fine. So there must be a problem with our CI(TeamCity) setup interacting with the build server.

I am currently stuck and could need some help ?

like image 631
havheg Avatar asked Oct 31 '22 04:10

havheg


1 Answers

This is the default behavior of Windows. since Internet Explorer is tightly coupled with Windows, it behaves this way but other browsers don't.

In order to have better resource utilization, when running on remote, windows detects that since session is running in remote mode and nobody is watching the screen, it takes away the resources required to show the screen and screen goes black. When you log into the machine, resources to show screen UI are deployed again. Hence, when running in remote mode, since there is no screen being showed, screenshot comes out to be blank.

There are only workarounds, no solution. Workaround:

Workaround 1: Use VNC server for your remote session instead of RDP since VNC keeps the remote session alive. Workaround 2: Add this command to batch file : tscon rdp-tcp#1 /dest:console

It will switch the session to "1" which is active mode. By default it will be running on "0" mode. It will disconnect your session and now you can run your test case.

like image 191
Anchal Agrawal Avatar answered Nov 09 '22 06:11

Anchal Agrawal