How to make selectWindow Command in a loop working reliably?


I am working on an automation to loop through some records on a website with tab. Each iteration in a loop I opened a new tab, selectWindow on it and work on it. At the of each iteration, I close the tab with selectWindow tab=CLOSE. This is working fine in the first few iterations. Unfortunately, while working on large number of records, it started to fail randomly at any iteration while selectWindow on the newly opened tab. It looks like the connection between the tab and UI.Vision lost randomly. I searched through the forum and found similar issues reported years ago. I wonder if there is any solution to make this loop and selectWindow working reliably? Any of your suggestion or comment is appreciated and welcome.

Thank you very much!
Best regards,
Jack Wu

It’s a very known thing this, when using selectWindow tab=CLOSE command these problems happen,
I suggest you a workaround, in the browser set 2 tabs always open with a site loaded and then load the sites of your macros only in these 2 tabs and never close and open the tabs but continue to use them without closing them.
Every time you close and open the tabs you risk that ui vision loses control of the tab and the macro fails it happens to me too and it seems like a random problem or maybe due to the slow internet connection but it’s a known bug for years

Thank you for your reply.
Unfortunately, my case cannot open each record into the same tab. Otherwise, I have to ask the website developer to change the way they open a record. It’s annoying that this is a known bug for years, but they don’t have a fix.

I have been using ui vision for 4 years and I can assure you that it is always possible to use the same tabs simply in the case of links that open on a new tab, the link is extracted and loaded with the open command in a tab.
Whenever you use the selectWindow tab=CLOSE command you are at risk of errors so it should never be used as a command.
Opening and closing tabs exposes you to many risks of errors, therefore good automation must avoid this and with the right experience it is possible to find a solution

Thank you for the explanation and pointing out the risk of selectWindow tab=CLOSE command.

My case is a bit complicated. The buttons I clicked to open new tabs are implemented in event handlers which is not simply opening a link but also trigger a list of actions (both at client and server sides). Anyway, I would try to figure out a way to work with the application developer on working around this issue. I am really appreciated for your help.