Runtime error when running tests: TypeError: Cannot read properties of null (reading 'errorMessage') Microsoft Office 365 image

How do you deal with Runtime error when running tests: TypeError: Cannot read properties of null (reading ‘errorMessage’) in your Power Apps Test Studio?

Automated tests

Automated testing in Power Apps can reduce the time to test your app dramatically.

First of all the automated testing in Power Apps is still in preview. About 2 years ago I wrote a post about it, and as the automate testing depends on a preview feature being enabled in your app, we would have to take care when enabling this feature.

Today when I used the automated testing to just confirm that nothing broke as I made some updates, I found that even though my app was working I would get the testing tool to give me a failure.

Runtime error when running tests: TypeError: Cannot read properties of null (reading 'errorMessage')

This error isn’t very clear until you analyze the problem.

One of my steps is failing.

Identifying the issue

The problem here is that I have a Label, in a Gallery. However a label i a gallery can also work. In this case however I have a Label that sits inside a container.

Runtime error when running tests: TypeError: Cannot read properties of null (reading 'errorMessage') Microsoft Office 365 image 2

The above Select however is trying to get the Label from the container. And even though the recording generated the above code. It ignores the container shell that sites around the Label control.

Fixing the issue

If we now try and fix this issue in the Test Studio, we will find out quite quickly that there isn’t a way to get to the Label2 or at least I haven’t found it.

Then I made a slight adjustment to my app. Rather than using a container I used a group instead. Groups and containers aren’t exactly the same but they are sometimes very similar.

Runtime error when running tests: TypeError: Cannot read properties of null (reading 'errorMessage') Microsoft Office 365 image 3

And now my automated test runs successfully.

Avatar for Pieter Veenstra

By Pieter Veenstra

Business Applications and Office Apps & Services Microsoft MVP working as a Microsoft Productivity Principal Consultant at HybrIT Services. You can contact me using contact@veenstra.me.uk.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: