Please post your Web Driver questions in official Web Driver forum

Monday, March 8, 2010

Execute QTP Tests from AOM file

Herein I have got Sample QTP - AOM file.
Such sample files are easily available on net but they hard code test path as well as result path.
In this sample file I am going to read test path and results path dynamically from with in driver script, which would make script more portable
Dim qtpApp 'As QuickTest qtpApplication
Set qtpApp = CreateObject("QuickTest.Application")
Dim qtResultsOpt 'As QuickTest.RunResultsOptions ' Declare a Run Results Options object variable
qtpApp.Visible = True
qtpApp.Test.Settings.Launchers("Web").Active = False
qtpApp.Test.Settings.Launchers("Web").CloseOnExit = True
qtpApp.Test.Settings.Run.ObjectSyncTimeOut = 120000
qtpApp.Test.Settings.Run.DisableSmartIdentification = True
qtpApp.Test.Settings.Run.OnError = "Dialog"
qtpApp.Test.Settings.Web.BrowserNavigationTimeout = 60000
qtpApp.Options.Run.RunMode = "Fast"
qtpApp.Options.Run.ViewResults = True
qtpApp.Options.Run.MovieCaptureForTestResults = "Never"
qtpApp.Options.Web.AddToPageLoadTime = 10
qtpApp.Options.Web.BrowserCleanup = True
qtpApp.Options.Run.ImageCaptureForTestResults = "OnError"
'Get path to trunk
sn = Wscript.ScriptName 'Script Name
fn = Wscript.ScriptFullName 'Fully Qualified Script Name
fp = Replace(fn, "\" & sn, "") ' Drive / Folder path
Set fso = CreateObject("Scripting.FileSystemObject")
'Open the test in read-only mode
qtpApp.Open fso.GetFolder(fp).ParentFolder& "\test_scripts\<TestName>", True
'Create the Run Results Options object
Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions")
'Set the results location
timeStamp = FormatDateTime(Now, 1)&" "& Hour(Time) &"-"& Minute(Time) &"-"& Second(Time)
qtResultsOpt.ResultsLocation = fso.GetFolder(fp).ParentFolder& "\results\<TestName>\" &timeStamp
qtpApp.Test.Run qtResultsOpt 'Run the test
Set qtpApp = Nothing
Set qtResultsOpt = Nothing
Set fso = Nothing
Tarun K
Fork me on GitHub