Micro Focus QTP (UFT) Forums

Full Version: IE Dialog Box, Print
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have a website with an input button named Print. It opens a page which then fires off a Print dialog box via javascript using window.print();. My problem is I have not been able to automatically close it. Does anyone have any experience with this? My code is the following:

Code:
Browser("title:=(.*)Print(.*)").Dialog("regexpwndtitle:=Print").WinButton("text:=Cancel").Click

It says
Quote:Cannot find the "[WinButton]" object's parent "[Dialog]" (class Dialog). Verify that parent properties match an object currently displayed in your application.

I have a Wait command before it that waits for 2 seconds. I'll probably end up changing it to 5 to see if that helps.
Hello,

Please see if the following helps:

Code:
With Dialog( "micclass:=Dialog" )
    If .Exist( 5 ) Then
        .WinButton( "text:=Cancel" ).Click
    End If
End With
Awesome. That did the trick!