Save Screenshot: Object Reference Not Set To An Instance Of An Object

The error "Save screenshot: Object reference not set to an instance of an object" occurs when running an automation.

Issue Description: The error "Save screenshot: Object reference not set to an instance of an object" occurs when running an automation.

Root Cause: This issue will occur when the Screenshot object (the variable that references the screenshot to be saved) is 'null'. This means that when the activity 'Take Screenshot' is executed, the activity was able to execute but no data was generated (i.e. there was no screen or information to take a screenshot of).

In most scenarios this can happen in two scenarios:

  1. The Desktop GUI is suppressed. This means the computer is not rendering any data for the Desktop GUI. This happens when the screen is locked, the machine is accessed through RDP and the RDP window is minimized, a screen saver is active, or the windows session is in a disconnected state.

    • The windows session can be in a disconnected state when an RDP connection is closed without logging out of the VM. Common cause would be logging into the Robot machine while it is executing and then disconnecting.

  2. The Desktop GUI is active but still initializing.

Resolving/Diagnosing

  1. Try to determine if the above two scenarios apply to the situation. If the automation fails almost immediately, then scenario 2 might apply.

    • In such a case, a screenshot probably would not be helpful.

    • Try making "WaitForReady" as "Interactive" or "Complete", in the "Take Screenshot" activity

    • Try adding a delay
  2. If this is an attended automation, make sure to not lock the screen or if using RDP only minimize the RDP window if the following settings have been applied as mentioned in Executing Tasks In A Minimized RDP Window

  3. If the automation is unattended:

    • Make sure no one is logging into the VM while it is executing (or if they are they need to stay logged in until it is done)

    • Additionally, it is good practice to always logout of the Robot machine after accessing it. This will ensure the Robot service both logs in and logs out when an automation executes. If there is a pre-existing session at runtime, that session will get re-used over and over again. When there is no session at runtime, a login and logout will occur.

    • Run 'gpresults /h %temp%/gpresult.html' from the command prompt as an administrator.

      • Check the results for lock screen policies and screen saver policies.

1 Like

A post was split to a new topic: Getting the [Object Reference Not Set To An Instance Of An Object] error

The command should read: ‘gpresult /h %temp%/gpresult.html’