Get cell data from webtable

Posted by rajivkumarnandvani on February 16, 2011

Hi all ,

I found a helpful example in QTP help file that can be use most of time while working with web table. I hope It will help you.


Returns the text contained in the specified cell.


object.GetCellData (Row, Column)

Argument Description
object A test object of type WebTable.
Row Required. A Variant value. The row number where the cell is located. The first row in the table is numbered 1.
Column Required. A Variant value. The column number where the cell is located. The first column in the table is numbered 1.

Return Value

A String value.  Returns the data contained in the specified cell.
If the specified cell is not valid, the method returns micCellDoesNotExist

Find All Employees That Live in the Same City
Sub GetCellData_GetRowWithCellText_Example()
‘The following example retrieves the names of all employees that live in
‘the same city as John Smith so that he can arrange rides home with them.
‘First, the example finds the table row containing
‘”John Smith”. Then it checks the value of the CityColumnn cell to determine
‘the city in which John lives. It searches the table cells to find all other
’employees that live in that city. Finally it uses the GetCellData method to
‘return those employees names and, using a function, generates a list
‘containing those names.

CityColumn = 4
NameColumn = 2
‘Get the row number for employee ‘John Smith’
RowNumber = Browser(“CorporateEmployees”).Page(“CorporateEmployees”).WebTable(“EmployeesTable”).GetRowWithCellText(“John Smith”)
Set AccommodationsCity = Browser(“CorporateEmployees”).Page(“CorporateEmployees”).WebTable(“EmployeesTable”).ChildItem(RowNumber, CityColumn, “WebEdit”, 0)
TableRows = Browser(“CorporateEmployees”).Page(“CorporateEmployees”).WebTable(“EmployeesTable”).RowCount
‘Search for all employees that live in the same city as ‘John Smith’ and add them to his ride home list
For i = 1 To TableRows
Set CurrentCity = Browser(“CorporateEmployees”).Page(“CorporateEmployees”).WebTable(“EmployeesTable”).ChildItem(i, CityColumn, “WebEdit”, 0)
If CurrentCity.GetROProperty(“value”) = AccommodationsCity.GetROProperty(“value”) Then
EmployeeName = Browser(“CorporateEmployees”).Page(“CorporateEmployees”).WebTable(“EmployeesTable”).GetCellData(i, NameColumn)
AddToJohnSmithRideHomeList (EmployeeName)
End If


End Sub


7 Responses to “Get cell data from webtable”

  1. lee said

    Thank you! Your blog help me solve my question.

  2. Thanks for reading the blog.. 🙂

  3. Balaji said


  4. prasad said

    plz tell me

    scenario : how to click a link in a cell of webtable (the cell consists of 4 links how to click the 2nd link

  5. Anonymous said

    i know how to click the single link in cell. May be this will helpful for u

    Set wTable= Browser(“CorporateEmployees”).Page(“CorporateEmployees”).WebTable(“EmployeesTable”).ChildItem(RowNumber, CityColumn, “Link”, 0)


  6. navi said


    It was good.. i got another issue..
    ” If I am supposed to click on a particular column of a webtable which will change dynamically.. what i need to do”

    wil getroproperty and settoproperty works fine with webtable…

    i need clear script for the same…


  7. Prasanna said

    How to get the value to webtable when WT value is available with multiple page?

    Thanks in advance

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: