How to save screen shot to relative path when running on VM


#1

Hello,
I have my project inside a try catch. When an exception is throw I would like my bot to take a screen shot and then email that screen shot to my email address. I currently have the screen shot being saved to the projects relative path. When I run locally though studio my results are as expected and everything works. When I run my project on a VM through orchestrator or the robot tray I get the following error:
“Save image : Object reference not set to an instance of an object.”

Using Studio version 2018.1.2 stable and orchestrator version 2017.1.6547

Steps to reproduce:

  1. Take a screen shot
  2. Save image to relative path
  3. run the following on a VM through orchestrator or robot tray

So my question is the following: Can I save an image to a relative path when running on a VM through orchestrator and if so, how?


#2

Looks like the issue is with Screenshot itself. The output - boomImage is null.

writeline - isnothing(boomImage).ToString to know if the Image has been captured or not.

I think yes, writeline Environment.CurrentDirectory to see where Image is being saved (On Robot machine).

C:\ProgramData\UiPath\Projects\XXXXXXX\lib\net45

Make sure to delete the Image after sending out the email.


#3

Hi @vvaidya
Thanks for the response! You are correct it was an issue with the Take Screenshot. It appears the boomImage variable was never being created.

I had to use log message since I only have robot on the VM.
In the logs I get the correct path for my project: "C:\ProgramData\UiPath\Projects(ProjectName.Number.)\lib\net45 "

After a few hours of head scratching I was finally able to figure out the issue. I was logging into the VM with the same credentials the robot was using to force an error (to test the screen shot email). The robot must have been getting confused when saving the image since there were 2 users logged in with the same credentials (the robot and myself).