How to sequentially process multiple tabs in a browser using a loop

I want to open multiple tabs in Microsoft Edge sequentially and display specific web pages, and once all are opened, I would like to process all of those tabs in a loop. However, the titles of the opened tabs are all the same, and the URLs are not unique, occasionally having exactly the same URL. Additionally, the structure of the web pages within each tab is almost identical (I’m opening the same page, but the text I input changes each time I initially navigate to the web page). Because of this, I can’t uniquely identify the UI elements I want to operate on, which is causing me trouble in achieving what I want to do. Could someone please teach me how to implement this? If it’s difficult, I’m also open to opening them as completely different windows instead of tabs. Specifically, here’s how I’m failing:

  1. Open the first tab, enter text → this is OK.
  2. Open the second tab, and when I try to enter text, the first tab becomes the target of the operation, leading to failure.

Hello

You can generally specify the tab position using the idx attribute, so please give it a try.

For example,

"<html app='msedge.exe' title='*' idx='2'/>"

that kind of setup.

However, using idx can make the handling a bit complicated, so it might be better to keep the UiElement of each tab when opening them sequentially and utilize that instead. Also, the window attach mode might be better set to SingleWindow.

Thank you for your response.
Even when tracing back to the parent of the UI element being interacted with, it seems there is no idx attribute that corresponds to the tab order…
I thought structurally that the UI elements within the tabs were nested under each tab, but it appears that’s not the case.
Therefore, obtaining the tabs as UiElements doesn’t seem very meaningful.

If it doesn’t exist, you need to add it. Usually, if it can be uniquely identified by title or URL, the idx is not necessary, so it may not appear. I think it would be good to change the idx values below and check if you can operate the expected browser tab.

"<html app='msedge.exe' title='*' idx='2'/>"

Obtaining the tab as a UiElement doesn’t seem very meaningful.

In this case, if you can identify the target tab regardless of idx, keeping the UiElement for that tab would allow its use in subsequent processes, which means you can implement it in a smarter way.

This time, we had to give up on switching multiple tabs due to different factors, but the fact that I could add the hidden idx attribute from my side was a personal revelation and quite shocking. In fact, I was able to use this technique to solve certain issues in other applications as well, which was very helpful. Thank you!