question

krii avatar image
0 Votes"
krii asked krii answered

Screenshot running Playwright test in Azure Functions

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
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

SamaraSoucy-MSFT avatar image
1 Vote"
SamaraSoucy-MSFT answered

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();



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

krii avatar image
0 Votes"
krii answered

Thanks Samara. Will try this out!

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.