How to find data in a webtable object?
Question ID: 106262
1
0

I need to figure out some data in a webtable object. I have a Purchase Order Number (PON) and I need to search the webtable till I find that number, then I need to capture the Customer ID Number (CIN) associated with the purchase order. The PON is in column 4 and the CIN is in Column 1. We are using UFT 12.02

Marked as spam
Posted by (Questions: 387, Answers: 66)
Asked on July 30, 2015 9:31 pm
321 views
Answers (1)
1
Private answer

The code below will iterate through each row and cell in the table till it finds the PON that matches strMyPON (the known purchase order number), then it will capture the CIN that is on the same row.

strMyPON = ''12345''

Set MyTable = Browser(''yourbrowser'').Page(''yourpage'').WebTable(''yourwebtable'')

intRows = MyTable.RowCount 'counts the rows in the table

For intCurrentRow = 1 To intRows 'Begin looping through every row in the table
strCIN = MyTable.GetCellData(intCurrentRow,1) 'Capture the CIN value for row intCurrentRow
strPON = MyTable.GetCellData(intCurrentRow,4) 'Capture the PON value for row intCurrentRow

If trim(strPON) = strMyPON Then 'Verifies if I found the PON I wanted. Trimming any possible leading or trailing spaces which are common.
Exit For 'If I found the right PON, then exit the for loop and move on with the test.
End If
Next

msgbox ''I found the CIN for '' & strPON & ''!! It is '' & strCIN

Marked as spam
Posted by (Questions: 17, Answers: 807)
Answered on July 30, 2015 9:31 pm
0
That worked really well. We're able to finish our test now!
( at July 30, 2015 9:32 pm)
EyeOnTesting

Welcome back to "EyeOnTesting" brought to you by Orasi Software, Inc.

X
Scroll to Top