Screenshot Test Case Attachment

Hello, I am trying to attach screenshots to test cases, but the files are shown in the orchestrator as attachments, not as screenshots.

I am using this code to create and attach screenshots in a test case:

this.testing.AttachDocument(screenshotPath, tags);

After the test is executed, the file is shown in the orchestrator in the section execution attachments, where I can download it as a PNG file.

It is confusing to me, below the execution attachments section, there is a screenshot section showing an error '!' no job execution media found.

My question is, how can I attach a screenshot in a test case to show it correctly as a screenshot in the orchestrator?

1 Like

Hello @lukas.arv try this instead in your code

string screenshotPath = “path_to_your_screenshot.png”;

this.testing.LogScreenshot(screenshotPath, new string { “AfterStep”, “Validation” });

Cheers

Maybe I am doing something wrong, but in my case, there is no method LogScreenshot on the ITestingService interface..

By checking the interface more deeply, I found this method override:

public bool VerifyExpression(bool expression, string outputMessageFormat, bool continueOnFailure,
    string alternativeVerificationTitle, bool takeScreenshotInCaseOfFailingAssertion,
    bool takeScreenshotInCaseOfSucceedingAssertion)
{
   ...   
}

so maybe I could provide screenshots by calling this code this.testing.VerifyExpression(true, ... true)

is this the only way providing screenshots to the Orchestrator?

Hello,

The issue is that this.testing.AttachDocument() attaches the file as a generic document, not as a native screenshot media. Orchestrator only recognizes specific media attachments in the “Screenshots” section.

Perhaps this is the solution:

  • Use the Right Activity: You must use a dedicated activity from the UiPath Testing package, like a specific Take Screenshot or Log Message configuration intended for Test Cases/Test Manager.
  • Avoid Generic Method: Stop using AttachDocument for visual proof.

Try using a native Testing activity to capture the screen; maybe it will work!

Hey

The correct way to provide screenshots to Orchestrator through the testing framework is to use the VerifyExpression() method like this

this.testing.VerifyExpression(
    true,
    "Screenshot after step validation",
    false,
    "AfterStep_Validation",
    false,
    true
);

Cheers

thanks! I am not happy with the UiPath API making this the only way of posting screenshots, but I can live with that. At least it is possible somehow.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.