Save Image - Object not set to an instance of an object

Hi all

I’ve got an issue where a process does the following:

Takes a Screenshot of a window
Saves the screenshot to a specific filepath

This runs without issue when run through Studio on my laptop but when we run it on a robot session (unattended and not visible) it will throw the Object not set… exception at the Save Image part, implying the screenshot has not been taken (even after a 30 second timeout)

If I log into the robot session and watch the process, it works fine. Which leads me to my question…

Does the Take Screenshot activity need to be in an active, visible session to work? If not, any ideas what could be the issue here? It’s driving me mad!

How are you executing the unattended robot? if via orchestrator I’ve had this issue before and resolved by changing the robot properties to ensure I was not logging in via console. If you are using another mechanism i.e. Windows scheduler then it needs an interactive session to take a screenshot, and this will not work.

Hi @AndyD,

Take screenshot works in unattended mode as well , it will be helpful if you can provide more details like error logs & built sequence.

Are you using community edition?

Thanks for the replies all

@cwedl - Yes using unattended executed through orchestrator. Checked settings and not logging in via console.

@shivagowdavarad - The error message is just:

Save image | Save Screenshot : Object reference not set to an instance of an object.

Meaning, the screenshot has not been taken and the variable is empty. As I mentioned initially, this runs fine on an active session so the activities aren’t the problem

@md.kashif464 - No, we are using the on premise Enterprise edition

Hi @AndyD,

This issue normally occurs when the variable is not initialised (doesn’t have a value). What variable type is your variable? You can try using an Assign before the activity that breaks, like so:

MyVar = ""

This will initialise the variable and give it a blank value

Thanks for the reply.

That assign won’t work as the take screenshot activity needs a variable of type Image and not String.

Any idea how to initialise a new image?

Hey @AndyD,

I’ve not used image variables before. Have a look at this stackOverflow post and see if that is any help. It is for a Java console app but may assist you.

@AndyD can you share the snapshot of the Robot Configuration from Orchestrator?