Ask a Question

How to get Data from Data Grid/DATA Table


How to get Data from Data Grid/DATA Table

Hi Team,

I Have created a record and post creation , it saves the table in the Data Grid.

Attached screenshot.


Please share the code or snippet to store the First record of the Data table into a variable and print it.



Community Hero

Without knowing the properties of your grid, and scripting language we can't help you. We need a lot more information.


Click the Accept as Solution button if my answer has helped

Agreed.  Could you supply a bit more information ?  It's not even entirely clear to me whether you are doing desktop or web testing - it looks like web, but you never know.  How do you intend to use the data ?  In other words, do you need to know all the values in the rows, are only interested in one of the fields etc.

Standard syntax disclaimers apply

Hello Rudolph and Team,


Please note my response below:


1. Yes, it is a web based testing application.

2. As part of our project, I am interested in fetching both the things from data table 

a. How to retrieve all the rows values/data inside these rows

b. Also there is one test case wherein I need to fetch particular cell value from a column.


Please See the screenshot attached, I would like to fetch firstly all the rows from this data table to a List or array.


Ands secondly I also need all Employee IDs(column Number 4) from this web table to be stored somewhere in the variable, so that I can use this column value for expected data output comparison.


Please share your responses, as it is quite urgent.

It would be really helpful if you could include the Objct browser for this table.  Sometimes tables are in the traditional <table><tr><td> format, but more commonly in modern application, these are custom build with divs, panels, textboxes etc.


Extremely generic:


You will have to use find methods to identify the rowindex of the "first" row - which contains the data, since it won't neccessarily be the first row in the "table"  You will probably also need to do a find in the objects with the rowindex of the header row and in that do a findchild where the contentText is the column's name.  You then know what the columnIndex is.  Combine rowIndex and columnindex in a find and you have a cell to get a value from.


FindAll where rowindex is "row" 1 and some other criteria such as where the objects are textboxes and you have all the fields in an array to populate your data.

Standard syntax disclaimers apply
Community Hero

Have alook at this thread that discusses something similar and includes links to other similar queries.  It might give you some starting point

Standard syntax disclaimers apply


Please find attached the Object Browser tree for the grid view.

Please advise on how to get the first row ,specific column data printed




To make life easier on yourself, you should probably Name Map Panel("transactionTypeGridDiv") to something like TransactionTypeTable


Although it might change from grid to grid, my guess is that panel(1) is your first row of data.


That means that to get the entire first row, you would be using a findchild something like so:

var PanelWithRow1 = Aliases...TransactionTypeTable.FindChildEx("Panel","1",1);

var childPanelWithData = PanelWithRow1.FindChildEx("Panel","0",1); 
//or ("Panel","1",1); if that's the panel with the data in var dataArray = childPanelWithData.FindAllChildren(cellcontainer,uniqueidentifierofcells).toArray(); //uniqueidentifierofcells can be a wildcard e.g. "*" you may need to use multiple properties and values e.g objecttype=textbox and visible=true //dataArray now has all the cells in your first data row and you can read from the array

Standard syntax disclaimers apply
SmartBear Alumni (Retired)

Hi @prabhjot88singh,


I agree with Rudolf - using Name Mapping sounds reasonable here. Please read the following tutorial explaining how to map objects manually:

Also, pay attention to mapping criteria - they should be reliable. Don't use Index or similar properties whose values are changed from run to run.


Once you map the cell, you can use the wText property or a similar one to get the value of the mapped cell.



Tanya Yatskovskaya
SmartBear Community and Education Manager

Showing results for 
Search instead for 
Did you mean: