本文介绍了使用White UI自动化框架查找记事本的多行文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在学习White UI自动化框架. Windows 7 32位SP1,白色v 0.2.1.受害者是众所周知的notepad.exe..
场景很简单:
1.找到记事本的主窗口
2.找到一个多行编辑框
===>
由于某些原因,我无法使用White自动化框架执行此操作..

请查看下面的代码..

Hi,

I''m learning the White UI automation framework. Windows 7 32-bit SP1, White v 0.2.1. The victim is well known notepad.exe..
The scenario is very simple:
1. find notepad''s main window
2. find a multi-line edit box
===>
I cannot perform this action using White automation framework for some reasons..

Please look at the code snipped below..

string exeName = "notepad";
Process[] processes = Process.GetProcessesByName(exeName);
Application app = processes.Length == 0 ? Application.Launch(exeName) : Application.Attach(exeName);
Window window = app.GetWindow(SearchCriteria.ByNativeProperty(AutomationElement.ClassNameProperty, "Notepad"), InitializeOption.NoCache);
window.Focus();
Thread.Sleep(1000); // just in case..
// Exception below is thrown!
var edit = window.Get<MultilineTextBox>(SearchCriteria.ByAutomationId("15"));
/*
A QueryInterface call was made requesting the class interface of COM visible managed class 'MS.Internal.AutomationProxies.WindowsEditBox'. However since this class derives from non COM visible class 'MS.Internal.AutomationProxies.ProxyHwnd', the QueryInterface call will fail. This is done to prevent the non COM visible base class from being constrained by the COM versioning rules.
*/

// No exception, but edit is NULL!
var edit = window.Get<TextBox>(SearchCriteria.ByAutomationId("15"));
// Exception below is thrown!
AutomationElement edit = window.GetElement(SearchCriteria.ByAutomationId("15"));
/* A QueryInterface call was made requesting the class interface of COM visible managed class 'MS.Internal.AutomationProxies.WindowsEditBox'. However since this class derives from non COM visible class 'MS.Internal.AutomationProxies.ProxyHwnd', the QueryInterface call will fail. This is done to prevent the non COM visible base class from being constrained by the COM versioning rules.
*/

// OK.....
AutomationElement aeEdit= window.AutomationElement.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.AutomationIdProperty, "15"));



有任何想法吗?我想使用White,我什至在MFC应用程序上实现了相当困难的场景,并且几乎决定使用White,但是在那之后..卡在NOTEPAD.EXE上.


谢谢,
Aleksey



Any ideas? I would like to use White, I have even implemented rather difficult scenario on MFC application, and almost decided to use White, but after that.. get stuck on NOTEPAD.EXE..



Thanks,
Aleksey

推荐答案

报价:

Actuall此诊断不被视为例外,如果您为Auto UI程序构建发行版,则仅在调试Auto UI程序时显示.您的程序,它将正常运行,至少在我的演示中是这样.

Actuall this diag is not considered as an exception, it only display when you debug the Auto UI program, if you build a release version for your program, it will run normally, at least in my demo it was that.

报价:

您可以关闭托管调试"NonComVisibleBaseClass"异常的助手.在Visual Studio中,
1.导航到Debug-> Exceptions ...
2.展开托管调试助手"
3.取消选中"NonComVisibleBaseClass抛出"选项.
4.单击[确定]

You can turn off the managed Debugging Assistant for the "NonComVisibleBaseClass" exception. In Visual Studio,
1. Navigate to Debug->Exceptions...
2. Expand "Managed Debugging Assistants"
3. Uncheck the NonComVisibleBaseClass Thrown option.
4. Click [Ok]


这篇关于使用White UI自动化框架查找记事本的多行文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 15:14