Screenshot running Playwright test in Azure Functions

Anonymous
2021-10-13T12:16:41.44+00:00

Hello people! I am curious about this guide, but seems that there are no more screenshot after the script has been run. Also, what could be the most advisable way to store screenshots taken from the Playwright scripts, when I define them inside the script? Thank you a lot!

https://github.com/Azure/azure-functions-availability-monitoring-extension/blob/master/src/Demos/ConfigurationAndUsage.md

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,119 questions
0 comments No comments
{count} votes

Accepted answer
  1. Samara Soucy - MSFT 5,051 Reputation points
    2021-10-21T01:47:39.73+00:00

    It looks like this was a preview tutorial which has since been removed, so it is possible that this process will break at some point. In the meantime, it looks like the UI has changed so that while the data is captured it is not being displayed as an image.

    Outputting to blob storage would be the simplest solution.

    Add the additional binding to output.json:

        {  
          "type": "blob",  
          "name": "myOutputBlob",  
          "path": "screenshots/{datetime:yyyy-mm-dd-hh-MM}.png", // I used a container called screenshots in the function app's storage account- update to whatever works best for you  
          "direction": "out"  
        }  
    

    After page navigation, get a screenshot from playwright and add it to that output binding.

            // Open new page  
            const page = await browserContext.newPage();  
              
            await page.goto('https://www.bing.com/?toHttps=1&redig=69CC3FCA85A84B3AAFA1D638964EA2B1');  
            const buffer = await page.screenshot();  
            context.bindings.myOutputBlob = buffer  
      
            // Close page  
            await page.close();  
    
    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2021-10-21T05:26:17.543+00:00

    Thanks Samara. Will try this out!

    0 comments No comments