web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Error handling for clo...
Power Automate
Unanswered

Error handling for close web browser

(0) ShareShare
ReportReport
Posted on by

Hello community, 

 

I have a flow that use action launch new Microsoft edge 2 times. After the flow ends or got any error, I use label to go to error handling and close webbrowser1 and webbrowser2. 

But I found a problem with my flow that if the error happens in between when webbrowser1 is opened but webrowser2 hasn't, yet I will get another error. 

So do you have any idea how I should change the error handing or if there's any way to check whether the webpage is open or not (not using if webpage contains) 

deerzzxdell_0-1705543906978.png

 

I have the same question (0)
  • CU31080729-3 Profile Picture
    502 Moderator on at

    Hi deerzzxdell,

    I am little bit confuse what exactly what you need to say (provide screenshot or explain more) , what i understand if any error come into your process or you want close Edge at end of process then you can used Terminate Process action it can closed your both Webbrowser1 and Webbrowser2

     

    (Note:- if you got your solution you can mark as solution and gives kudos)

     

    Thanks & Regards

    Chetan Ninghot

     

  • deerzzxdell Profile Picture
    on at

    @Chetan_Ninghot 

    thank you for the reply, so here's the code, The first thing I do is launch the edge (1st) and do some action and then launch another edge (2nd). 

    deerzzxdell_0-1705558770517.png

    deerzzxdell_1-1705558913411.png

     

    My problem is when there's an error happen during line 16 populate text field on web page, the flow will jump to label error handling in the picture to get last error.

    deerzzxdell_2-1705559164495.png

     

    In the region error handling, after getting last error into variables, it will close both browsers in line 106 and line 107.  But what happen here is I got an error again at line 106 because there's only 1 browser that got opened. 

    deerzzxdell_3-1705559328187.png

     

    And what I have shown you is sub flow. After this it will go out to main flow to check again whether there's an error during sub flow.  By using the same code of error handling

    deerzzxdell_4-1705559819053.png

     

    I've look through action details in power automate cloud and see the result of each last error. The first on happen because it failed in line 16 

    "value""Failed to write text in form field.",

     

    For another one it failed in line closing web browser because PAD can't find browser2 (not open)

    "localizedName""Error",
            "value""Argument 'BrowserInstance' must be 'Web browser instance'.",
     
    Also after all the flow ended the last error also got overwrite with the second error, it didn't show the what happen in the first place, so i have to go through Desktop flow action details on PA web
  • CU31080729-3 Profile Picture
    502 Moderator on at

    Hi,

    Have you try Terminate process action (select process name is chrome)for closing you browser , it can closed you both browser if its open or its not open this action not through any error.

    if nay error come if you want to stop process instead of going to main flow you can used stop flow action at end the error handling sub flow.

    "value""Failed to write text in form field.", if populate text field action failed you can select proper attribute of this element.

     

    (Note:- if you got your solution you can mark as solution and gives kudos)

     

    Thanks & Regards

    Chetan Ninghot

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    You can add a condition to check if the browser instance is empty. You can check if %Browser2% is not empty (it's empty if it's never been opened) AND if %Browser2.Handle% is not equal to -1 (it would be equal to that if the browser was opened, but was also closed already). If both of these are true, you use Close browser to close it. If either of these is false, you skip the action.

    -------------------------------------------------------------------------
    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

    I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 223

#2
David_MA Profile Picture

David_MA 195 Super User 2026 Season 1

#3
Haque Profile Picture

Haque 167

Last 30 days Overall leaderboard