Friday 30 December 2022

Testing Power Apps using Microsoft Playwright with C#

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


2. Open the VS Code terminal, create a C# Console app using .NET6, add the reference to the Playwright package, install the headless browsers against you profile (only needed once per machine). 
3. Write and run the tests.  Tip: It's easier to record the code and then add it to the C# console.

Note: It's worthwhile using NUnit as it's much easier to test than doing it the way I've done it here.

Playwright using the NUnit framework:



Tuesday 6 December 2022

Using the OpenAI PowerFx language helper leading into building a Tax chatbot using Power Apps (No model training)

I had some time today, and I've been hearing a lot about OpenAI/GPT-3, so I thought I'd have a look around and wow it's good.  There are so many uses and it's just easy to use.

For instance, Power Apps uses PowerFx which is a simple language that Microsoft had added the "Ideas" are to that helps you build PowerFx code.  Honestly I found it extremely irritating when it was released recently but after reading more on Open AI I to take a closer look and it definitely is a great idea.



Thoughts:  I don't memories code so I feel this is a great tool for citizen and professional developers.  I think it will get a lot of attention and improve over time and become a key part of PowerFX and app development.

More Info:

https://learn.microsoft.com/en-us/power-apps/maker/canvas-apps/power-apps-ideas

OpenAI - Took less than an hour to setup the demo

The Power Platform has a Premium Connector to use the OpenAI API's.  Robin Rosengrun has a demo and built and published a connector. 

I spent some time playing around with the OpenAI GPT-3 API using the "davinci-002" engine in a Power App connector.    

First search data result is correct
This is completely wrong, although HMRC have amended the go live date many times.  I was hoping for "6 April 2024"

The third question result is good - but could be better.