Highlighted
Respected Contributor.
Respected Contributor.
4851 views

Running a QTP script on a virtual machine via Windows scheduler

Can anybody help?

 

 I've got QTP 10 application and the QTP script installed on a virtual machine (XP).  I'm running a VBScript via the Windows Scheduler to start QTP, load and run the script in the middle of the night

 

The QTP script invokes IE with correct URL, but fails at the first screen (login) reporting that the object doesn't exist and takes a screenshot, which is just black.  I've got a user account logged into the machine at the time of the run and I've changed the registry setting:

'HKEY_CURRENT_USER\Software\Mercury Interactive\QuickTest Professional\MicTest\SkipEnvironmentChecks to 1

 

If I RDP onto the machine with the same user account and run the VBScript via the scheduler or am logged in when the scheduled job runs, the QTP script runs successfully.

0 Likes
9 Replies
Highlighted
Absent Member.. Absent Member..
Absent Member..

Re: Running a QTP script on a virtual machine via Windows scheduler

When the test runs, is there some RDT connection open to the VM, or is it all happening "behind the scenes?"

 

I have found that QTP tests don't run well, and sometimes don't run at all, on a headless VM. I usually have an RDT connection open on my desktop. It can be minimized. In fact, my desktop can be locked (not logged off).

 

Caveat: I learned this a while ago while using QTP 10 or maybe 9. I haven't tried it with the newer versions. It has just remained my SOP to have an open session to the VM while running tests.

0 Likes
Highlighted
Absent Member.
Absent Member.

Re: Running a QTP script on a virtual machine via Windows scheduler

Same happens to me with a remote desktop connection.

 

I guess if a RDP does not so will the vmware...

 

It comes with the program I am afraid...

0 Likes
Highlighted
Honored Contributor.
Honored Contributor.

Re: Running a QTP script on a virtual machine via Windows scheduler

Not sure if can help, but when I intended to run test via RDP, I often do this;

1. Set registry key to enable QTP run when RDP is minimized

 

For 32-bit operating systems: <HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE>\Software\Microsoft\Terminal Server Client 

For 64-bit operating systems: <HKEY_CURRENT_USER>\Software\Wow6432Node\Microsoft\Terminal Server Client 

(More information of running test via RDP or Citrix can be found in QTP Help) 


2. Run a script that keeps the computer awake, don't lock screen. Following is a sample VBScript that use SendKeys to turn Numlock on/off after a period of time.

 

set WSHELL = Wscript.createobject("Wscript.SHELL")
i=0
' turn numlock on/off every 30 seconds, but should change to another key, it's tricky when user input number
While i<60000
    WSHELL.sendkeys "{NUMLOCK}" 
    WSHELL.sendkeys "^"
    Wscript.sleep 30000
    i=i+1
Wend
set WSHELL = nothing

 

 

0 Likes
Highlighted
Absent Member.
Absent Member.

Re: Running a QTP script on a virtual machine via Windows scheduler

Especially your tip number 2 might even make the black screenshots go away!

 

Thanks HaiTNguyen, i´ll try this whenever I have some time!

0 Likes
Highlighted
Absent Member.. Absent Member..
Absent Member..

Re: Running a QTP script on a virtual machine via Windows scheduler

Can you give more details on how to trigger this script? I already have UFT provision on VM but have issues to stay logged in with configured accont . How do I trigger this script on uft vm box?

Thank you.

0 Likes
Highlighted
Respected Contributor.. Respected Contributor..
Respected Contributor..

Re: Running a QTP script on a virtual machine via Windows scheduler

Hi @HaiTNguyen 

How did you set up the small script on vb to be run on the remote machine? Through Task Scheduler from windows??

Did you create a .bat file with that content?? I am facing the same problem about black screenshots ... after 15 minutes of being disconnected from the remote machone (where I run UFT tests through Azure) ... my tests fails always, some objects are not identified and all the screenshots are black ... If I connect to the machine and disconnect and run the tests within 15 minutes, everything goes well..

Regards,

Diogo Cruz 

0 Likes
Highlighted
Honored Contributor.
Honored Contributor.

Re: Running a QTP script on a virtual machine via Windows scheduler

Hi Diogo,

Regarding your issue of black screen, I think your machine has triggered
screen saver which is blocking all object recognition. So I would suggest
you to do following things:

1. Enable auto login on your VM. This will ensure the VM is always ready
even after a restart.
2. Create a .bat file with the content i posted above, and put it in Start
Up folder. This will ensure the script will be always triggered even after
a restart.

Sorry I can't provide details as I've been moved to Node.js + Mac OS for
automation and not having a Windows system to check it for you.

Please give it a try and let me know if you still having issues.

Regards,
Hai
Highlighted
Respected Contributor.. Respected Contributor..
Respected Contributor..

Re: Running a QTP script on a virtual machine via Windows scheduler

Hi @HaiTNguyen 

Thanks for the information. 

Yesterday I copied the script and created a .bat file. I ran it (double click) but nothing happens .. only happened and close the cmd window (which is normal I think ..) .. however .. I opened task manager searched on Details tab for this process/bat file running but I didn't find .. so I assumed that this script was not running (or is it?).

So, I went to Task Scheduler and create a new task with this batch file .. but I think I did something which I will need to change .. because I've selected Daily and an hour to start the batch file and repeat it every 10 minutes (to avoid the 15 minutes of the lock/screen saver) ... and it worked in fact ... 

However, I will need to change from Daily to "at Startup" .. otherwise if the machine is rebooted ... the batch file will not be triggered anymore ... but as I understand from your point 2 above .. I just need to put the batch file on startup programs? Don't I need to create a task on task scheduler?

Regards,

Diogo Cruz

0 Likes
Highlighted
Honored Contributor.
Honored Contributor.

Re: Running a QTP script on a virtual machine via Windows scheduler

Hi Diogo,

It's strange, that script should run right from the command line or when
you double click on it. It will not show anything and will close the
terminal.

This script has a loop and repeat every 30 seconds for 60,000 times. Mean
that the script will end in 500 hours or approximately 20 days. You can
modify the condition of the loop to something like

While 1=1

to make it run indefinitely.

So as I recall from my memory, I will usually do 2 things:
1. Set auto login
2. Put the script in Start Up folder. You can also use Registry Editor to
modify it following this instruction
https://www.akadia.com/services/windows_registry.html
Remember to put it in
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
A Task Scheduler task should be fine as well. But I find it sometimes it
stuck and the task is rescheduled for the next day and will never run if
not configure correctly. I prefer modifying registry.

Regards,
Hai Nguyen
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.