Switch tabs in browser

Hi everyone,
I have a bot that interacts with a website, when clicking on a button it opens a new tab, but the focus stays on the first tab, I have tried to use attach browser to switch to that new tab using the title but it turns out that both have the same title, and I can’t use use application/browser because the url is dynamic and changes continuously. Please help.

Thanks.

Hi @RPA_NOZAMA

→ Insert another Use application\browser activity after click activity which is directing to new page.
→ Use another Use application\browser and indicate the redirected webpage.
→ Change the properties as below,
→ Open - IfNotOpen
→ Close - IfOpenedbyApp\Browser
→ window attach mode - Application instance.

Check the below image for better understanding,
image

For the first Use application\browser activity change the window attach mode to Single window.

Inside Second Use application\browser activity insert the Ui activities to work on second tab (Redirected window).

Hope it helps!!

Hello, thank you for your answer but I did not understand you well, do I have to use 2 use application/browser in addition to the one I am already using where am I clicking the button that opens another tab? 3 “use application/browser” activities?

regards

You can also retrieve the URL of your new tab. Then go to url and do your activities inside.

How to recover the URL of the new tab if I can’t even get the focus?

Okay @RPA_NOZAMA

Here we are working with only two Use application\browser activities.
First Use application\browser activity you are already, just change the Window attach mode to Single window in properties.

After Click activity Insert the New Use application\browser activity (Second Use application\browser) and indicate the newly opened webpage (new tab). Then change the properties for this Use application\browser activity as below,
→ Open - IfNotOpen
→ Close - IfOpenedbyApp\Browser
→ window attach mode - Application instance.

Inside the Second Use application\browser activity insert the Ui Activities to work on newly opened tab. Then the bot will go to new tab and perform the actions there.

Hope you understand!!

1 Like

but when indicating the new tab in the use application/browser it saves the current url of the tab, and the url changes in different cases in which it is consulted, it has a fixed part but the rest is dynamic.

Okay @RPA_NOZAMA

After indicating the browser for the second use application/browser activity, remove the URL, open the selectors option in the properties and remove the attributes which are changing everytime or use wildcards.

In the properties change the below options,

  • Open → Never
  • Close → If opened by Application/browser
  • Window attach mode → Application instance.

If the URL keep changing it will work.

Hope you understand!!

Hello, it still doesn’t work, I changed everything as you told me, and in the selector I have this set:
"<"html app=‘chrome.exe’ title=‘Market’ url=‘https://market.es/members/disputes/create*’ />
I don’t know how to use the selector very well, I think, the asterisk at the end of the url is what is usually dynamic but I don’t know if that’s right or if something should be changed.

You did it correct… @RPA_NOZAMA

Have you followed the options that I have told in the above post.

You have to remove the URL in the Use application/browser activity.

If possible can you take the screenshot and show me how you have given.

First “Use aplication/browser”

Second “Use aplication/browser”
image

One question, does the second “use application/browser” have to be inside the “do” of the first “use application browser” or does it have to be outside?

Don’t think of tabs as tabs, they’re really separate browser windows. And you attach to browser windows with Use Application/Browser.

when clicking on a button it opens a new tab

Is the URL always the same? Then instead of clicking the button just Use Application/Browser and give it the URL and set it to “always open” and then you’ll be working in the correct browser/tab.

Even if you need to build the URL (ie dynamically use values from variables to make the URL) this is still a good way to do it instead of clicking the button.

new tab using the title but it turns out that both have the same title

There are other properties of a browser besides title.

@RPA_NOZAMA

Use idx=‘2’ in the selector…as the titlw is same it would connect to the second one

Also you can try getting active window and then attach to that

Cheers

Can you give me a confirmation Click activity which is opening a new tab, have you inserted in First Use application/browser activity or second one… @RPA_NOZAMA

If you are insert Click activity which is redirecting to other tab you have to insert in first use application/browser activity.

Hope it helps!!

Yes, I click inside the first use application/browser and then after this I put the second use application/browser

Then it will work… @RPA_NOZAMA

Throwing any error or what is the behaviour of bot in that scenario.

idx should be avoided at all costs. There are better ways to handle this, like using URL in the selector or getting the URL from the button/link and then manually opening it with Use Application/Browser

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.