Facebook

Course Name Start Date Time Duration Registration Link
No Training Programs Scheduled ClickHere to Contact
Please mail To sudhakar@qtpsudhakar.com to Register for any training

Friday, October 9, 2009

Close latest opened Browser using QTP

Close latest opened Browser using QTP

Dim pTitle

'*********************************************************
'Calling the Function 
Call CloseLatestOpenedBrowser()

Function CloseLatestOpenedBrowser()

Dim oDescription
Dim BrowserObjectList
Dim oLatestBrowserIndex

Set oDescription=Description.Create
oDescription("micclass").value="Browser"
Set BrowserObjectList=Desktop.ChildObjects(oDescription)
oLatestBrowserIndex=BrowserObjectList.count-1

Browser("creationtime:="&oLatestBrowserIndex).close

Set oDescription=Nothing
Set BrowserObjectList=Nothing

End Function

'*********************************************************


____________________________________________________________


Please send your Suggestions and Doubts to my yahoo group http://in.groups.yahoo.com/group/qtpsudhakar

8 comments :

  1. This a very good solution you provided. Thank you very much.

    ReplyDelete
  2. Excellent! Thanks you very much Sudhakar

    ReplyDelete
  3. Superb Code.... Thankyou very much.

    ReplyDelete
  4. I want to know what url my application has opened in Internet explorer. This is not working, if you would help that will be too gratefull.

    ReplyDelete
  5. Use below code. It will open and close the current browser.

    set ie = createobject("internetexplorer.application")
    ie.visible = true
    ie.navigate "URL"

    'Perform your task

    ie.quit
    set ie = nothing

    ReplyDelete
  6. excellent dude.. i have come across this question in interview.. same browser closing using function i need pass the browser creation time number as 3 and it should close the second browser..(using function) can u help me on this...

    ReplyDelete