Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/140.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 无法使用TestStack.White自动编辑控件和列表框 我有一个用Visual Studio 2012编写的C++专业的MFC应用程序。目前,我想使用用C编写的TestStack.White框架创建一些自动化脚本_C#_C++_Mfc_White Framework - Fatal编程技术网

C# 无法使用TestStack.White自动编辑控件和列表框 我有一个用Visual Studio 2012编写的C++专业的MFC应用程序。目前,我想使用用C编写的TestStack.White框架创建一些自动化脚本

C# 无法使用TestStack.White自动编辑控件和列表框 我有一个用Visual Studio 2012编写的C++专业的MFC应用程序。目前,我想使用用C编写的TestStack.White框架创建一些自动化脚本,c#,c++,mfc,white-framework,C#,C++,Mfc,White Framework,我无法控制列表框和编辑控件。 我正在使用spy++。编辑控件嵌套在组框中,我无法检查自动化ID 我的代码示例 var psi = new ProcessStartInfo(ExeSourceFile); application = Application.AttachOrLaunch(psi); mainWindow = application.GetWindow(SearchCriteria.ByText(applicationName), InitializeOption.NoCache);

我无法控制列表框和编辑控件。 我正在使用spy++。编辑控件嵌套在组框中,我无法检查自动化ID

我的代码示例

var psi = new ProcessStartInfo(ExeSourceFile);
application = Application.AttachOrLaunch(psi);
mainWindow = application.GetWindow(SearchCriteria.ByText(applicationName), InitializeOption.NoCache);
其中ExeSourceFile是应用程序的路径

这就是我尝试的方式。其中IDC_Edit是来自designer的ID

TextBox TextObj = mainWindow.Get<TextBox>     (SearchCriteria.ByAutomationId("IDC_Edit"));
如何控制列表框复选框/计数行数据当前我使用向上和向下箭头作为解决方法? 当我正在使用tab键更改焦点时,如何控制组框内的编辑控件? 我试图通过ID获取MFC控件,但失败了。我应该使用Spy++或其他框架以外的工具吗

编辑:

这是检查表。


我尝试使用id 1221和0x1221,但没有成功。

我使用MFC向导创建了一个看起来像visual studio的应用程序,并在“属性”窗口中添加了一个编辑控件,以便测试编辑控件。我无法添加组框,因为据我所知,CGroupBox不存在。如果你能提供一些代码来说明如何实现分组框,我可以将其添加到我的答案中

希望我能回答你的一些问题

这是我用C编写的控制台应用程序,用于自动执行列表框和编辑控件

 using System;
 using TestStack.White;
 using TestStack.White.UIItems;
 using TestStack.White.UIItems.Finders;
 using TestStack.White.UIItems.ListBoxItems;

 namespace ConsoleApplication1
 {
     public class Program
     {
         public static void Main(string[] args)
         {
             var application = Application.Attach("MFCApplication1");
             var window = application.GetWindow("MFCApplication11 - MFCApplication1");

             //Edit Control
             var propertyPane = window.Get<Panel>(SearchCriteria.ByAutomationId("150"));
             var edit = propertyPane.Get<TextBox>(SearchCriteria.ByAutomationId("1"));

             //Type this text into the edit control
             edit.Text = "Hello World";

             //List View
             var output = window.Get<Panel>(SearchCriteria.ByAutomationId("149"));
             var list = output.Get<ListBox>(SearchCriteria.ByAutomationId("2"));

             //Output the count of how many rows exist
             Console.Out.WriteLine(list.Items.Count);

             //Select the second row
             list.Items[1].Select();
         }
     }
 }
这是我测试的应用程序的一个图像,我自动突出显示了控件


不要实现任何类型的嵌套。在自动化方面,编辑控件是否位于GroupBox内没有区别。如果需要查看对象的可访问树,请改用该工具。我假设TestStack White使用相同的可访问树进行自动化。我不熟悉此测试框架,但谁将文本IDC_Edit转换为其数值?请发布inspect控件属性的屏幕截图。我回家后会看一看。我需要一点时间才能安装MFC应用程序,因为我以前从未使用过它。谢谢您的屏幕截图。当我关闭Visual Studio异常时,TextBox将开始工作。我无法选择列表中的任何一行,可能是因为它已绘制。在其他列表中,一切正常。谢谢你的建议。