views:

260

answers:

2

I'm using QTP 10 together with VMWare to test a Siebel Application. I'm executing the following code to click on a Save button.

Browser("Siebel").Dialog("Filedownload").WinButton("Save").Click

The code works perfectly fine when I'm connected to the VM via Remote Desktop.

On the other side, when I'm starting the QTP test through the scheduler, without having a Remote Desktop connection, the code above fails without any error message. The WinButton is simply not clicked.

Any idea?

+3  A: 

QTP can't interact with a locked desktop, that's why it'll only work for you when logged in interactively either locally or over RDP. It's a well known limitation of QTP, most automation engineers go through this pain at some point. :)

To be more specific, it can't interact with Win32 objects (can't think of a better way of putting it), so it'll interact with basic browser controls on a locked desktop no problem, but browser popups and Windows applications can't be interacted with in those circumstances.

I strongly recommend (if your system policy allows) that you install something like UltraVNC or another VNC variant to interact with your remote machines. That way you can leave the remote machine's desktop logged on and active at all times. Since it's a VM that shouldn't cause you any major security problems either. Make sure you turn off any screen savers and don't auto-lock the desktop too. QTP should work just fine for you if you do that.

Xiaofu
+3  A: 

Just to add from my experience.

In some companies I worked for I couldn't change screensaver or standby settings due to security policy. A PC was bringing up screensaver during long synchronization periods (like generating really big report), and execution was broken.

To avoid that I created simple "Anti Sleep" function that slightly "moves" mouse every 5 minutes. http://automation-beyond.com/2009/08/18/anti-sleep-function/

Private Const SleepTime_Max = 300 ‘ 5 minutes
Public Function AntiSleep()
Dim iter
Dim objTimer
Dim objDeviceReplay
Dim intTimeElapsed

 Set objTimer = MercuryTimers(“AntiSleep”)
 intTimeElapsed = CInt(objTimer.ElapsedTime/1000)

 If intTimeElapsed = 0 Then
  MercuryTimers(“AntiSleep”).Start
  Exit Function
 End If

 If intTimeElapsed < SleepTime_Max Then
  Exit Function
 End If

Set objDeviceReplay = CreateObject(“Mercury.DeviceReplay”)

 For iter = 100 To 110
   objDeviceReplay.MouseMove iter,300
 Next

MercuryTimers(“AntiSleep”).Start

Set objDeviceReplay = Nothing

End Function

Example of using it in a custom synchronization function: http://automation-beyond.com/2009/08/20/gui-object-synchronization-custom-function/

Thank you, Albert Gareev

Albert Gareev
Thanks, this worked for me, but I had to use "objDeviceReplay.MouseClick 100, 200, 0", since a MouseMove only did not keep the VM connection awake.
Federico Elles
Oh, yes, that's absolutely correct, if it's under remote connection you have to click too (If it's on the regular desktop moving only is enough).I just do not have clicking as a default action in a sync loop because sometimes clicking might trigger something you wouldn't want.But in an upper level sync loop I have a codepiece periodically clicking on the titlebar of the window which is generating report or doing some other thinking stuff. Thanks.
Albert Gareev