![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | AutomationElement from Window hangs on AutomationElement.Current Hello all, I am using NUnit to unit test a WPF form. Issues with Nunit MTA threads and WPF STA Thread requirement have been handled. The NUnit thread now correctly receives any Assert exceptions from the delegated STA Thread running the WPF window. I am also instantiating AutomationElement in order to automate the window for testing. AutomationElement instance is hanging on Current property-get. I can step-through the TestAddressbookWorker() method below and teh debugger (and run-time out of debug mode) hangs at "x = aeWindow.Current.BoundingRectangle.Location.X;" In the CommandWindow-Immediate, inspection of abHelper results in "Function evaluation timed out." on the AcceleratorKey property and then "Function evaluation disabled..." on every subsequent property. I notice that the handle reported by "abHelper.Handle" is not the same as that reported on teh window by Spy++ during the debug session. I know that Spy++ is reporting Hex and Handle property is reporting IntPtr integer. The values from one debug session are : Spy++ : HxF09CE = 985550 abHelper.Handle : Hx8098A = 526730 I noticed in the WinFX Sample "InvokePattern and ExpandCollapsePattern Menu Item Sample " that the target window for automation is Win32 and in fact an instance of Notepad.exe. So I am very curious how to reconcile the sample with a pure-WinFX example that is calling only XAML windows. Thank you for your assistance and time investigating tthis one! using System; using System.Collections.Generic; using System.Text; using System.Threading; using System.Windows; using System.Windows.Automation; using System.Windows.Interop; using NUnit.Framework; namespace NunitTest { [TestFixture] public class Class1 { NUnitHelpers.CrossThreadTestRunner runner = new NUnitHelpers.CrossThreadTestRunner(); [Test] public void truthtest() { Assert.IsTrue(true); } [Test] public void falsetest() { Assert.IsTrue(false); } public static void TestAddressbookWorker() { Window ab = new AddressBookLib.Window1(); try { ab.Show(); WindowInteropHelper abHelper = new WindowInteropHelper(ab); IntPtr abHwnd = abHelper.Handle; AutomationElement aeWindow = AutomationElement.FromHandle(abHwnd); double x = -1d; x = aeWindow.Current.BoundingRectangle.Location.X; Assert.AreEqual(0, x); } finally { ab.Close(); ab = null; } } [Test] public void TestAddressBook() { runner.RunSTA(new ThreadStart(TestAddressbookWorker)); } } } |
My System Specs![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How do I keep the current window on top as new one loads? | mattfbuelow | Network & Internet | 6 | 3 Weeks Ago 01:34 PM |
| VS2005 Basic Hangs when changing from Code window to Design Window | ngrTerry | .NET General | 0 | 07-30-2008 06:56 AM |
| rundll code to close current window | ldvg | General Discussion | 2 | 07-11-2008 05:17 PM |
| Updating window title bar to current location | Marc Scheuner | PowerShell | 2 | 12-30-2007 03:42 PM |
| Vista - ? Mark - Current window Help | Rox | Vista General | 6 | 08-21-2007 06:19 AM |