How to close google chrome browser tabs one by one at a time? (776 Views)
Reply
Advisor
pradeepsingh999
Posts: 35
Registered: ‎12-10-2012
Message 1 of 6 (776 Views)
Accepted 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

Frequent Advisor
pavanpy
Posts: 57
Registered: ‎04-11-2013
Message 2 of 6 (754 Views)

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

 

Advisor
pradeepsingh999
Posts: 35
Registered: ‎12-10-2012
Message 3 of 6 (752 Views)

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

Advisor
pradeepsingh999
Posts: 35
Registered: ‎12-10-2012
Message 4 of 6 (742 Views)

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
pavanpy
Posts: 57
Registered: ‎04-11-2013
Message 5 of 6 (733 Views)

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

Advisor
pradeepsingh999
Posts: 35
Registered: ‎12-10-2012
Message 6 of 6 (730 Views)

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

The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.