Skip to main content

Adding screenshots to livingdoc using devops blob storage

Comments

2 comments

  • Andreas Willich

    From which test runner are you using the context class? Is this MSTest? I don't think that every testrunner does have an inbuild API that pushes the files to the Azure DevOps results.

    About the ResultId:

    As far as I remember, we don't even have this in the SpecFlow+ Runner, where we implement our own testrunner. So this information is very hard to access. Perhaps we could get it via the Azure DevOps APIs, but not sure.

    0
  • Mortimer, Andrew EXT

    Yes this is with MSTest , code below adds the attachment to the test result in azure devops. Regardless of how the attachment is added (specFlowOutputHelper.AddAttachment(path); also adds it to the result which appears in devops) it looks like the existing azure devops apis could be used to scrape the result, then update the living doc with a link to the correct place?

    var context = scenarioContext.ScenarioContainer.Resolve<TestContext>();

     

    public static void ReportScreenCapture(ScenarioContext scenarioContext, IWebDriver webDriver)
    {
    try
    {
    var context = scenarioContext.ScenarioContainer.Resolve<TestContext>();

    if (context.CurrentTestOutcome != UnitTestOutcome.Passed)
    {
    var screenShotter = ((ITakesScreenshot)webDriver).GetScreenshot();
    var path = FormatScreenFilePath(scenarioContext, $"{Directory.GetCurrentDirectory()}");
    screenShotter.SaveAsFile(path);
    context.AddResultFile(path);
    }
    }
    catch (Exception)
    {
    Console.WriteLine("Error creating screen capture");
    }
    }

    0

Please sign in to leave a comment.

Powered by Zendesk