Open an app in Power Automate Desktop

When you open an app in Power Automate Desktop, and you need to run this Power Automate Desktop flow multiple times it becomes important to handle the multiple instances of your browser. In this post the steps to make this work for you.

The issue to resolve

During testing, if you open a browser every time you run a flow then you will end up with many browsers. Power Automate Desktop however will select one instance. As you develop your desktop flow it will take a browser session, that might not be the same when you run it. Therefore making sure that you only ever have one browser sessions with your app open is a good idea.

In this post I’ll look at how you van make sure that you only ever open one session with a Power App.

Create Subflows

First of all I like to implement the opening of an app as a sub flow. This means that I can call this sub flow over and over again. As part of my automated testing implementation this can be very useful.

Create a subflow in Power Automate Desktop
Create a subflow in Power Automate Desktop

Within my subflow I have created an input parameter AppUrl. This way I can reuse my subflow for multiple projects.

At the start of my Desktop flow I will now check that the AppUrl input parameter has been set or not.

Check if the AppUrl has been set
Check if the AppUrl has been set

In my condition I just need to check if my AppUrl is empty or not. When the AppUrl is Empty I will stop my subflow and report the reason for the failure.

Is the AppUrl empty?
Is the AppUrl empty?

Now that we have an AppUrl, we can Launch the browser using the Launch new Browser action. I use Chrome, but feel free to use a different browser.

I will first try to attempt to find an existing browser that currently uses the AppUrl. My app is a Power App therefore the URL is static.

Attach to an existing browser session
Attach to an existing browser session

Please note that the On error for this step has been set to continue.

On Error settings set to continue
On Error settings set to continue

If however, we don’t have the app open already, then I’ll try to open Chrome again, but this time I’m creating a new browser instance.

Open a new browser
Open a new browser

Then finally in my flow I’m adding a 5 seconds wait time just to make sure that my app has properly started.

The flow to open an app in a browser
The flow to open an app in a browser

Alternative solution

So far I looked at reusing the browser that already opened the app before. Now I could imagine that it might be useful to close that session before opening the app.

If you want to close existing browser sessions then the following flow will help you with this:

Flow control logic in Power Automate Desktop for managing browser sessions based on AppUrl input.
Open an app in Power Automate Desktop 1

Discover more from SharePains

Subscribe to get the latest posts sent to your email.

Related Posts

Leave a Reply

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