简体   繁体   English

自动化Windows GUI测试 - FindWindowEx和控件类

[英]Automating Windows GUI Testing - FindWindowEx and Control Classes

I've inherited a C# window's application that I'm not real crazy about. 我继承了一个C#window的应用程序,我并不是真的很疯狂。 I've got a looming deadline and I'm scared to death that some of my changes might be having adverse effects on existing functionality. 我有一个迫在眉睫的截止日期,我害怕我的一些变化可能对现有功能产生不利影响。

I've got a hobbyist background to RoR and I'm fairly comfortable with testing in that framework (using both RSpec and Cucumber). 我对RoR有一个业余爱好者的背景,我对在该框架中进行测试感到相当舒服(使用RSpec和Cucumber)。

I love having test scripts that can be ran on a regular basis and I'm willing to spend my personal time developing those for this particular project. 我喜欢有可以定期运行的测试脚本,而且我愿意花个人时间为这个特定的项目开发那些。 I purchased a book from PragProg.com on scripted GUI testing with Ruby ( http://pragprog.com/titles/idgtr/scripted-gui-testing-with-ruby ). 我从PragProg.com购买了一本关于使用Ruby进行脚本化GUI测试的书( http://pragprog.com/titles/idgtr/scripted-gui-testing-with-ruby )。 So far, I'm digging what I'm seeing and I think that this should work well. 到目前为止,我正在挖掘我所看到的东西,我认为这应该很有效。

Unfortunately, I've got a fundamental lack of understanding concerning Windows app development. 不幸的是,我对Windows应用程序开发缺乏了解。 I'm making calles to FindWindowEx (via Win32API) to "attempt" to retrieve sub-controls in my application. 我正在使FindWindowEx (通过Win32API)来“尝试”检索我的应用程序中的子控件。

A big part of my confusion is how I should retrieve the Class Name of the control that I'm trying to capture. 我的困惑很大一部分是我应该如何检索我想要捕获的控件的类名。 The example provided in the text is as follows: 文中提供的示例如下:

    edit = find_window_ex.call @main_window, 0, 'ATL:00434310', nil

Where @main_window is my application's main window handle, and 'ATL:...' is the class of a text box area. 其中@main_window是我的应用程序的主窗口句柄,'ATL:...'是文本框区域的类。 There is no explanation given as to how the author arrived at 'ATL:...'. 关于作者如何到达'ATL:......'没有解释。

I've read some very old posts concerning MS's SPY++, but those seem to be obsolete (or for some reason it wasn't installed when I installed vs2010). 我已经阅读了一些关于MS的SPY ++的非常老的帖子,但那些似乎已经过时了(或者出于某种原因,当我安装vs2010时没有安装它)。

So, what's the best way for me to find control classes to be used with the findWindowEx call? 那么,找到与findWindowEx调用一起使用的控件类的最佳方法是什么? I do have the source code - should I be pulling from there? 我有源代码 - 我应该从那里拉? What if I don't have the source code and I want to automate an application? 如果我没有源代码并希望自动化应用程序怎么办? Is there a utility that allows you to somehow "browse" controls on a running application? 是否有一个实用程序,允许您以某种方式“浏览”正在运行的应用程序上的控件?

Sorry for the length - thanks in advance for the help! 对不起,请提前感谢您的帮助! Bob 短发

The best is for you to install the components so that you get Spy++, this is the best way I know of to get to the actual class names esp. 最好的安装组件,以便你得到Spy ++,这是我所知道的最好的方式来获得实际的类名esp。 if you do not have the source to the original controls, which might be from a library or possibly some standard ActiveX controls that Microsoft ships. 如果您没有原始控件的源,可能来自库或Microsoft可能提供的某些标准ActiveX控件。

The ATL class name is probably for controls developed using Microsoft Active Template Library (ATL), this is a C++ template library which significantly simplifies the development of ActiveX controls, and COM objects etc. in C++. ATL类名称可能用于使用Microsoft活动模板库 (ATL)开发的控件,这是一个C ++模板库,它显着简化了C ++中ActiveX控件和COM对象等的开发。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM