I am automating the WPF application using coded UI, I am trying to find a row in Data Grid which is unable to find the control, when i ask my developer about the control hierarchy, they said that they put another Data Grid with in the Data Grid. When i record the control which is unable to find the control, Can any one help me thankyou.
After clicking the first toggle button second row will display, actually it is not second row, with in that row only Data Grid is added. This is my code..
WpfCustom custDetaPre = new WpfCustom(rowGrid);
custDetaPre.SearchProperties.Add(WpfCustom.PropertyNames.ClassName, "Uia.DataGridDetailsPresenter");
//custDetaPre.SearchConfigurations.Add(SearchConfiguration.AlwaysSearch);
custDetaPre.SearchProperties.Add(WpfCustom.PropertyNames.TechnologyName, "UIA");
When i try to record the second toggle button it is with in the above custom control, with in this custom control data grid is placed.
this is my total code :
WpfTable tableGrid = new WpfTable(DashboarWindow);
tableGrid.SearchProperties.Add(WpfTable.PropertyNames.ClassName, "Uia.DataGrid");
tableGrid.Find();
The above code for finding the Data grid in the form.
WpfRow rowGrid = new WpfRow(tableGrid);
rowGrid.SearchProperties.Add(WpfRow.PropertyNames.ClassName, "Uia.DataGridRow");
The above code is row of the data grid
WpfCell celGrid = new WpfCell(rowGrid);
celGrid.SearchProperties.Add(WpfCell.PropertyNames.ClassName, "Uia.DataGridCell");
the above code is first row and first cell in the data grid
WpfToggleButton toglButtonShowall = new WpfToggleButton(celGrid);
toglButtonShowall.SearchProperties.Add(WpfToggleButton.PropertyNames.AutomationId, "ShowDetails");
Mouse.Click(toglButtonShowall);
the above code is first toggle button, when i click on this (toggle), the second row will display, (second toggle button ) but this is not second row, this is a another data grid within the row. to find the second data grid one custom control is there with in this custom control only this second grid is exists. but i am trying to find this custom control i am getting the exception that is control can not found, the code for custom control is like below.
WpfCustom custDetaPre = new WpfCustom(rowGrid);
custDetaPre.SearchProperties.Add(WpfCustom.PropertyNames.ClassName, "Uia.DataGridDetailsPresenter");
custDetaPre.DrawHighlight();
from the above code where i am getting the exception. custDetaPre.Drawhighlight()
I believe you'll want to specify an explicit Row
and Column
index.
Add the row index to both the WpfRow
and WpfCell
and a column index to the WpfCell
From your screen shot, you are at least failing to qualify the row since you have 2 rows. you may not need the column index as long as you don't have multiple toggle buttons in a row.
As is, if you call rowGrid.FindMatchingControls()
after setting the search params, you should return two controls
From your comments....
WpfRow rowGrid = new WpfRow(tableGrid);
rowGrid.SearchProperties.Add(WpfRow.PropertyNames.RowIndex , "0");
WpfCell celDeffe = new WpfCell(rowGrid);
celDeffe.SearchProperties.Add(WpfCell.PropertyNames.RowIndex, "0");
celDeffe.SearchProperties.Add(WpfCell.PropertyNames.ColumnIndex, "0");
WpfToggleButton toglButtonShowall = new WpfToggleButton(celGrid);
toglButtonShowall.SearchProperties.Add(WpfToggleButton.PropertyNames.AutomationId, "ShowDetails");
Mouse.Click(toglButtonShowall);
I would expect the above to work for you
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With