Click here to Skip to main content
11,644,731 members (67,799 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: UI Automation 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"));

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
Posted 12-Nov-12 9:11am
TRicK588

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Sorry guys, google rulit.. the answer might be interesting for others..
http://social.msdn.microsoft.com/Forums/is/Vsexpressvb/thread/27c3bae8-41fe-4db4-8022-e27d333f714e[^]
The main idea:
Quote:
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.
Quote:
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]
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 680
1 jyo.net 494
2 Sergey Alexandrovich Kryukov 464
3 Afzaal Ahmad Zeeshan 424
4 CPallini 386
0 OriginalGriff 1,020
1 Sergey Alexandrovich Kryukov 673
2 DamithSL 656
3 Afzaal Ahmad Zeeshan 652
4 CPallini 555


Advertise | Privacy | Mobile
Web02 | 2.8.150731.1 | Last Updated 12 Nov 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100