Detecting lack of a (rendering) display on Windows

Last edited on

Synopsis

GUI Automation on Windows requires an available “display” in most cases. The “display” is where the desktop and applications can be seen.

The physical monitor/display attached to the computer is usually used to view the “display”.

However, there are a number of cases when the display becomes unavailable:

Other reasons for no display being available:

See Automation on Windows for more information and recommended setup steps to avoid this type of problem.

Symptoms

Detecting lack of a Display

Python

Step 1: Copy display_available.exe into SQUISH_DIR\bin or into any of the folders in the PATH environment variable.

Step 2: Invoke display_available.exe in case of errors:

import os

from remotesystem import RemoteSystem

def main():
    try:
        main_original()
    except:
        res = RemoteSystem().execute(["display_available"])
        if res[0] != "0":
            test.fatal(res[1])
        raise

def main_original():
    startApplication("...")
    #...
test.py

Example log entry when the display is not available:

WARNING:

  Disconnected RDP (Remote Desktop Protocol/Client)
  session found.

  This is usually caused by connecting and then
  disconnecting (or minimizing) an RDP client to a
  (Windows) computer. Once disconnected or minimized
  the user session the lacks a display.



  Lack of a display causes these general problems for
  any GUI automation on Windows:

  1) Applications cannot render their GUI.

     Without rendering the coordinates of GUI elements
     on the screen cannot be determined. These
     coordinates are required for many mouse based
     interactions with applications.

  2) Sending "Window Messages" is paused or hangs.

     Among others, sending Window Messages is required
     for querying the current GUI controls of
     applications.



  To restore the display, log in to the physical console
  (or to a VNC server running as a Windows service, if
  one is installed).

Display not available (Reasons: (Typically) Disconnected RDP session or minimized RDP client.)

Related Information