Micro Focus QTP (UFT) Forums
Unable to close new tab - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Unable to close new tab (/Thread-Unable-to-close-new-tab)



Unable to close new tab - pradeep singh - 03-01-2013

Hi,

I am facing a problem.

In my application,I have to click on a link that open a new tab. As soon as it open a new tab,I have to close this new tab only. But below code does not do this.

'********************************************
Code:
If Browser("CreationTime:=1").Exist(0) Then
  print "present"
Browser("CreationTime:=1").Close
'fncloseBrowser()
  else
  print "not present"

End If
'*******************************

It print "present' in print log but not close the new tab and show error on line "Browser("creationTime:=1").close ". Error is "Object not visible".
And when I click on 'Retry' button of this Run error dialog box and get focus on new tab (by click on new tab) then only it get closed. Unless I dont foucs,it is not get closed .
Please let me the solution for this problem.


RE: Unable to close new tab - pradeep singh - 03-04-2013

Hi ,
(browser("creationtime:="&m).highlight ) statement highlight the browser which is currently visible ,not new one opened in a new tab.

If I manually click/focus on new tab then only it get closed by qtp. So please let me know how to click on new tab if we dont know any webelements on new page.


RE: Unable to close new tab - pradeep singh - 03-04-2013

Hi,
I am still looking for the solution. Please run this code and you will find the same bug which I am facing.Please anybody help me out asap.

Code:
systemutil.Run "iexplore.exe","yahoo.com"
Browser("title:=.*").Sync
Browser("title:=Yahoo! India").OpenNewTab
Browser("title:=Yahoo! India").OpenNewTab
Browser("title:=Yahoo! India").OpenNewTab
Browser("title:=Yahoo! India").OpenNewTab

sTitle="Yahoo! India"
Set oDesc = Description.Create
oDesc( "micclass" ).Value = "Browser"
oDesc( "application version" ).Value = "internet explorer.*"

Set vIE= Desktop.ChildObjects(oDesc)
vIECount=vIE.count
z=vIECount
For m=1To vIECount
z=z-1
    If Browser("creationtime:="&z).Exist(1) Then
        newTitle=Browser("creationtime:="&z).GetROProperty("title")
        If Not (sTitle = newTitle) Then
            Browser("creationtime:="&z).highlight
            Browser("creationtime:="&z).Close
        End If
  
    End If


Next



RE: Unable to close new tab - pradeep singh - 03-05-2013

Hi,
Any reply on above problem. I need solution urgently. Please help me .

Thanks & Regards
Pradeep Singh