{"id":41791,"date":"2025-07-18T17:05:32","date_gmt":"2025-07-18T11:35:32","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=41791"},"modified":"2025-07-18T17:05:32","modified_gmt":"2025-07-18T11:35:32","slug":"automating-ui-testing-for-canvas-apps-with-power-platform-test-engine","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2025\/07\/automating-ui-testing-for-canvas-apps-with-power-platform-test-engine\/","title":{"rendered":"Automating UI Testing for Canvas Apps with Power Platform Test Engine"},"content":{"rendered":"<p><img decoding=\"async\" class=\"alignnone size-full wp-image-41807\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/Automating-UI-Testing-for-Canvas-Apps-with-Power-Platform-Test-Engine.png\" alt=\"Automating UI Testing for Canvas Apps with Power Platform Test Engine\" width=\"1925\" height=\"1100\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/Automating-UI-Testing-for-Canvas-Apps-with-Power-Platform-Test-Engine.png 1925w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/Automating-UI-Testing-for-Canvas-Apps-with-Power-Platform-Test-Engine-300x171.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/Automating-UI-Testing-for-Canvas-Apps-with-Power-Platform-Test-Engine-1024x585.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/Automating-UI-Testing-for-Canvas-Apps-with-Power-Platform-Test-Engine-768x439.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/Automating-UI-Testing-for-Canvas-Apps-with-Power-Platform-Test-Engine-1536x878.png 1536w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/Automating-UI-Testing-for-Canvas-Apps-with-Power-Platform-Test-Engine-660x377.png 660w\" sizes=\"(max-width: 1925px) 100vw, 1925px\" \/><\/p>\n<p>Canvas Apps in Power Platform provide a flexible way to build rich, custom user interfaces using a low-code approach. However, as these apps grow in complexity\u2014handling multiple screens, dynamic logic, and business-critical processes\u2014the need for automated, repeatable UI testing becomes critical.<\/p>\n<p>Automated testing is essential to ensure application reliability by consistently validating functionality across different scenarios. It reduces the need for repetitive manual testing, saving valuable time and resources. Moreover, catching defects and regressions early in the development cycle improves overall code quality and accelerates delivery timelines.<\/p>\n<p>This is where the Power Platform Test Engine comes into the picture.<\/p>\n<p>The Power Apps Test Engine, developed by Microsoft, allows developers to automate end-to-end testing for both Canvas and Model-Driven Apps. Using YAML-based test cases and Power Fx expressions, it simulates user interactions such as filling fields, clicking buttons, and verifying outcomes, before any changes are deployed.<\/p>\n<p>This blog provides a step-by-step guide to setting up and using the Test Engine for Canvas Apps, demonstrating how to utilize basic Power Fx queries and .NET to execute automated tests, using a common form submission scenario as an example.<\/p>\n<p><strong>Prerequisites<\/strong><\/p>\n<p>Before you begin, ensure that you have the following prerequisites:<\/p>\n<ul>\n<li><strong>Latest .NET <\/strong>installed<\/li>\n<li><strong>PowerShell<\/strong> (v5.1 or later)<\/li>\n<li>Your <strong>Canvas App is published<\/strong> and ready in an environment<\/li>\n<\/ul>\n<p><strong>Step-by-Step Setup Guide<\/strong><\/p>\n<p>Let\u2019s walk through how to install and configure the Power Platform Test Engine:<\/p>\n<h3><strong>1. Create a Test Engine Workspace<\/strong><\/h3>\n<p>Create a new folder on your system where you want to work with the Test Engine. Open the folder in Visual Studio Code and launch the integrated terminal in VS Code.<\/p>\n<h3><strong>2. Clone the PowerApps Test Engine Repository<\/strong><\/h3>\n<p>Run the command below in your terminal to fetch the latest version of the PowerApps Test Engine source code.<\/p>\n<p><em>git clone <\/em><a href=\"https:\/\/github.com\/microsoft\/PowerApps-TestEngine.git\"><em>https:\/\/github.com\/microsoft\/PowerApps-TestEngine.git<\/em><\/a><\/p>\n<p>This will create a new folder named <strong>PowerApps-TestEngine<\/strong> inside your workspace<\/p>\n<p><img decoding=\"async\" class=\"size-full wp-image-41798 aligncenter\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/1Power-Platform-Test-Engine.png\" alt=\"Power Platform Test Engine\" width=\"263\" height=\"113\" \/><\/p>\n<h3><strong>3. Navigate to the Source Folder<\/strong><\/h3>\n<p>Move into the folder where the <strong>Test Engine source code<\/strong> is located.<\/p>\n<p><em>cd PowerApps-TestEngine\/src<\/em><\/p>\n<h3><strong>4. Build the Test Engine Project<\/strong><\/h3>\n<p>Build the PowerApps Test Engine project.<\/p>\n<p><em>dotnet build<\/em><\/p>\n<h3><strong>5. Install Playwright<\/strong><\/h3>\n<p>PowerApps Test Engine uses Microsoft Playwright for simulating browser actions like clicking buttons and typing text. Navigate to PowerApps-TestEngine folder and install Playwrite using below command.<\/p>\n<p><em>.\\bin\\Debug\\PowerAppsTestEngine\\playwright.ps1 install<\/em><\/p>\n<h3><strong>6. Create Folder Structure for Your Tests<\/strong><\/h3>\n<p>Under <strong>PowerApps-TestEngine<\/strong> root directory, create the folders where your test files and configuration will live using below command:<\/p>\n<p><em>cd ..\/..<\/em><\/p>\n<p><em>mkdir tests<\/em><\/p>\n<p><em>cd tests<\/em><\/p>\n<p><em>mkdir canvas<\/em><\/p>\n<p><em>cd canvas<\/em><\/p>\n<p>You should now be inside:<\/p>\n<p><em>PowerApps-TestEngine\/tests\/canvas\/<\/em><\/p>\n<p><em> <img decoding=\"async\" class=\"alignnone size-full wp-image-41797\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/2Power-Platform-Test-Engine.png\" alt=\"Power Platform Test Engine\" width=\"245\" height=\"555\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/2Power-Platform-Test-Engine.png 245w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/2Power-Platform-Test-Engine-132x300.png 132w\" sizes=\"(max-width: 245px) 100vw, 245px\" \/><\/em><\/p>\n<h3><strong>7. Create the <\/strong><strong>json<\/strong><strong> File<\/strong><\/h3>\n<p>Create a file with the name config.json and include the following content:<\/p>\n<p><em>{<\/em><\/p>\n<p><em>\u00a0 &#8220;environmentId&#8221;: &#8220;your-environment-id&#8221;,<\/em><\/p>\n<p><em>\u00a0 &#8220;tenantId&#8221;: &#8220;your-tenant-id&#8221;,<\/em><\/p>\n<p><em>\u00a0 &#8220;installPlaywright&#8221;: false,<\/em><\/p>\n<p><em>\u00a0 &#8220;user1Email&#8221;: &#8220;your-email@example.com&#8221;,<\/em><\/p>\n<p><em>}<\/em><\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-41796\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/3Power-Platform-Test-Engine.png\" alt=\"Power Platform Test Engine\" width=\"565\" height=\"189\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/3Power-Platform-Test-Engine.png 565w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/3Power-Platform-Test-Engine-300x100.png 300w\" sizes=\"(max-width: 565px) 100vw, 565px\" \/><\/p>\n<ul>\n<li><strong>environmentId<\/strong>: The ID of your Power Platform environment where the Canvas app is deployed.<\/li>\n<li><strong>tenantId<\/strong> (optional): Your Azure Active Directory tenant ID.<\/li>\n<li><strong>installPlaywright<\/strong>: Set to false if Playwright is already installed.<\/li>\n<li><strong>user1Email<\/strong>: Email of the user who will run the tests.<\/li>\n<\/ul>\n<p><strong>Note:<\/strong> You do <strong>not<\/strong> need to specify a password here, as authentication uses the saved <strong>StorageState<\/strong>.<\/p>\n<h3><strong>8. Define Test Cases in YAML File<\/strong><\/h3>\n<p>Create a file named <strong>formsubmit.yaml<\/strong>, and add the following test definition:<\/p>\n<pre class=\"lang:css gutter:true start:1\">testSuite:\r\n\r\ntestSuiteName: Form Entry Test\r\n\r\ntestSuiteDescription: Verifies that users can fill and submit a form successfully\r\n\r\npersona: User1\r\n\r\nappLogicalName: your_app_logical_name\r\n\r\ntestCases:\r\n\r\n- testCaseName: SubmitFormTest\r\n\r\ntestSteps: |\r\n\r\n= Screenshot(\"form_load.png\");\r\n\r\nSetProperty(TextInput_Name.Text, \"John Doe\");\r\n\r\nSetProperty(Dropdown_Country.Selected, { Value: \"Canada\" });\r\n\r\nSetProperty(Toggle_Subscribe.Value, true);\r\n\r\nAssert(TextInput_Name.Text = \"John Doe\", \"Verify Name input value\");\r\n\r\nAssert(Toggle_Subscribe.Value = true, \"Verify subscribe toggle is set to true\");\r\n\r\nScreenshot(\"form_filled.png\");\r\n\r\nSelect(Button_Submit);\r\n\r\nScreenshot(\"form_submitted.png\");\r\n\r\ntestSettings:\r\n\r\nlocale: \"en-US\"\r\n\r\nrecordVideo: true\r\n\r\nheadless: false\r\n\r\nbrowserConfigurations:\r\n\r\n- browser: \"chromium\"\r\n\r\nenvironmentVariables:\r\n\r\nusers:\r\n\r\n- personaName: User1\r\n\r\nemailKey: user1Email<\/pre>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-41795\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/4Power-Platform-Test-Engine.png\" alt=\"Power Platform Test Engine\" width=\"1317\" height=\"647\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/4Power-Platform-Test-Engine.png 1317w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/4Power-Platform-Test-Engine-300x147.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/4Power-Platform-Test-Engine-1024x503.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/4Power-Platform-Test-Engine-768x377.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/4Power-Platform-Test-Engine-660x324.png 660w\" sizes=\"(max-width: 1317px) 100vw, 1317px\" \/><\/p>\n<p>In the above YAML, SubmitFormTest simulates a user filling out and submitting a form. It sets the Name to &#8220;John Doe&#8221;, selects &#8220;Canada&#8221; from the Country dropdown, and turns on the Subscribe toggle. The test then verifies these values with assertions and clicks the Submit button. Screenshots are captured at key steps\u2014before filling, after filling, and after submission\u2014to validate the process visually.<\/p>\n<h3><strong>9. Create a PowerShell Script to Automate the Test Run<\/strong><\/h3>\n<p>Create a file named run-tests.ps1 with the necessary code to automate test as shown below:<\/p>\n<pre class=\"lang:css gutter:true start:1\"># Get the current working directory\r\n\r\n$currentDirectory = Get-Location\r\n\r\n# Load config\r\n\r\n$config = Get-Content -Path .\\config.json -Raw | ConvertFrom-Json\r\n\r\n$tenantId = $config.tenantId\r\n\r\n$environmentId = $config.environmentId\r\n\r\n$user1Email = $config.user1Email\r\n\r\nif ([string]::IsNullOrEmpty($environmentId)) {\r\n\r\nWrite-Error \"Environment not configured. Please update config.json\"\r\n\r\nreturn\r\n\r\n}\r\n\r\n# Build the latest version of the test engine\r\n\r\nSet-Location ..\\..\\src\r\n\r\ndotnet build\r\n\u00a0\r\n# Install Playwright if specified\r\n\r\nif ($config.installPlaywright) {\r\n\r\nStart-Process -FilePath \"pwsh\" -ArgumentList \"-Command `\"..\\bin\\Debug\\PowerAppsTestEngine\\playwright.ps1 install`\"\" -Wait\r\n\r\n} else {\r\n\r\nWrite-Host \"Skipped Playwright install\"\r\n\r\n}\u00a0\r\n\r\n# Set credentials as environment variables\r\n\r\nSet-Location ..\\bin\\Debug\\PowerAppsTestEngine\r\n\r\n$env:user1Email = $user1Email\r\n\r\n# Run the test using .NET\r\n\r\ndotnet PowerAppsTestEngine.dll -u \"storagestate\" --provider \"canvas\" -a \"none\" -i \"$currentDirectory\\formsubmit.yaml\" -t $tenantId -e $environmentId\r\n\r\n# Reset to original directory\r\n\r\nSet-Location $currentDirectory<\/pre>\n<p><strong>Note<\/strong>: Make sure to rename formsubmit.yaml with your specific file name.<\/p>\n<h3><strong>10. Run the Script<\/strong><\/h3>\n<p>Inside the canvas folder, execute: <em>.\\run-tests.ps1<\/em><\/p>\n<p>A browser window will launch automatically with the email address pre-filled. You&#8217;ll only need to enter the password manually once. This password is securely stored in the StorageState file for future test executions. After the first login, the tests will proceed automatically without any additional input, as shown in the video below.<\/p>\n<div style=\"width: 665px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-41791-1\" width=\"665\" height=\"374\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/webm\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/Canvas-App-Test-Engine-Form-Entry-Test-Video-1.webm?_=1\" \/><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/Canvas-App-Test-Engine-Form-Entry-Test-Video-1.webm\">https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2025\/07\/Canvas-App-Test-Engine-Form-Entry-Test-Video-1.webm<\/a><\/video><\/div>\n<p>All output from your test runs will be saved in the TestOutput folder located at: %USER_PROFILE%\\AppData\\Local\\Temp\\Microsoft\\TestEngine\\TestOutput<\/p>\n<p>You can review logs, screenshots, and videos of the test execution in this folder to verify results and debug if necessary.<\/p>\n<ol start=\"11\">\n<li><strong> Check Test Cases Status<\/strong><\/li>\n<\/ol>\n<p>Once the test cases have successfully executed, you can view the debug log under the TestOutput folder. This log provides detailed information about the test execution, including any errors or warnings, allowing you to verify that your tests ran as expected.<\/p>\n<h3><strong>Conclusion<\/strong><\/h3>\n<p>Using the Power Platform Test Engine with .NET execution provides a structured, automated way to validate your Canvas Apps before deployment. It supports a variety of user actions and verifications through YAML using basic Power Fx, and helps ensure your app behaves as expected during form entry, submission, and UI transitions.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Canvas Apps in Power Platform provide a flexible way to build rich, custom user interfaces using a low-code approach. However, as these apps grow in complexity\u2014handling multiple screens, dynamic logic, and business-critical processes\u2014the need for automated, repeatable UI testing becomes critical. Automated testing is essential to ensure application reliability by consistently validating functionality across different\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2025\/07\/automating-ui-testing-for-canvas-apps-with-power-platform-test-engine\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":15,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1954,2361],"tags":[1988,3187],"class_list":["post-41791","post","type-post","status-publish","format-standard","hentry","category-canvas-apps","category-technical","tag-canvas-apps","tag-power-platform-test-engine"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/41791","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/comments?post=41791"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/41791\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=41791"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=41791"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=41791"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}