running QTP from vbs and runas

378 views
Skip to first unread message

Vasil_Panushev

unread,
Sep 26, 2008, 8:33:03 AM9/26/08
to QTP - HP Quick Test Professional - Automated Software Testing
Hi

I have a strange issue with QTP when executed with the windows runas
command.

My scenario is following:

1. A java tool generates a configuration XML and a vbs script for a
QTP test case
2. Then it launches the vbs script
3. The vbs script launches QTP and runs a test
4. Go to 1 and create another configuration/script and launch again

The issue appears when I want to start QTP (and all apps launched from
inside) with a different user by using the "runas" command of Windows.
To achieve this I run the java tool with runas and give the
credentials of a different user. What happens is:

- the java process runs with the "runas" user
- the vbs interpreter process runs with the "runas" user
- (here it starts to be funny) I get two 2 QTP related processes; The
first one is "QTAutomationAgent.exe" which is running with the "runas"
user; the second one "QTPro.exe" runs with the logged on user.
Respectively all browsers started from the test case run with the
logged on user :(


Any idea why does this happen. The QTP launch from the vbs is pretty
standard:
Dim App 'As Application
Set App = CreateObject("QuickTest.Application")
App.Launch
App.Visible = True

Thank you
Vasil

Roman Zilber

unread,
Sep 26, 2008, 9:01:40 AM9/26/08
to Mercu...@googlegroups.com
Does it happen when you start java from command line?

Vasil Panushev

unread,
Sep 26, 2008, 9:20:53 AM9/26/08
to Mercu...@googlegroups.com
I start java from a batch file, that is run with "runas" command.
i.e .something like "runas /user:<credentials> /savecred runjava.bat" and runjava.bat runs the java command

and btw - I use QTP 9.2 (if this matters).

Best regards
Vasil

Roman Zilber

unread,
Sep 26, 2008, 9:48:01 AM9/26/08
to Mercu...@googlegroups.com
As I understand, QTAutomationAgent.exe is not a part pf problem.
Hard to say something specific without looking to Java code and VBscript code. But my wild guess, the problem related to part witch is responsible for running tests one by one. You should have in some place synchronization point "wait for the end of previous test.

If the loop in VBScript, the synchronization is automatic, if the java call to VBScript, you should wait, when a previous process has been died.

Put msgbox "..." in the beginning of vbscript file. And you will see how many vbscipts are running in the same time.

Vasil Panushev

unread,
Sep 28, 2008, 9:36:41 AM9/28/08
to Mercu...@googlegroups.com
I think I ruled out the java tool by just letting it generate the vbs script and then directly running the script with following run-as command:

runas /user:<domain>\<user> /savecred /env "wscript 58.vbs"

Here is the script too:

Dim App 'As Application
Set App = CreateObject("QuickTest.Application")
App.Launch
App.Visible = True

App.Test.Settings.Launchers("Web").Active = False
App.Test.Settings.Launchers("Web").Browser = "IE"
App.Test.Settings.Launchers("Web").Address = "http://newtours.mercuryinteractive.com"
App.Test.Settings.Launchers("Web").CloseOnExit = True
App.Test.Settings.Launchers("Windows Applications").Active = True
App.Test.Settings.Launchers("Windows Applications").Applications.RemoveAll
App.Test.Settings.Launchers("Windows Applications").RecordOnQTDescendants = True
App.Test.Settings.Launchers("Windows Applications").RecordOnExplorerDescendants = False
App.Test.Settings.Launchers("Windows Applications").RecordOnSpecifiedApplications = True
App.Test.Settings.Run.IterationMode = "rngAll"
App.Test.Settings.Run.StartIteration = 1
App.Test.Settings.Run.EndIteration = 1
App.Test.Settings.Run.ObjectSyncTimeOut = 20000
App.Test.Settings.Run.DisableSmartIdentification = False
App.Test.Settings.Run.OnError = "NextStep"
App.Test.Settings.Resources.DataTablePath = "<Default>"
App.Test.Settings.Resources.Libraries.RemoveAll

App.Folders.RemoveAll

App.Folders.Add("C:\develop\ngsso\saml2.tests.qtp\ApplDev_stream\src\testtool\..\_saml2~qtp\tests")
App.Folders.Add("C:\develop\ngsso\saml2.tests.qtp\ApplDev_stream\src\testtool\..\_saml2~qtp\tests\Repository")
App.Folders.Add("C:\develop\ngsso\saml2.tests.qtp\ApplDev_stream\src\testtool\..\_saml2~qtp\tests\Reusable actions")

App.Test.Settings.Web.BrowserNavigationTimeout = 60000
App.Test.Settings.Web.ActiveScreenAccess.UserName = ""
App.Test.Settings.Web.ActiveScreenAccess.Password = ""

' load and execute test / create the run results options object
Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions")

' open QTP test file
' TODO - path to the location of the test case to be executed
App.Open "C:\develop\ngsso\saml2.tests.qtp\ApplDev_stream\src\testtool\..\_saml2~qtp\tests\QTPTests\KerbWindows_nameID"

' Set the results location
' TODO - path to the folder where the results will be stored
qtResultsOpt.ResultsLocation = "C:\develop\ngsso\saml2.tests.qtp\ApplDev_stream\src\testtool\.\temp\results"

' Run the test
App.Test.Run qtResultsOpt

' release the run results options and application object
Set qtResultsOpt = Nothing
Set App = Nothing


I get the same effect - the QTPro.exe runs with the logged on user, not with the runas user.

Best regards
Vasil

Roman Zilber

unread,
Sep 30, 2008, 9:25:36 AM9/30/08
to Mercu...@googlegroups.com
Sorry, only now I've gotten what you are asking about (my bad). I don't know the answer, I think you are expecting form Windows OS unix style of behavior :)

Roman

Vasil Panushev

unread,
Oct 2, 2008, 6:34:14 AM10/2/08
to Mercu...@googlegroups.com
Well actually Windows OS seems to be ok - child processes are started with the correct user but the ws script interpreter seems to be buggy :(

Following script:
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = true
IE.Navigate "http://www.google.com"

also creates IE process from the logged on user even if I do runas :(
 
Anyway thanks for the help :)

Reply all
Reply to author
Forward
0 new messages