Can't get Values of a Xceed DataGrid

Class library usage, coding and language questions.
MM-P
Posts: 9
Joined: Fri Mar 27, 2009 10:50 am

Can´t get Values of a Xceed DataGrid

Post by MM-P » Fri Mar 27, 2009 12:12 pm

Is there any user guide for working in visual studio with ranorex?
Or is all the same like in Ranorex Studio? Seems to me like that.

But I´ve a problem I´ve a XceedDatagrid. I´ve set everywhere, where it is possible automation ID´s
- It recognice the DataGrid .. ControlType.DataGrid (have got automationID)
- It recognice the DataRow .. ControlType.DataItem (have got no automation ID)
- and the Cells of the Row are ControlType.Custom ... (have got automation ID and the 3 are for every ROW the same)
--> the Cells are set Read-Only
--> i can´t access them via your accessible method
What can I do to get the value of the Cell
I can get only the Text.ToString() ... what it´s not the value.

Is it correct that u working with automatonId and/or index? It seems to me like that.

(http://www.ranorex.com/blog/making-3rd- ... automation) ... will not help me I think because I can´t change something in the Xceed Grid. In our Application we Binding the Data out of a database in xaml with

Code: Select all

ItemsSource="{Binding Path=ContactItems}"

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

Post by Support Team » Fri Mar 27, 2009 1:38 pm

Is there any user guide for working in visual studio with ranorex?
Or is all the same like in Ranorex Studio? Seems to me like that.
It's all the same like in Visual Studio.
(http://www.ranorex.com/blog/making-3rd- ... or-automat ion) ... will not help me I think because I can´t change something in the Xceed Grid.
You can get/set all existing properties and call methods of the Xceed Grid in the AUT without changing the code. Here a code sample:

Code: Select all

Control control = yourForm.FindSingle<Ranorex.Control>("RxPath of the control");
 
String text = (String)control.GetPropertyValue("Text");
control.SetPropertyValue("Text", "My" + text);
control.SetPropertyValue("BackgroundColor", System.Drawing.Color.Cyan);
Jenö
Ranorex Team

MM-P
Posts: 9
Joined: Fri Mar 27, 2009 10:50 am

Post by MM-P » Fri Mar 27, 2009 3:08 pm

I tried it ...

Code: Select all

Form myForm = myRepo.FormAdministration.Self;	
Control control = myForm.FindSingle<Control>("/form[@name='averylongspecification']withmanycriteria");
and get the Message:
Ranorex.CapabilityNotSupportedException: The element does not support the required capability 'control'. at Ranorex.Adapter.Create[T](Element element) at Ranorex.Adapter.FindSingle[T](RxPath path) at ...

Is it a wrong using of the form? I´m setting in RxPath the absolute Path of Ranorex Spy.
Is it possible not to use RxPath, an set it out of the repository, for example:

Code: Select all

myRepo.FormAdministration.Common.DataGrid1.DataRow1.Cell1
I also tried:

Code: Select all

Cell myCell = myRepo.Form_Administration.ContainerScroll.CellCell_Comment1;
and tried to set the control on it ...

MM-P
Posts: 9
Joined: Fri Mar 27, 2009 10:50 am

Post by MM-P » Fri Mar 27, 2009 3:39 pm

I tried to set control on a Form, Button, Table and Cell ... but always I´m getting this exception.

Thank u 4 your support!

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

Post by Support Team » Fri Mar 27, 2009 3:50 pm

OK, that's clear, sorry for being unexact.

If you find with form.FindSingle, you have to use a relative path within the form:
(This code searches a control with the control name "button1" within the form)

Code: Select all

Control control = testedForm.FindSingle<Ranorex.Control>("button[@controlname='button1']");
or you use a full RxPath like this:
(This code searches a control with the full RxPath in your local machine)

Code: Select all

Control control = "/form[@controlname='TestedApp']/button[@controlname='button1']";
Jenö
Ranorex Team

MM-P
Posts: 9
Joined: Fri Mar 27, 2009 10:50 am

Post by MM-P » Mon Mar 30, 2009 8:31 am

Ok finally I understand how to work with the RxPath ;)

Code: Select all

Button button = "form[@name='Adminform']/container/button[1]/element[1]/button";
button.Click(); 
--> passed

Code: Select all

Control control = "form[@name='Adminform']/container/button[1]/element[1]/button";
button.Click(); 
--> failed with Exception:
Ranorex.CapabilityNotSupportedException: The element does not support the required capability 'control'. at Ranorex.Adapter.AssertRequiredCapabilities() at Ranorex.Adapter..ctor(Element element) at Ranorex.Control.op_Implicit(String path) at AgiloStandardTest.Program.Test1() in ...
and I also can´t set it to a CELL ... same error Message. And I need the value respectively the content of the cell, not the name, or sth. other.

When I´m trying to use FindSingle with:

Code: Select all

Form myForm = myRepo.AdminForm.Self;	
Control control = myForm.FindSingle<Control>("button[@automationid='Admindata']");
--> failed with Exception:
Ranorex.ElementNotFoundException: No element found for path 'button[@automationid='Admindata']'. at Ranorex.Core.Element.FindSingle(RxPath path) at Ranorex.Adapter.FindSingle[T](RxPath path) at AgiloStandardTest.Program.Test1() in ...
Is it possible that my elements are not allowed to be accessed by Ranorex.Control ? What is wrong with my FindSingle Search ?? There is a element which have automationid 'Admindata'!

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

Post by Support Team » Mon Mar 30, 2009 10:02 am

Code: Select all

Is it possible that my elements are not allowed to be accessed by Ranorex.Control ? 
Yes, this depends on the control type, can you please inform us about the exact type and version number of the control.
Please also send us a Ranorex snapshot file:

1. Start Ranorex Spy
2. Track the control in the AUT
3. Select the application in RanorexSpy
4. Right-click the application and select "Set Element as Root"
5. Save as Snapshot
6. Send the Snapshot file to support at ranorex.com

Jenö
Ranorex Team

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

Post by Support Team » Mon Mar 30, 2009 3:13 pm

Thank you for the snapshot.

I played a little bit with the Xceed Grid control and could automate everything.
I used the "Editing Data" online Demo sample from:

http://xceed.com/Grid_WPF_Demo.html

Please check the following code:

Code: Select all

Form form = "/form[@title~'Xceed DataGrid for WPF']";
                
Table table = form.FindDescendant<Table>("grid");

// Find a cell by Index and AutomationId
Cell cell_name = table.FindSingle<Cell>("row[@Index='2']/cell[@automationid='Cell_Name']");
Report.Info(String.Format("Text={0}   Column={1}   Row={2}", 
                          cell_name.Text, cell_name.ColumnIndex, cell_name.RowIndex));
Report.Info(String.Format("--------------------------------------"));	

// Read all cells by Cell_Name
IList <Cell> cells = table.FindDescendants<Cell>("Cell_Name");
foreach( Cell cell in cells)
{
	Report.Info(String.Format("Text={0}   Column={1}   Row={2}", 
	                          cell.Text, cell.ColumnIndex, cell.RowIndex));
}
Jenö

Ranorex Team

MM-P
Posts: 9
Joined: Fri Mar 27, 2009 10:50 am

Post by MM-P » Tue Mar 31, 2009 10:35 am

:D
I really appreciate that you are helping me. But

Code: Select all

cell.Text
was never a Problem to get.

But not what ist the content of the cell from database in this cell. That´s not the Text attribute. And I also couldn´t found it in the Tree when I´m moving over the variable.

That´s not a Problem of Ranorex! I had the same problem with TestComplete and UI Automation with White too. But Ranorex is the most comfortable tool :) I like the repository :)

