IF statement working like loop

I am facing some interesting issues, while creating processes.
I’m trying to clear environment before initializing robots (here: closing all Internet Explorer’s browsers).
I am curious, if anybody knows, why If Statement, included in screen shot given below, works as Loop? What I mean is, if plenty of IE browsers are opened, it closes the first one, then waits some amount of time, and then suddenly closes all others browsers.
And this statement works like this only with Browser Applications.

Could anyone tell me please, why is it so? Why this IF works like loop here? Why it doesn’t close only one process, but whole bunch of it?

Selector for Close application activitity:
< wnd app=‘iexplore.exe’ cls=‘IEFrame’ title=’*’ / >


1 Like


It’s not the If that’s acting like a loop it’s the Close Applicaton Activity (you can try this by isolating the close application activity outside the if)

I’m definitely not sure on why this is happening though. I guess since you specify iexplorer as the application and that it detects that there are still iexplorer windows it has a retry mechanism built in.

I’m hoping someone more experienced could shed some light on this mistery :slight_smile:

King regards,

Mandoc Cosmin

1 Like

Single Close Application works like this, IF activity is not necessary here.
It works also with another browser, eg. Chrome.
But if I want to close notepad in a way like this, it only closes 1 window.

So is it some special issue in Close application only for browsers? It’s very convinient though, but if it’ll work always like this?

1 Like

This is because GetProcessByName.Count will give you all the running iexplore.exe and when you are closing the application your selector is not specific to any one opened window that is why it is closing everything in your case.

Though it should not behave like this in either case because even if you want to close iexplore.exe if so many tabs are open it will ask you a question “Do you want to close all the tabs or current tab”. You must be more specific to selector while closing the application.

While if you have them opened in different windows it will successfully close only one window with the help of title attribute.

What do you mean by “you must be more specific to selector” ? I want to close all IE processes. Not only one.

And even if “Do you want to close all tabs?” box pops up, it also closes it all. Without my help. Even IF statement I posted is not necessary. It works the same without IF. Same Close App activity is sufficient.

I don’t agree since I tested out having two different explorer windows with two different titles :

The selector for my close application :


Behaviour : The robot closed the first window (Google) and after a while closed the other one (Bing) even though the title for bing is different.

I think this is why we have two different activities, close tab for browsers so we can close a particular tab and close application will close all the windows of the selected browser.

It does specify on the UiPath Guide that the activity works differently for browser , applications and SAP :


This is something strange because it is working perfectly at my end.

I was having 4 different windows Yahoo, Google, MSN and Bing I selected Bing as title in selector and it worked, it closed the one window which was having title as Bing

I see there must be something wrong I’m doing from my end then.

I’m going to investigate some more :slight_smile:

No that could be an issue for anyone, I have attached a sample, try and see what it does on your machine and let me know

Main.xaml (7.7 KB)

Your code works on my system. I think my error is opening each Internet Explorer manually.

I can still reproduce my error by manually opening two internet explorer, on one going to google the other going to bing and using the selector:


When I use your Close Application Selector, it closes the Google Window and then reopens it with the following message :


Anyway this problem shouldn’t reproduce since normally you open browser using the open browser activity :slight_smile:

1 Like