Click here to Skip to main content
15,896,479 members

Find notepad's multiline text box using White UI automation framework

TRicK asked:

Open original thread
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..

C#
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"));


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
Tags: UI, Automation

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900