DataGrid

Feb 20, 2012 at 5:17 AM

I tried to access the DataGrid as a ListView but I was able to detect the number of raws but the number of cells is zero.

and I also tried to access it as a Table and that produces an error.

how can I access it any help?

Feb 20, 2012 at 7:18 AM
Edited Feb 21, 2012 at 6:48 AM

 

Hi

you has a WPF Application and your DataGrid has many Custom Controls right?

Then this is a known problem.

you can get the cells from the row on your own.

 

 

ListView view = parent.Get<ListView>(....);

List<ListViewCells> rowCells = new List<ListView>();

foreach(ListViewRow row in view.Rows)

{

BricksCollection<AutomationElement> coll = new BricksCollection<AutomationElement>(row.AutomationElement.FindAll( TreeScope.Descendants, new PropertyCondition( AutomationElement.ClassNameProperty, "DataGridCell" )));
 
ListViewCells cells = new ListViewCells( coll, view.ActionListener, view.Header );

rowCells.Add(cells);

}

This is one possible way

Feb 20, 2012 at 11:42 AM

I realy sory but I am a newer to UIAutomation and to White so If so If you explain each line in the foreach loop (in details)that will be nice, and by the end of the loop rowCells will it cotain all the cells from all the raws or will it only contains the cells of the last raw?

and if there is any gude, document, link or any documentaion about UIAutomation and/or White that I can read so I become familuare with it.

 

and thanks in advance.

Feb 20, 2012 at 1:14 PM

Hi

I only use the documentation and demos of White himself. This documentation is part of the source code of White.

White is a Wrapper of UIAutomation and most  White functions are based on UIAutomation.

 

The Loop ( I have corrected a copy paste error there)

 

the first line gets all cells from a row as AutomationElementCollection.

the second line is the constructor of ListViewCells which is a collection with all cells of a row.

the last line added this to a list.

The list contains all cells of all Rows in the same order.

 

Throndorin

 

 

 

 

 

 

Feb 21, 2012 at 5:46 AM

ok nice and thanks now I can access the cells: I think you thould replace list.ActionListener by view.ActionListener and the same for list.Header

now I need to check the value inside the cell and compare it with a string or if it was a button I want to click, to compare it with string I tries to cast it, and tried to convert all  the cells to array of strings but faield,
so thans and if u have a segestion for this it will be nice

Feb 21, 2012 at 6:57 AM

Hi

to get more informations about elements in the cell you have to get the controls inside of the cell. In most cases there are ComboBoxes, Labels or TextBoxes inside of the cell.

 

You can extend ListViewCell with a Operation

 

public static string GetValue(this ListViewCell cell)

{

ComboBox box = cell.Get<ComboBox>(SearchCriteria.ByControlType(ControlType.ComboBox));

if (box != null)

{

//get value

   return valueComboBox;

}

TextBox //.... and so on

}

 

 

Have a look in UIAVerirfy which controls are embedded in a ListViewCell.

Throndorin

Feb 22, 2012 at 4:56 AM

thanks I think this may work.