Selenium screenshots in VSTS (Azure DevOps)
Asked Answered
G

2

6

According to my searches, it should "just work". This is the best article I found. I've followed the steps, but nowhere in the VSTS (Azure DevOps) interface does it indicate there are any screenshots attached.

I am running this on a privately hosted build server and I have verified the following:

  1. Screenshots are being created and saved to disk
  2. The resulting TRX file (I'm using MSTEST framework) does have a ResultFile reference (a path to the image file)
  3. The TRX file is uploaded to VSTS and I can download it and see that the ResultFile is still in the TRX.

I'm not sure what I am missing in order to get this to work. Any help would be appreciated.

Gneiss answered 15/10, 2018 at 19:39 Comment(2)
Just to double check: are you using the 'Visual Studio Test task' as indicated in the documentation? Have you checked the Artifacts page for them. Maybe adding the 'Copy and Publish Build Artifacts' as indicated would help? I wouldn't expect the files to get automatically uploaded. You indicate in (3) that you see the resultfile being present: is that the link to it or the full image?Brote
@RobBos I am using the "Visual Studio Test" task. The images are not in the artifacts. The task has an option for "Upload test attachments" and it is checked. The resultfile is a string that contains the local path, relative to the TRX file, of where the image would be. Since there's an option to upload attachments, I would expect VSTS to parse this information and upload the images to make the available in the build/release results.Gneiss
K
4

This is a known issue and Microsoft says it is fixed but pending release in a future update: Azure DevOps build test results missing attachments from tests

The work-around in the response notes says to use the option to Rerun failed tests.

Kingdom answered 18/10, 2018 at 16:6 Comment(2)
Thanks for the link. So hopefully it'll "just work" once they release the fix!Gneiss
The bug was fixed, but I had to manually update my agent (since I run in interactive mode) before it started working.Gneiss
T
0

Related tasks for publishing artifacts

Use these tasks to publish artifacts. Is unfortunately well hidden in the docus.

icon Utility: Copy Files By copying files to $(Build.ArtifactStagingDirectory), you can publish multiple files of different types from different places specified by your matching patterns.

icon Utility: Powershell Create a PowerShell Inline Task to delete the files after copy

Remove-Item –path "Path to your screenshots" –recurse

icon Utility: Publish Build Artifacts With this task the will publish as test artifacts

Torsk answered 8/1, 2019 at 9:6 Comment(1)
Thank you for your answer. I wish all responses on SO were this well formatted! In my case, I'm not looking to publish the screenshots as artifacts, they are part of the test results. I have this working now, I had to wait for the bug to get fixed AND then I had to update my Azure DevOps agent.Gneiss

© 2022 - 2024 — McMap. All rights reserved.