I have a webpage which is in table format. It has five columns. I need to check whether two of the five columns are sorted or not. How can i extract the two columns from the webpage for the sorting process in QTP?
Have you tried using a Browser().Page().WebTable().GetCellData(row,col) call?
If you're sorting, you could load the values into an array which should make it a bit easier.
<font class="small">Code:</font><hr /><pre>Dim colA(),colB()
totalRows = Browser("<yourBrowser>").Page("<yourPage& gt;").WebTable("<yourtable>").RowCount
ReDim colA(totalRows), colB(totalRows)
For x = 1 to totalRows
colA(x) = Browser("<yourBrowser>").Page("<yourPage& gt;").WebTable("<yourtable>").GetCellData(x, <firstcolumn>
colB(x) = Browser("<yourBrowser>").Page("<yourPage& gt;").WebTable("<yourtable>").GetCellData(x, <secondcolumn>
Next </pre><hr />
A good rule of thumb is to never measure with your thumb.
How can I add the webtable to the repository during recording? Because if I click on the table it shows up as Browser("dev").Page("dev").WebElement("WebTable"). Click
Add it to the OR manually. Click on Add object and click inside the table. Then from the object hierarchy choose the first WebTable for adding.
Buy the NEW QTP Descriptive Programming Unplugged Book
** Download QTP Unplugged 2nd Edition eBook for FREE **
Thanks for the above info.
How do I check the values in the array which I have retrieved from the webtable?
Compare each consecutive element of the array and make sure they are in order (either increasing or decreasing).