我已经创建了一个精益项目,并用DataGrid创建了一个示例,但是它抛出的表没有发现异常,而且我也不确定在精益中测试DataGrid的方法。有谁能帮我解决这个问题吗?
Datagrid示例:
<Window x:Class="WpfApplication12.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Name="datagrid_window"
Title="MainWindow" Height="350" Width="525">
<Grid>
<DataGrid x:Name="msdatagrid" AutoGenerateColumns="True">
</DataGrid>
</Grid>
</Window>我已经从后面的代码中为这个datagrid设置了itemsource。
Leanft测试方法:
public void TestMethod1()
{
SDK.Init(new SdkConfiguration());
Reporter.Init(new ReportConfiguration());
Process.Start(@"..\..\..\Debug\WpfApplication12.exe");
IWindow win = Desktop.Describe<IWindow>(new WindowDescription
{
IsChildWindow = false,
IsOwnedWindow = false,
AccessibleName = @"datagrid_window",
});
ITable table = win.Describe<ITable>(new TableDescription
{
Name = @"msdatagrid"
});
table.SelectCell(1, 1);
}发布于 2015-12-24 22:03:41
未找到测试对象异常意味着您没有为测试对象或其父对象创建正确的描述。尝试使用对象识别中心来窥探数据网格,复制描述(使用底部的第二个左键)并将其粘贴到测试中。
有关OIC的更多信息请访问:http://leanft-help.saas.hp.com/en/latest/HelpCenter/Content/HowTo/TestObjects_OIC.htm
在您的示例中,它将如下所示:
var table = Desktop.Describe<IWindow>(new WindowDescription
{
ObjectName = @"datagrid_window",
FullType = @"window",
WindowTitleRegExp = @"MainWindow"
}).Describe<ITable>(new TableDescription
{
ObjectName = @"msdatagrid"
});下面是访问数据网格单元格的方法,例如:
var firstCell = table.Rows[0].Cells[1];
Assert.AreEqual("World", firstCell.Value);
firstCell.SetValue("World1");确保您根据所使用的技术添加了正确的using语句。每个技术测试对象都定义在一个专用的命名空间中。对于WPF,它应该是:
using HP.LFT.SDK.WPF;您使用了HP.LFT.SDK.StdWin名称空间中的WindowDescription (根据其属性)。WPF是本机窗口控件测试对象的命名空间,您不能通过StdWin命名空间在窗口上描述HP.LFT.SDK.StdWin测试对象。
请注意,对于桌面应用程序,最好只有一个应用程序实例在运行。
我还可以看到您正在初始化SDK和Reporter。建议使用已经包含所需的所有内容(引用、初始化)的visual studio LeanFT项目模板来开始对测试进行编码。这些模板可以在visual studio的“新建项目”对话框的“C#\Test”部分下找到。
希望它能帮上忙!
https://stackoverflow.com/questions/33863804
复制相似问题