Forum Discussion

vgangavarapu198's avatar
vgangavarapu198
Occasional Contributor
10 years ago
Solved

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

  • HKosova's avatar
    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

     

    • emaizler's avatar
      emaizler
      New Member

      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.