.netqtpswfobjecthp-uft

UFT hangs after "Press" method


I have an issue with my script.
Here is my script:

SwfWindow("swfname:=MDIMain").SwfObject("swfname path:=;MDIMain").SwfWindow("swfname:=ActiveReportPreview").SwfObject("swfname:=Viewer1").SwfToolbar("micclass:=SwfToolbar").Press 2
SwfWindow("swfname:=MDIMain").Dialog("text:=Print").SwfButton("text:=&Print").Click

This code suppose to:

  1. Click on "print" icon -> "Print" dialog opens
  2. Click on "Print" button on the "Print" Dialog.

But after first line, UFT hangs and doesn't proceed to the next line.

What could be the solution?

P.S. when I close the "Print" dialog manually, UFT works fine again. I'm using UFT version 11.5.


Solution

  • Try highlighting the object first, and see if UFT can actually see this object. This is how I'd write the code:

    Set myobj = SwfWindow("swfname:=MDIMain").SwfObject("swfname path:=;MDIMain").SwfWindow("swfname:=ActiveReportPreview").SwfObject("swfname:=Viewer1").SwfToolbar("micclass:=SwfToolbar")
    myobj.Press 2  '//not entirely sure if this line will work, but modify if needed
    wait 2 '//give it the time to sync
    If SwfWindow("swfname:=MDIMain").Dialog("text:=Print").Exist() Then
       SwfWindow("swfname:=MDIMain").Dialog("text:=Print").highlight()
       SwfWindow("swfname:=MDIMain").Dialog("text:=Print").SwfButton("text:=&Print").Click  
    End If