How to handle webtable in QTP
I should describe this post in very beginning of this blog anyway Today I am going to describe some basic things to handle webtable in webpage automation using QTP. Its very easy to automate webtable in QTP. Just You will require following knowledge to automate webtable.
1. How to get row count from webtable?
2. How to get column count from webtable?
3. How to fetch data from specific row and column from webtable?
Method to get row count and column count from webtable
You can use rowcount method to get data from specific row and specific column. Refer following step by step procedure to apply getcelldata method in your script.
1. First record the table using QTP.(just click on any element of webtable)
2. After recording you will get code like following.
Browser (“myBrowser”).Page (“myPage”).Frame (“myFrame”).WebTable (“myTable”).WebElement(“myElement”)
3. Now just remove webelment part from above sentence and write rowcount (after “.”) at the end of sentence, so you will have code like following.
Row_count = (Browser (“myBrowser”).Page (“myPage”).Frame (“myFrame”).WebTable (“myTable”).RowCount)
4. you will get row count in Row_count variable.
Note:- The same apply for getting column count but just you have to specify no. of row in argument.
Following code will give column count of 2nd row.
Row_count = (Browser (“myBrowser”).Page (“myPage”).Frame (“myFrame”).WebTable (“myTable”).Columncount(2))
Method to fetch data from specific row and column from webtable.
The same method applies here as above in row and column count. We can fetch value from table using getcelldata method. Here two argument have to specify to fetch value.
The following code will get data from 3rd row and 5th column. The first argument must be row and second must column.
Get_data = Browser (“Cisco Media Experience_4”).Page (“Cisco Media Experience_3”).Frame (“Frame_3”).WebTable (“Job ID_2”).GetCellData (3, 5)
If you face any difficulty to get content of webtable you are always welcome to raise query.