Unified Functional Testing Practitioners Forum
Showing results for 
Search instead for 
Do you mean 

How to close google chrome browser tabs one by one at a time?

SOLVED
Go to Solution

How to close google chrome browser tabs one by one at a time?

Hi,

 

I have successfully close the IE browser and firefox browser tabs one by one (except first one)  but unable to do so with chrome browser.

 

'***********************************************************************************************
Function fnCloseTabExceptOne (browserPropertyApplicationVersion)

On error resume next

Set oDesc = Description.Create
oDesc( "micclass" ).Value = "Browser"

oDesc( "application version" ).Value = browserPropertyApplicationVersion

Set vIE= Desktop.ChildObjects(oDesc)
vIECount=vIE.count

z=vIECount
For m=1To vIECount - 1
z=z-1
    If Browser("creationtime:="&z).Exist(0) Then

            Browser("creationtime:=1").Close
   
    End If


If err.number > 0 Then
message = message & " @@@@@@@Error shown by application is :  " & err.description
icon_flag=0
End If
Next

Set oDesc = Nothing
Set vIE=Nothing
End Function

 

 

'***********************************************************************************************

 

 

 

Could anybody tell me how to achieve this for chrome browser also?

 

Thanks & Regards

Pradeep Singh

5 REPLIES
Frequent Advisor

Re: How to close google chrome browser tabs one by one at a time?

You can try keyboard actions.

example: Browser("...").Type micCtrlDwn+micF4+micCtrlUp.

 

Switching between tabs can be done using Ctrl+Tab and Ctrl+Shift+Tab.

 

+pavan

 

Re: How to close google chrome browser tabs one by one at a time?

Thankx Pavanpy,

 

I will try this solution suggested by you.

 

 

Thanks & Regards

Pradeep Singh

Highlighted

Re: How to close google chrome browser tabs one by one at a time?

Hi,

 

The solution provide by you is not worked for me.  When I use below to close one tab then it close chrome browser completely instead of one tab.

 

objShell.Sendkeys "^{W}"

 

Frequent Advisor

Re: How to close google chrome browser tabs one by one at a time?

Keyboard command to close individual tab on browser: Ctrl + F4

 

Keyboard command to close browser window: Alt + F4

 

Are you using the correct ones?

 

+pavan

Re: How to close google chrome browser tabs one by one at a time?

Thanks Pavanpy,

 

Now it works for me.

 

 

Thanks once again....

Pradeep Singh