Overview: I am using a C# Console app to run my power Apps to verify that it is working correctly.
Approach: I'm not using NodeJs but I'll use C# and add it into my devOps pipelines. I assume you have VS Code installed (you need the C# extensions, I have kept my notes at the bottom of the post). I'm using .NET 6 core SDK and the Microsoft.Playwright package. I'm not using any of the .NET testing frameworks to keep it simple.
Tips: Playwright by default use headless browser testing, I want the test to use my local JWT that I have stored against my Chrome browser. If I tell Playwright to use show the browser i.e., headless=false, it logs me in using my cached credentials. You should parameterise the login and store the username/pswd somewhere secure like a key vault.
Code Example:
Replace the C# code in the console as I have done above, and hit F5 (Run>Debug). The test logs me into the Canvas app and returns the Title of the page.
Note: I like the Canvas app testing feature but this is better as I can easily add testing to my CI/CD pipelines, tooling and recording is better and there are more ways I can use the Playwright approach.
Notes for installing Playwright on VSCode to use C#
1. Install VS Code and add the following two extensions
Playwright Post 1 - Overview of E2E testing using Playwright
Playwright Post 2 - Continuously Test/Monitor Canvas apps and website with MFA enabled
Playwright Post 3 - Add App Insights logging inside your Playwright tests
Playwright Post 4 - 6 Min walkthru of Playwright testing with Azure Monitor
Other Posts
Upgrading two C# Blazor web applications and verifying using Playwright - super fast
Mendix - Part 2 - Diving deeper (E2E automation testing of Mendix using Playwright)
Low-code testing with playwright walkthru
Continiously Monitor Apps using Playwright with TS
Testing Canvasa apps with Playwright using C# (rather use TS, it's better)