简体   繁体   中英

How to iterate visible rows alone using UFT

when i iterate this below webtable,i am getting row count as 3(with hidden row). but i can see only 2 rows in my application. i can get row count with help of descriptive programming,but i want to iterate only the rows which are visible.

<table>
 <tbody>
  <tr class="show">Name</tr>
  <tr class="hide">Ticket</tr>
  <tr class="show">city</tr>
 </tbody>
</table>

i have tried this below code,but its displays hidden row text as well,

for i=1 to rowcount
  print oWebtable.getcelldata(i,2)
next

Actual Output - Name, Ticket, city

expecting output - Name, city

UFT has no way knowledge of your show/hide class names. If you want to filter out some rows you need to do it yourself.

Set desc = Description.Create()
desc("html tag").Value = "TR"
desc("class").Value = "show"

Set cells = oWebtable.ChildObjects(desc)
Print "Count: " & cells.Count
For i = 0 To cells.Count - 1
    Print i & ": " & cells(i).GetROProperty("inner_text")
Next

Note that I had to add TD elements to your table in order for this to work since it's invalid HTML to have text in a TR element.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM