Is there a way to distinguish between windows and tabs in the selector, or run a process uninterrupted in a for each parallel?

Hello,

First of all, I apologize for my English, as I understand it very little and I have to rely on Google Translate, which has its limitations.

Does anyone know if there is a way in the selector to distinguish between windows and tabs? Alternatively, is there a way to ensure that a specific sequence is executed continuously within a “for each parallel” loop, without jumping to another parallel branch until that sequence is completed?

Let me explain: I have a process that reads data from an Excel file and stores it in a DataTable. Then, using that data, it accesses a website and, for each row in the DataTable, it enters the data, opens a new tab, and downloads a PDF with a variable name. The process takes about 20 seconds per line. Recently, the maximum number of lines in the Excel file has increased from around 100 to 6000, which has increased the execution time from less than 1 hour to 36 hours.

Therefore, we have decided to parallelize the process and we want to do it with a variable number of parallel branches (with 5 or 6 parallel branches, we hope to reduce the time to around 6 or 7 hours, which is more manageable, although it will depend on the number of lines). To achieve this, we want to use a “for each parallel” loop.

The problem arises when the pdf tab needs to be closed once the document is downloaded, and it always has the same name and URL (just like the original window before entering the data). We distinguish each window using the index in the selector. However, when the data is entered, the title automatically changes, so we have to remove the title from the selector and replace it with an asterisk, because otherwise the indices keep resetting based on the number of windows remaining with that title, instead of specifying which window or tab it is.

Similarly, we could refer to that second tab of each window using the number of tabs plus the number of windows, assuming both are always open. However, being a “for each parallel” loop, we don’t know the number of second tabs that are open at any given time.

I have tried several things, but either it confuses the window or the tab, especially with the indices, or activities like “get active window” also cause confusion. Sometimes another tab opens between the “use application/browser” activity and the start of the “get active window” activity, causing confusion…

I’m not sure if I have explained the problem well or not, I hope I have.

So, is there any immutable or distinct identifier for tabs and/or windows? Or is there any way to force the download and tab closure to happen continuously without jumping to other parallel branches?

Any ideas will be welcome. Thank you very much!

Hi @Roger_Vidal

Have you tried the combination of This Open and Close options. for close as Always. and Open as IfNotOpen.
image

or using the Navigate Browser - close Tab activity once you’re done with downloading
image

Hello @adiijaiin ,

Yes, I have tried both, the first one identifies the tab correctly but fails with the window, and the second one identifies the window correctly but fails with the tab.

Hi @Roger_Vidal

In UiPath, when working with web browsers, you can differentiate between windows and tabs using the “Attach Browser” activity. This activity allows you to target a specific browser window based on its title, URL, or window handle. By using the appropriate properties and selectors in the “Attach Browser” activity, you can ensure that your automation interacts with the desired window or tab.

To ensure that a specific sequence is executed continuously within a “For Each Parallel” loop without jumping to another parallel branch until completion, you can make use of synchronization techniques. UiPath provides several activities that can help you achieve synchronization, such as the “Get Lock” and “Release Lock” activities. By using these activities, you can enforce a mutually exclusive lock on a specific section of your automation, allowing only one branch to execute that section at a time.

Thanks!!

Hi @Nitya1 ,

Hello, Nitya1,

Thank you for the response, but it doesn’t work. I tried using an “attach browser,” but if I put a “use application/browser” activity inside it to use modern activities, it completely ignores that it’s within an “attach browser” scope. And if I use older activities, I don’t know how to pass the browser variable to a click activity, for example. If I don’t pass that variable, it also ignores that it’s within the “attach browser” and relies on its own selector, which also fails.
Furthermore, if I use it exclusively to close the window, how do I indicate the index? Even if I specify the name of the second tab, it always closes the first tab, not the second one that I want to close.
The problem I have is that I have n windows, and the first tab of each window has two names (one before entering the data and another that includes the data after it’s entered), with the same URL. They will open between 0 and n second tabs (depending on the situation) with the same name and URL. Therefore, the name or URL alone is not enough to differentiate the windows, and the index doesn’t allow me to differentiate the tabs.

On the other hand, I searched for the “Get Lock” and “Release Lock” activities, but I couldn’t find them. Are they included in any package?

Thank you.