Forum Discussion

Stevan's avatar
Stevan
Contributor
4 years ago
Solved

How can I close an IE Tab during testing

When recording a keyword test, I click and option and it opens a PDF file to view, so once I viewed I closed out the new tab to get to my original tab. Test complete is failing on this step. How can I get it to close an IE tab?

  •         
    def test11():
      Aliases.browser.Page("*", 0).Close()

    assuming that the focused control is on the browser tab that we want to close, the above code should work

4 Replies

  •         
    def test11():
      Aliases.browser.Page("*", 0).Close()

    assuming that the focused control is on the browser tab that we want to close, the above code should work

    • Stevan's avatar
      Stevan
      Contributor

      Do I convert my key test into a script and just copy and paste the code you provided?

  • or you can save the script routine and drag and drop it into your keyword test workspace where you need to perform that action

  • JewelRaynor's avatar
    JewelRaynor
    Occasional Visitor

    The following code will take a browser that is open to Google.com and open a new tab, then nagivate to eyeontesting.com on the new tab, then will close just the google.com tab. Modify for your needs...

    'Browser is open to Google.com

    Browser(''Google'').Page(''Google'').WebEdit(''q'').Set ''eyeontesting''

    Browser(''Google'').Page(''orasi - Google Search'').WebButton(''btnG'').Click

    Browser(''Google'').OpenNewTab

    Browser(''Browser'').Page(''Page'').Sync

    Browser(''Browser'').Navigate ''eyeontesting.com''

    CloseBrowserByTitle ''Google'', true

    Sub CloseBrowserByTitle(title, isregex)

    Set desc = Description.Create()

    desc(''title'').Value = title

    desc(''title'').RegularExpression = isregex

    desc(''index'').Value = ''0''

    While Browser(desc).Exist(5)

    Browser(desc).Close

    Wend

    End Sub