简体   繁体   中英

Looking for a GUI automation framework that works with .NET (WinForms)

Currently we're using AutoIT for automating a few internal tools built with WinForms.

This is not a smooth process since AutoIT does not handle .NET windows very well as far as I could see.

I'm looking for a framework that is:

  1. Free (or very cheap).
  2. Works with WinForms/WPF and any other .NET technology. By this I mean robust control identification that will redue overhead of maintaining the
    project with every small UI change of the application.
  3. No scripting/minimal scripting involved (if possible - in a popular language).
  4. Record mode to record runs.

You could use White . From the site:

White is a framework for automating rich client applications based on Win32, WinForms, WPF, Silverlight and SWT (Java) platforms. It is .NET based and does not require the use of any proprietary scripting languages. Tests/automation programs using White can be written with whatever .NET language, IDE and tools you are already using. White provides a consistent object-oriented API, hiding the complexity of Microsoft's UIAutomation library (on which White is based) and windows messages. Only stable versions of White are released, so all releases are production-ready.

Since your are looking to test automate .NET apps then presmably your are working in a .NET development house. If thats the case there is a good chance yor have an MSDN subscription . If you do AND if its at the Premium (or better) level then you can author UI automation tests using the Coded UI Test type within a Visual Studio test project .

  • This is free ASSUMING your already have an MSDN subscription at Premium or above
  • It tests WinForms, WPF and ASP.NET UI.
  • Its not as fully featured as a dedicated UI automation toolkit, but you may already own it!
  • Can author tests by recording the UX test run
  • If you have to change/customzie tests its no so much scripted but full bown .NET you get to edit; maximum power, but if you dont code .NET already also maximum learning curve

Posting explicit AutoIt code from the comments...

#include <DotNetIdentification.au3>

; "Test App" is a fake application with a control named "txtShowMe". 
$WindowName = "Test App"
$WindowText = ""

$control = NET_ControlGetHandleByName( $WindowName, $WindowText, "txtShowMe" )
if @error = 0 then 
    WinActivate( $WindowName, $WindowText )
    ControlFocus( $WindowName, $WindowText, $control )
endif

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