From Interviewer stand point he may provide the applicant with a sample table such as the one shown below and can ask the applicant to find the number of columns and number of rows in table
RowNumber = 2
strColCnt = Browser("name:=UFT Questions.*").Page("title:=UFT Questions.*").WebTable("column names:=Slno;Student Name;Student Registered ID").ColumnCount(RowNumber)
Slno
|
Student Name
|
Student Registered ID
|
1
|
John Henkey
|
R2014010156789
|
2
|
Peter Mark
|
R2014010157892
|
3
|
Mary R
|
R2014010168975
|
Below is the code that can help you to retrieve the Table row and column count
Code
Please run the below code in UFT/QTP to see the result
To Get the Row Count
strRowCnt = Browser("name:=UFT Questions.*").Page("title:=UFT Questions.*").WebTable("column names:=Slno;Student Name;Student Registered ID").GetROProperty("rows")
Msgbox strRowCnt
Output is 4
strRowCnt = Browser("name:=UFT Questions.*").Page("title:=UFT Questions.*").WebTable("column names:=Slno;Student Name;Student Registered ID").RowCount
Msgbox strRowCnt
Output is 4
To Get the Column Count
strColCnt = Browser("name:=UFT Questions.*").Page("title:=UFT Questions.*").WebTable("column names:=Slno;Student Name;Student Registered ID").GetROProperty("cols")
Msgbox strColCnt
Output is 3
We may some time require column count of a particular row. In that case this will work, where RowNumber=2 is refereing to the second row of the table
RowNumber = 2
strColCnt = Browser("name:=UFT Questions.*").Page("title:=UFT Questions.*").WebTable("column names:=Slno;Student Name;Student Registered ID").ColumnCount(RowNumber)
Msgbox strColCnt
Output is 3
Regards,
Sreenu Babu
Thanks Sreenu Babu
ReplyDeletehow get particular column name and particular row
ReplyDeletehow can yo find the exact location of "Peter Mark". In other words how do i capture the row number and column number where "Peter Mark" is present
ReplyDeletegörüntülü show
ReplyDeleteücretlishow
V53O