编码的UI:getcell不适用于层次结构中具有XamDataGridCustom的Wpftable

时间:2016-06-29 13:50:05

标签: coded-ui-tests

我是Coded UI编码的新手,所以需要一些帮助来解决我面临的以下问题。 我有一个WPftable,在UI Map中具有以下层次结构:

this.UICommissionEngineMainWindow.UIXamDataGridCustom.UIRecordsTable

我需要从上表中读取单元格值,单元格具有以下层次结构:

this.UICommissionEngineMainWindow
    .UIXamDataGridCustom
    .UIRecordsTable
    .UIItemDataItem
    .UIItem2443Cell
    .UITextBlockText;

当我运行具有' GetColumnName'的以下代码行时和' ColumnCount'它起作用的方法:

var myrecord = this.UICommissionEngineMainWindow
                   .UIXamDataGridCustom 
                   .UIRecordsTable.GetColumnNames();

MessageBox.Show(this.UICommissionEngineMainWindow
                    .UIXamDataGridCustom
                    .UIRecordsTable
                    .ColumnCount.ToString());

但是当我尝试检索单元格数据时,它失败了。我尝试了几种方法但每次都失败了

Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotFoundException‌​: The playback failed to find the control with the given search properties. 
Additional Details:
TechnologyName: 'UIA'
FrameworkId: 'Wpf'
ControlType: 'Cell'
RowIndex: '1'
ColumnIndex: '1'
Search may have failed at 'Records' Table as it may have virtualized children. If the control being searched is descendant of 'Records' Table then including it as the parent container may solve the problem.System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component.

首先尝试

 this.UICommissionEngineMainWindow
     .UIXamDataGridCustom
     .UIRecordsTable
     .GetCell(1, 1)
     .Value.ToString());

ALTERNATIVE:

//GetProgramTablehas the Wpftable object in it
var cell = new WpfCell(GetProgramTable());
int row = 1;
int column = 1;
foreach (var data in dataitem.FindMatchingControls())
{
    var cell = new WpfCell(data);
    cell.SearchProperties.Add(WpfCell.PropertyNames.RowIndex, row.ToString());
    cell.SearchProperties.Add(WpfCell.PropertyNames.ColumnIndex, column.ToString());

    MessageBox.Show(cell.FindMatchingControls().Count.ToString());
}

ALTERNATIVE:

cell.SearchProperties.Add(WpfCell.PropertyNames.ColumnHeader, "Name");
cell.SearchProperties.Add(WpfCell.PropertyNames.Value, "2143");
MessageBox.Show(cell.FindMatchingControls().Count.ToString()) 

我想知道GetcolumnNames和ColumnCount何时能解决GetCell无法正常工作的问题。

0 个答案:

没有答案