Is there a way to attach multiple screenshots at once?
I am afraid that there is no out-of-box method could meet your requirements.
It only supports uploading one file at a time in Test Runner UI.
Workaround:
You could try to use the Powershell script to run Rest API to achieve it.
Here is the sample:
$files = @("filepath1","filepath2")
For ($i=0; $i -lt $files.Length; $i++)
{
echo $files[$i]
$filename = $files[$i]
$parts = $filename.split("\")
$name = echo $parts[4]
echo $name
$file= [IO.File]::ReadAllBytes("$filename")
$Base64file= [Convert]::ToBase64String($file)
echo $Base64file
$token = "PAT"
$url="https://dev.azure.com/{OrganizationName}/{ProjectName}/_apis/test/Runs/{RunId}/Results/{TestResultID}/Attachments?iterationId=1&api-version=5.0-preview.1"
$token = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($token)"))
$JSON = "
{
`"stream`": `"$Base64file`",
`"fileName`": `"$name`",
`"comment`": `"Test attachment upload`",
`"attachmentType`": `"GeneralAttachment`"
}"
$response = Invoke-RestMethod -Uri $url -Headers @{Authorization = "Basic $token"} -Method Post -Body $JSON -ContentType application/json
}
The powershell script will traverse the file path and upload it to the test result attachment.