How to force close a chrome tab?

I used a close tab activity that is working fine but when it tries to close the tab a popup appears that you are going to leave this site and to completly close the tab you have to click leave. How can I bypass that ?

1 Like

Hi @Rohit_Nandwani

Try using Kill process with the process name mentioning!

"Chrome"

Regards

I need to kill a specific tab not all tabs

Hi @Rohit_Nandwani
Use attach browser on the tab you re using and create a out variable for the attach browser

And inside the do of the attach browser use the close tab activity passing the out variable of the attach browser!

Or use the element exists on the particular pop up window if the element exists

then click close to close the popup

Else do nothing @Rohit_Nandwani

Regards

Did same but that popup is not allowing to close the tab untill it clicks on leave.

Hey @Rohit_Nandwani

I guess the popup which you are saying is the site specific I believe right ?

Not something specific to Chrome ?

Kindly confirm

Also, do you want to handle the popup which comes everytime when you close the tab with the site (or) you want to just simply force close the tab?

Thanks
#nK

Force closing tab will work but only the specific one rest tabs needs to remain opened

1 Like

Hi @Rohit_Nandwani

What Nithinkrishna is asking is if the Tab is site specific. If so, you can use a workflow which selects and closes that specific Tab. You could do this by adding a dynamic selector in the Tab Title Anchor, and indicating the X as the element.

Here’s an example full selector for a Click element for the X (Close) image button in Chrome:

image

where strTabTitle is the variable name of the string in the Tab Title.

That should work. I do have another idea for another method but its a bit more complicated but will force close specific tabs, as this method won’t force close tabs per say.

This issue - with multiple tabs can be avoided entirely by opening individual Browser instances for separate processes and passing in/out the UiElement

image

Let me know how you get on.

Kind Regards

1 Like

Yes the site is specific on which that popup is coming but each time i need to close tab for that site only. I just need to close that tab without handling that popup as you can say force close

1 Like

Hi @Rohit_Nandwani,

You can use Send hotkey activity and use the shortcuts CTRL + W on that particular tab. It will close the tab.

Thanks

1 Like

Try @Shikhar_Tandon’s solution.

If it doesn’t work, I will explain the other solution I have in mind

Kind Regards

Already did popup is still there

Ok, next steps is up to you.

First idea (which is using best practices) is using separate Chrome instances for each process. Then, utilizing the UiElement variable of that specific process to Attach Browser, send HotKey ALT + F4.

Second idea is using Chrome’s Task Manager. This shows all the process IDs of each Tab, from there you can use a Kill Process with that specific ID to force close that tab.

You would open the Task Manager via automation with sending hotkey CTRL + M, select the new window, then using a Get Text activity to extract the process ID for a given Task. This will also require using a dynamic selector (if you want to implement any kind of reusability/robustness into your selector and code). You would make the Task name the selector Anchor and the Process ID desired element.

Let me know how you get on

Kind Regards

1 Like

use a Send Hotkey activity with a ctrl + W inside a browser window of the tab you wish to close - make sure your selectors are indicative of that tab only. This will close the tab

This looks spot on @Che Thanks for sharing.

1 Like