Custom Search

Friday, June 29, 2012

How to get highest value from given values


Dim num, i, Length1
num=array(100,34,12,98,43,89,49,56)
Length1 = UBound(num) 'Find the length of array
For i= 1 to Length1
   If (num(i)>num(0)) Then
     num(0)=num(i)
   End If
Next
MsgBox num(0)

Monday, June 4, 2012

Loading Actions, Libraries, Repository and Environment files at run time (built-in Functions) without creating QTP object

Actions:
LoadAndRunAction(TestPath, ActionName, [Iteration], [Parameters])

Environment File:
Environment.LoadFromFile("C:\QuickTest\Files\MyVariables.xml")

Repositories:
RepositoriesCollection.Add(RepPath)

RepPath = file://mercury/SORS/MySharedObjectRepository.tsr

Library Files:
ExecuteFile “FilePath”

New feature in QTP11v: LoadFunctionLibrary "FilePath"

PilePath=”c:\Add.vbs”

Friday, June 1, 2012

How to load External Environment veriables at run time in QTP

Dim App ‘As Application
‘ Launch QTP
Set App = CreateObject(“QuickTest.Application”)
App.Launch
App.Visible = True
‘ Load an INI file with user-defined parameters
App.Test.Environment.LoadFromFile “C:\Test_Params\environment_file1.ini”
‘ Set the value of a specific user-defined Environment variable
App.Test.Environment.Value(“newvariable”) = “new value”
As you can see from the example, the Environment variable file is actually an .ini file. The structure would be:
[Environment]
var1=value1
var2=value2



Enable and Disable of Error Handling at runtime in QTP

On Error Resume Next:

On Error Resume Next statement enables the Error handling in the code.If there is error in the code "On error Resume Next" ignores it and continue with next line of code.

On Error Go to 0:
On error got to 0 statement disables error handling we have previiously enabled it by using On Error resume Next.