I think the only possibility to get the content of the cell is while binding the data to a cell also setting the cell.Text to the same name which is in the binded data.

My Table is like this:
0 - Row Header - [Signature][Name]
1 - Row [Mayor][Hans Koch]
When I´m trying this code:

Code: Select all

Table table = myForm.FindDescendant<Table>("sigExtDataGrid");
Cell cell_name = table.FindSingle<Cell>("row[@index='1']/cell[@automationid='Cell_Name']");
... and I get:
Text=Name Column=1 Row=1
Name ist set for every cell in the column which the Header is name. And also Signature is set for every cell in the column which the Header is Signature

Thank you for your support, I´ll go on testing with Ribbons.

MM-P
Posts: 9
Joined: Fri Mar 27, 2009 10:50 am

Post by MM-P » Wed Apr 08, 2009 11:40 am

I got it ... by chance ...

the problem was, that in the cells are a intern Lists (within the child). (this is not in the database) In this List I find the Text :)

So I can access die cells text now with this:

Code: Select all

Table contactTable = "...path...";
IList<Row> contactRows = contactTable.FindDescendants<Row>();
for (int i = 0; i < contactRows.Count; i++){
   contactRows[i].DoubleClick();
   for (int j = 0; j < contactRows[i].Cells.Count; j++){
      try{
         Text cellText = contactRows[i].Cells[j].FindChild<Text>();
         Console.WriteLine(cellText.TextValue.ToString());
         }catch{}
    }
}
Thank u again.