Ranorex.Table - I can't get cells values

Class library usage, coding and language questions.
sop
Posts: 11
Joined: Mon Mar 18, 2013 7:29 am

Ranorex.Table - I can't get cells values

Post by sop » Mon Mar 18, 2013 7:56 am

Hello,
I have a grid in our application which is seen as Table with MSAA flavour by the Spy.
I am trying to get values out of that table with the following code

Code: Select all

Ranorex.Table t = PortfolioForm.FindSingle<Ranorex.Table>("element/element[@controlid='yyy']/table[@accessiblename='xxx]", 5000);
            t.EnsureVisible();
            t.Focus();
      
            IList<Row> rows = t.FindDescendants<Row>();
            foreach (Row row in rows)
            {
                foreach (Cell cell in row.Cells)
                {
                    String v = cell.Text;
                 }
            }  
I am getting values only for the top row (in fact a header of the datagrid).
for the rest I am getting null although I can see the values in the application.

the same happens in the Spy.
for cells of the top row
Row 'Top Row'
+Cell 'ROOT Header 0'
+Cell 'ColumnA Header 2'
...
I can see in the Overview a value in the section Cell under Text.

for other rows
Row 'Row 0'
+ Cell 'ROOT Row 0'
+ Cell 'ColumnA Row 0'
...
I can see that in the Overview Cell section Text is greyed out and contains nothing
Cell.jpg
In reality cell contains a number which can be seen in application and in Spy in the screenshot section
CellSS.jpg
AM I doing something wrong?
Any advice of how to get the cell value in the code?

Thanks,
sop
You do not have the required permissions to view the files attached to this post.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Ranorex.Table - I can't get cells values

Post by Support Team » Mon Mar 18, 2013 4:03 pm

Hi,

In order to analyze this is detail we would need a Ranorex snapshot file of your table, could you please post us such a snapshot file?
Following link will show you how to generate a snapshot file:
Creating Ranorex Snapshot Files.

Thanks,
Markus

sop
Posts: 11
Joined: Mon Mar 18, 2013 7:29 am

Re: Ranorex.Table - I can't get cells values

Post by sop » Mon Mar 18, 2013 4:40 pm

Hi Markus
here is the snapshot
tablesnapshot.rxsnp
thanks,
sop
You do not have the required permissions to view the files attached to this post.

sop
Posts: 11
Joined: Mon Mar 18, 2013 7:29 am

Re: Ranorex.Table - I can't get cells values

Post by sop » Mon Mar 18, 2013 7:34 pm

one more thing
looking at cells properies /Details in the Spy I can see that AccessibleValue for header cell is the value and for other rows is empty
Header screenshot
header.jpg
other cells Details screenshot
Cell.jpg
thanks,
sop
You do not have the required permissions to view the files attached to this post.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Ranorex.Table - I can't get cells values

Post by Support Team » Tue Mar 19, 2013 2:57 pm

Hi,

Thanks for the snapshot file!
The not set "AccessibleValue" should have no impact on the ability of Ranorex of finding elements.
But there is obviously something different between the controls, so could you ask your development team why they didn't set the "AccessibleValue" for the other cells too?

The snapshot looks quite okay, I could see all your cells, so could you please execute the following code:
Ranorex.Table t = PortfolioForm.FindSingle<Ranorex.Table>("element/element[@controlid='1000']/table[@accessiblename='DataGrid']", 5000);
t.EnsureVisible();
t.Focus();
List<Cell> cells = t.Find<Cell>("./row/cell", 10000);
        	
Report.Info("Count: "+cells .Count);
how much cells could be found during runtime?

Regards,
Markus

sop
Posts: 11
Joined: Mon Mar 18, 2013 7:29 am

Re: Ranorex.Table - I can't get cells values

Post by sop » Tue Mar 19, 2013 5:02 pm

Hi Markus
it gets all cells = number of rows* number of columns
but as I said I cant see how to get the value which is stored in body cell

header cell:
headerCell.jpg
body cell:
bodyCell.jpg
regards,
sop
You do not have the required permissions to view the files attached to this post.

sop
Posts: 11
Joined: Mon Mar 18, 2013 7:29 am

Re: Ranorex.Table - I can't get cells values

Post by sop » Tue Mar 19, 2013 5:04 pm

sorry for a bit of confusion - in the screenshot number of cells is more than in the snapshot because there are more rows in the choosen datagrid
but as I said the total number of cell is as expected (i.e. number of cells = number of rows* number of columns.)

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Ranorex.Table - I can't get cells values

Post by Support Team » Wed Mar 20, 2013 3:17 pm

Hi,

I see, so do I assume correctly that these controls are MFC controls?
If so you could try to add the process or class name to the GDI capture list in order to get the needed information as described here: Testing of Legacy Applications.

Regards,
Markus

sop
Posts: 11
Joined: Mon Mar 18, 2013 7:29 am

Re: Ranorex.Table - I can't get cells values

Post by sop » Wed Mar 20, 2013 4:07 pm

thanks Markus
in Spy it becomes accessible but in a bit strange way - not as a cell identified by row and a column
so by default the xpath is using rawtex
newCell.jpg
you can see that this element is located in the 8th row and 2 column
looking in the application one would expect it to be 6th row 0 column
cellnew1.jpg
but apparently there are rows and columns which dont exist
for example cell[1,0] doesnt exixts and can not be found
cell10.jpg
whereas cell[0,0] points as expected to the HEADER

so I am not sure how it is possible to know which index to use in order to access a specific cell

second question is - how do I do the same inside the code if we dont use Ranorex repository and working with GUI using xpathes?

thanks,
sop
You do not have the required permissions to view the files attached to this post.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Ranorex.Table - I can't get cells values

Post by Support Team » Thu Mar 21, 2013 3:42 pm

Hello,

Unfortunately it is not as useful to access specific cells as it is with the original msaa elements.
I am afraid that you have to create a loop in a user code file where you iterate through all raw text element in the table and check the value of each element.

Regarding your second question, you could use variables in you RanoreXPath in order to access the cells, but if you do this it could cause a bad performance.

Regards,
Bernhard