I am testing a page that has about 25 links of different cities. I want to parameterize it so that my qtp script works for any of the cities.I created a function library and used some descriptive programing.
Set VarLink = Description.Create
VarLink("html tag").value= "A"
VarLink("Class Name").value = Link
VarLink("text").value = Datatable.Value ("VarCity", dtLocalSheet)
Browser("Browser").Page("Greyhound Discovery Pass_3").Link(VarLink).Click 0
I am calling this function in my script andf I have 2 cities in my datasheet.
Error:It just displays the city in the first row on the msgbox which means it's not even going to the second row/city.
Can anyone tell me what is wrong with this?And can anyone tell me how to write a for loop for this so that I don't have to call the function each time?
The Error; your Sub has call to SetCurrentRow(1), so every time you call it the Sub will go to the first row.
If you look in help for "looping" you'll find a few different alternatives for doing loops in your script.
Another thing you should learn about is the Data Sheets and Parameterizing Values. You'll learn that you can add your data to the Action sheet for your action, and you won't need loops because the action gets repeated for each row in the action sheet.
You have created complicated codes, try to create easy and simple.
<font class="small">Code:</font><hr /><pre>
varlink = Datatable.Value ("VarCity", dtLocalSheet)
Browser("Browser").Page("Greyhound Discovery Pass_3").Link("name:="&varlink).Click
end sub </pre><hr />