简体   繁体   中英

WPF Automation Testing without Automation Framework?

This is probably a bit crazy/nuts, but is there any way to perform WPF Automation Testing without using the MS Automation Peer framework?

There are several times when I actually need the UIElement/FrameworkElement and would like to access that directly. I was looking into Snoop to try and deal with it, but it looked like it was a bit painful to "inject" into a process.

I've tried connecting to the process that is launched (we're currently using SpecFlow), but any attempt to marshall the Process or Window thread (I've looked for the actual Window's proc ID and tried connecting) results in a null from the HwndSource. I was trying to also create an instance of the Application inside my unit test, but it looks like NUnit has issues with launching the Application in the background (even on a STA Thread), because the second a test starts trying to load, the Application starts blocking.

Has anyone had any success in doing something else? My only thoughts to "solve" the problem now would be to create a special AutomationPeer that I could reflect to and then get the FrameworkElement from, or something like that.

Any thoughts?

No, there's nothing that can marshal WPF elements (especially underlying native elements such as graphic resources, images, etc.) across processes, and UI Automation works by definition across processes.

If you own the target application, you can dramatically increase its "UIAutomation-ness" if you create AutomationPeers specific for your app.

Otherwise, the snoop way (process injection) is the only way (but has a lot of drawbacks, including security issues).

If this is the case:

any way to perform WPF Automation Testing without using the MS Automation Peer framework?

you can use the Telerik's Testing Studio , it's rich and with some coding you'll get use to it. Another plus is the good documentation and the help that can be provided by them.

To be honest it took me a while, but since the Framework is free I finally decide to use it over the MS alternative.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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