In the company where I do test recording. the test asked if it is possible to select a range of "configurations" from 1 to all en everything between it. So It has be possible to lets say run the test with configuration 1 or 100 or the range 10 till 50 or just All.

The solution I came up with is the following:

' Making sure that reporting is off on Default
Reporter.Filter = 3

'Setting delarations for easier reading
'Declarations used in range selection
Dim Som
Dim Use
Dim UseSt
Dim UseEn

'Range selection :Start

'Check if All the configurations are requested
If Parameter("Start_ConfID") ="All" Then
Start = DataTable("ConfID", dtGlobalSheet)
Last = DataTable("ConfID", dtGlobalSheet)

elseif Parameter("Start_ConfID") <>"All" Then
' Start of looking for if row is in or out of Scope

Start = DataTable("ConfID", dtGlobalSheet) - Parameter("Start_ConfID")
Last = DataTable("ConfID", dtGlobalSheet) - Parameter("End_ConfID")

' Looking if the ConfID is Equal or bigger than the Start Parameter
If Start < 0 Then
UseSt = 2

elseif Start = 0 then
UseSt = 1

elseif Start > 0 then
UseSt = 1
' if there is an value that is not known set an not used value
else Start UseSt =30
End If

' Looking if the ConfID is equal or smaller then End Parameter
If Last < 0 Then
UseEn = 10

elseif Last = 0 then
UseEn = 10

elseif Last > 0 then
UseEn = 20
'if there is an value that is not known set an not used value
else UseEn = 100
end if
'edding both values for setting to correct range
Use = UseST+UseEn
'The only correct answer is 11

Select case use
Case 11
Reporter.Filter = 0
Reporter.ReportEvent micPass, "In range", Use

Case 12
Reporter.Filter = 3
exitaction ' exit this row and start over

Case 21
Reporter.Filter = 3
exitTest ' end of range so stop test

Case 22
Reporter.Filter = 0
Reporter.ReportEvent micDone, "Wrong range", "Range provided is incorrect check if parameters are in the correct positions"

Case else
Reporter.Filter = 0
Reporter.ReportEvent micFail, "Wrong Outcome", "Now range selection can be created with the information provided"
end select

else Reporter.ReportEvent micFail, "Parameter Error","Not used Correct Parameters recheck en re-run test"
End if

'Range selection :End

The Globalsheet has to have an colum with the name: ConfID

in this QTP test are the following parameters declared:

Explanation Script:

The script first checks if the ConfID is equal or bigger then the requested start. afther this the script checks if the ConfID is lower or equal to the requested end ConfID.

Now the outcome of both checks are a number that is counted
the out come is : 11, 12, 21, 22

where 11 is the only correct answer for the range the other are to low or to high. if the answer is to low he stops the action and starts over on a new row of the GlobalSheet. Is the Answer to High he stops the test.

Good luck with the use of this part of script


[Moderator]->EMail id's not allowed in generic post