问题
I am executing the QTP scripts from Virtual mechine. QTP is not able to click on OK button of Window pop-up when VM is minimised.
below is the code
If Browser("name:=.*").Dialog("text:=Message from webpage","nativeclass:=#32770").Exist(50) Then
Browser("name:=.*").Dialog("text:=Message from webpage","nativeclass:=#32770").Activate
Browser("name:=.*").Dialog("text:=Message from webpage","nativeclass:=#32770").WinButton("text:=OK").Click
End If
Virtual mechine OS Is -- Microsoft Windows XP Professional
Can any one help me on this.
回答1:
The behaviour you're seeing isn't specific to virtual machines. Even if you're connected to a physical machine via RDP and the window is minimized QTP will fail to run specific steps. The reason for this is due to the tight integration between RDP and Windows, when the client window is minimized it informs Windows that there is no active display and Windows doesn't pay attention to mouse and keyboard events.
Starting with UFT 11.53 UFT supports running on disconnected RDP sessions. You can activate this feature from Tools → Options → General → Run Sessions (See screen shot)

If you're using an older version of QTP then a workaround to this problem is to use a different remote desktop program which is less well integrated into Windows (e.g. RealVNC). Thus Windows will keep responding to QTP's simulated mouse and keyboard events even if the client's window is minimized.
来源:https://stackoverflow.com/questions/22814903/qtp-is-not-able-to-click-on-ok-button-of-window-popup-when-the-vm-is-minimised