Take Screenshot Issue

Team,
I am facing a problem in below screenshot steps

  1. Assign Activity (Path1 = Assets(“Path_Success”).ToString
  2. Take Screenshot Activity (Path1+“Login_Success.png”)
    Getting error in Take Screenshot activity - Please ensure that the path is valid

In log it’s showing the correct path

@Honda

better way to combine path is to use

path.combine(Path1,"Login_Success.png")

can you please try the same

cheers

1 Like

Hi,

You can try the following best practices to avoid errors while using the Take Screenshot activity:

  • Add a short delay before taking the screenshot to ensure the UI has fully loaded.
  • Use a Retry Scope around the screenshot logic to handle intermittent UI issues.
  • Ensure the application window is visible and in focus when the screenshot is taken.

These steps can help improve the reliability of your automation.

Hope this helps!

Hi @Honda

make sure the folder path exists
use path.combine(path1, “login_success.png”) ; instead of path1 + “login_success.png”

Happy AUtomation

Hi @Honda ,

This issue usually happens when the folder path from Assets("Path_Success").ToString doesn’t exist or has invalid characters.

Fix Suggestions:

  • Make sure the directory exists before saving the screenshot:

    If Not Directory.Exists(Path1) Then  
        Directory.CreateDirectory(Path1)  
    End If
    
  • Use Path.Combine(Path1, "Login_Success.png") instead of string concatenation to avoid path issues.

Also, check that there are no special characters in the asset path and that the robot has write permissions.

Hope this helps!

@Honda

try add a slash like below
Path1+“\Login_Success.png”
if you are using c# use double slash

for more robust check before taking the scrennshot whether that folder is exists or not by using folder exists activity

Happy Automation!!

Hi @Honda

Could you please show the value you have saved in Path_success asset?

does it have a slash in the end and you are combining this with file name, it needs to be added there or in the filename.

Just verify, sometimes, simple things like this can be the issue :slight_smile:

You should be using Path.Combine not + for building a path.

Path.Combine(Assets("Path_Success").ToString,"Login_Success.png")

1 Like

I think this might work.
Whenever I pass a value something like - variable + Strings + Variable +… in the variable, I don’t get the expected output.
Using Path.Combine always fix the issue for me.

Hi @Honda

Use Get Asset to get the asset value & pass it to Path1 Variable then if you don’t have the forward (/) at the end of the Path1 you need to add it like this

Path1 + “/LoginSuccess.png”

Hope this helps :slight_smile:

You should be using Path.Combine - it handles the \ for you.

1 Like