‘ tested using QTP 9.1 and QTP 9.5
Aren’t data tables great ? they are !
Ever wish you could have total control over what dataRow you start at and how many loops you run ?
You can .. assuming you are willing to step out of the box a bit!
Set the test settings to run only ‘one row’ of your ‘main action’
then you can take control of where to point to get your data.
What about re-useable Actions ?
Re- implement them as inline VBScript Sub Procedures, or create a library of re-useable
VBScript sub procedures linked via your test settings
‘dim custname, custAddress
isRandom=MsgBox (“Answer YES to RANDOMLY pick a starting data row,– NO to CHOOSE the data row to start at–”, 36, “manual Step !”)
If (isRandom=6) Then
randomize
currDataRow=RandomNumber (1,99) ‘ if you have 99 rows of data
Else
currDataRow= inputBox (“Input the data row of the spreadsheet to start at as an integer”, “Row to start data”, 1)
End If
counter= 1
‘ set current data row
currDataRow= 1
DataTable.SetCurrentRow(currDataRow)
counter=1
loopEndCounter =inputBox (“how many rows of data do you want to enter- ie how many loops to run ?”)
‘ OR …
‘loopEndCounter= [some fixed number if you want to do the same every time]
‘ if you need to logon…
‘ login inside the loop or outside of it ? depends on your test and your app
‘ most browser apps will let you logoff and logon as ‘some other test account’
‘ if I am running a test with multiple test accounts, I try to logon inside the loop
‘ …..usually I would not close the initial browser until I exit the bottom of the main loop
‘ re- instantiating the browser-under- test is tricking and doesn’t always work well
‘################################
Do While(counter <= CInt(loopEndCounter)) ‘ start main loop
If (counter > 1) Then
currDataRow= currDataRow +1
End If
DataTable.SetCurrentRow(currDataRow)
custName= DataTable(“custName”, dtGlobalSheet)
custAddress= DataTable(“custAddress”, dtGlobalSheet)
‘etc
‘ msgBox currDataRow
‘ #############################
‘ do your testing here !!!!
‘ logoff
counter= counter + 1
Loop
‘ end man loop
Browser(mySpiffy App Browser).Close
‘ or whatever cleanup steps you need