Ask a Question

How can I close an IE Tab during testing

SOLVED
Stevan
Contributor

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?

4 REPLIES 4
hkim5
Staff

        
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

Best,
Justin Kim

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

hkim5
Staff

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

Best,
Justin Kim
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

 
cancel
Showing results for 
Search instead for 
Did you mean: