Tuesday 25 February 2014

UFT/QTP: GetRowWithCellText method

getrowwithcelltext example, getrowwithcelltext in qtp, getrowwithcelltext method in qtp


GetRowWithCellText method - find the row number on a webtable with specified cell text

Syntax

object.GetRowWithCellText(Text,[Column],[StartFromRow])

·          Column  - Optional - A Variant value. The column number where the cell is located. The value can either be the column name or index. Index values begin with 1.

·      StartFromRow - Optional. A Long value. The number of the row in which to start the search. The first row in the table is numbered 1. 

·           In case the method does not find any cell with specified text, the method returns -1 value.

In below mentioned example I will select the row where Confirmation Number is "789"

Select
Flight Name
Ticket Number
Source
Destination
Date
IA
123
Chennai
New Jersy
3-Mar-14
BA
456
New Jersey
Los Angeles
4-Mar-14
JA
789
Los Angels
Singapoer
5-Mar-14
               

--Find the row number  where "789" text is present using GetRowWithCellText method

GtRowN = Browser("XYZ").Page("OBC").WebTable("Ticket Summary").GetRowWithCellText("789")

--check text find in webtable or not

     If  GtRowN >0 Then
          -- coulmn index  where  checkbox  is present
          --here select coulmn name index value is 1
          CoulmnIndex = 1         
  
-- create the checkbox object  after getting the rownumber and select the row by clicking the checkbox

 set objCheckbox = Browser("XYZ").Page("OBC").WebTable("Ticket Summary").ChildItem(GtRowN,CoulmnIndex,"WebCheckBox",0)
      
 objCheckbox.set "ON"

    else
         msgbox "Did not find the value test fail"

     End If

No comments:

Post a Comment