selectWindow TAB=1 randomly throws an error

I am looping over a list of links.
Open a link as a page, on this new page I click on another link, which results in opening a new tab.
I select this new tab, complete a couple of actions, and close it.

The issue is that selectWindow sporadically throws an error
Line 9: failed to find the tab with locator 'TAB=1'
Any suggestions on what might be wrong?

Opening and closing tabs is a weak point of automation because it can show errors.
The safe solution is to never open links in new tabs but simply copy/store URLs and always open them in the same tab.
Every time a tab is opened and closed there is a risk of errors because ui vision can lose control of the tab and go into error

1 Like

I agree with @newuserkantu - in addition, here is another solution: What you can do this too catch the sporadic error and then rerun this part of the macro.

To do so, you can use the ${!current_tab_number} or
${!current_tab_number_relative} internal variables to check if you are on correct tab. If the tab failed to open, this tab number would be different than usual.

1 Like