最近,我开始使用编码的UI测试自动化我的windows应用程序,并且在访问一些MSAA控件时遇到了问题。我是手动编码我的自动化,不想添加控件到UI地图,然后使用它。
我被卡住的控件是左窗格上的一个treeItem,它选择机器,细节显示在中心的客户端区域。
我尝试使用属性搜索控件,如十字线显示在UI控件上,但徒劳无功。
下面是我试过的密码-
UITestControl machine = new UITestControl(App);
machine.TechnologyName = "MSAA";
machine.SearchProperties.Add(WinTreeItem.PropertyNames.ControlType, "TreeItem");
machine.SearchProperties.Add(WinTreeItem.PropertyNames.Name, "Machine1");
machine.SearchProperties.Add(WinTreeItem.PropertyNames.ControlName, "m_tvPlantStructureView");
Mouse.Click(machine); // This code gives an error错误-
Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotFoundException:回放未能找到具有给定搜索属性的控件。详细信息: TechnologyName:'MSAA‘ControlType:'TreeItem’名称:'Machine1‘ControlName:'m_tvPlantStructureView’--> System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL已通过调用COM组件返回。
请参阅附件。让我知道,有什么问题,以及要遵循什么过程,才能完全摆脱这种控制上的错误,这在将来是不被承认的。
目前,我遵循这样的方法:做交叉操作,获取属性,然后对控件的属性进行编码,以自动化用户操作和断言。但这种方式并不总是有效的。
如果有更好的方法,请告诉我。
发布于 2014-06-26 15:13:37
你需要做一个层次搜索。创建2个控件:首先,Treeview作为窗口。使用控件名m_tvPlantStructureView,然后创建一个名为Machine1的新TreeItem。
var treeView = new WinWindow(App);
treeView.SearchProperties.Add(WinWindow.PropertyNames.ControlName, "m_tvPlantStructureView");
var machine= new WinTreeItem(treeView);
machine.SearchProperties.Add(WinTreeItem.PropertyNames.Name, "Machine1");
Mouse.Click(machine); // This code gives an error如果失败,另一件事是从treeview中删除App并添加窗口标题。
如果你有任何问题,请告诉我。
var treeView = new WinWindow();
treeView.WindowTitles.Add("mywindowname");
treeView.SearchProperties.Add(WinWindow.PropertyNames.ControlName, "m_tvPlantStructureView");
var machine= new WinTreeItem(treeView);
machine.SearchProperties.Add(WinTreeItem.PropertyNames.Name, "Machine1");
Mouse.Click(machine); // This code gives an error发布于 2014-10-27 10:49:45
在执行鼠标clik之前,我将使用
machine.Find();之后,我检查机器是否有一个不同的值为null,如果它不是null,则执行单击。
https://stackoverflow.com/questions/13009323
复制相似问题