Ask a Question

How to Close the Tab in browser

SOLVED
vgangavarapu198
Occasional Contributor

How to Close the Tab in browser

I am working on the web applications and i know how to close whole window but not th eperticular tab.

 

For Browser:

 

Set Browser=Aliases.Browser

Browser.BrowserWindow.Close.

 

 

 

For Tab:  ???????

 

 

Please Help...

3 REPLIES 3
Ryan_Moran
Valued Contributor

Browser.BrowserWindow(0).Keys("^[F4]")


''-Praise the sun and Give Kudos.''
HKosova
SmartBear Alumni (Retired)

Ctrl+F4, as in Ryan's solution, closes an active tab. To close another (inactive) tab you can use:

Aliases.Browser.MyPage.Close
' or
Aliases.Browser.Page("http://example.com").Close

 


Helen Kosova
SmartBear Documentation Team Lead
________________________
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️

I have a similar issue. I need to close a tab in IE 11 that contains a PDF doc. As you know IE tabs sometimes behave differently. I tried to apply a VBScript Routine:

 

function CloseIETabWithCaption(Caption)


dim tabs, tmpTab, found, windowCaption
tabs = Aliases.browser.BrowserWindow.commandbar.tabband.ChildCount
for i=1 to tabs-1
Aliases.browser.BrowserWindow.commandbar.tabband.Child(i).WaitProperty Exists,true,1000
windowCaption = Aliases.browser.BrowserWindow.WndCaption
found = aqObject.CompareProperty(windowCaption, cmpContains, Caption)

if found then
Aliases.browser.BrowserWindow.commandbar.tabband.Child(i).Close()

end if
next
end function

 

However sometimes the code closes a wrong tab.

And if I open this PDF in more than one tab, it closes only one.

 

Please help me with a better solution for this issue.

cancel
Showing results for 
Search instead for 
Did you mean: