Close Browser Window Only if it's Open

Hi everyone!

I’m building an automation which utilizes both Internet Explorer and Chrome. However, sometimes it runs into issues when the browsers are open. So, I added an initial activity to close the browser windows. I decided to add a Repeat activity, set the number of times to 3, and created a TryCatch inside it, to try to close browser windows. I created two identical Repeat activities, one for Chrome, and one for IE.

This works! However, it takes a considerable amount of time to run whenever there are no windows open, or when there is just one Chrome window, etc. Is there a more efficient way to to do this? I would want all Chrome/IE windows to close, but only if they are already open. I’ve tried adding a “Close application” instead of “Close Window” but Chrome reopens with a “This application closed unexpectedly” message, and I wanted to avoid that, especially because I don’t want the any old tabs reopening.

Did we try kill process activity

It’s very simple and straightforward activity

For chrome, mention as “chrome” in ProcessName property of kill process

For internet explorer, mention as “iexplore” in ProcessName property

That should work for sure

Even in REFramework they follow the same approach in INIT application state
Cheers @sidb

You can still use the Close Window activity, but the surrounding attach browser activity timeout should be set to maybe 500 milliseconds, and ContinueOnError should be true. That should speed up the process.

Otherwise you can use “Kill Process” with ContinueOnError set to true. Although you’ll need to change your chrome settings to not reopen windows when unexpectedly closing. Also you’ll need a click activity to close that “Application Closed Unexpectedly” message.

1 Like

Thank you, this helped!!!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.