39

I'm looking for a library that can be used in native .NET code, just like any .NET assembly. The purpose of the library must be to automate Windows (push a button, select a window, send keys, record & playback, that sort of thing).

So: the library is supposed to be used natively in .NET, but the automation itself must be able to target any native or .NET Windows application that can receive user input.


Suggestions so far:

If nothing else appears available, I'll probably choose Microsoft's UI Automation and upgrade any projects that require it that are still in .NET 2.0 to .NET 3.5, if possible. But I hope for a more widely applicable automation framework (.NET prior to 2.0 does not need to be supported).

Community
  • 1
  • 1
Abel
  • 56,041
  • 24
  • 146
  • 247

9 Answers9

11

Have you looked at the White framework?

Unmesh Gundecha
  • 560
  • 5
  • 10
  • Thanks for your answer. It looks good and it takes the pain away of using the UI Framework of WPF. However, it has the same drawbacks as WPF (when called from WinForms for instance), but it is possibly the best solution so far. – Abel Jan 21 '10 at 14:14
  • If you also have external Controls, you may want to verify that they can be automated with White: In this case you might want to use this http://www.codeplex.com/UIAutomationVerify . – tobsen Jan 23 '10 at 17:17
  • 1
    After some thought I decided to accept your answer. It is not exactly what I wanted (it limits me to use WPF when I want to include White or MS UI Automation), but it's arguably the best offer so far. Thanks! – Abel Jan 25 '10 at 09:17
  • 3
    Actually White is just a wrapper over MS UI Automation. – Yauheni Sivukha Nov 23 '12 at 22:19
8

microsoft's own built in one is fine

http://msdn.microsoft.com/en-us/library/ms747327.aspx

not restricted to wpf as some seem to think.

pm100
  • 48,078
  • 23
  • 82
  • 145
  • I wasn't aware of this new development. Surely interesting, but it locks me down to WPF. Considering I nearly only do .NET 3.5+ development (when I do .NET projects, that is) that shouldn't be a real problem though. – Abel Jan 12 '10 at 22:43
  • I don't think this locks you into WPF; it's the Windows standard UI automation library, and just happens to work with WPF now. MS Active Accessibility is your best option if you need to work downlevel. – JasonTrue Jan 12 '10 at 22:57
  • I don't seem to make myself very clear, sorry about that. I want to use the libs from programming code. Which requires WPF (which isn't a problem). Yes, of course it can automate anything in Windows, I totally understand, but that wasn't the point... ;-) – Abel Jan 12 '10 at 23:39
  • +1. As recommended in MSDN magazine http://msdn.microsoft.com/en-us/magazine/cc163465.aspx – MarkJ Jan 18 '10 at 11:25
  • It was a tough decision between your answer and White. But White is so much easier to use, it really takes away the complexity of Microsoft UI Automation, while still being able to falling back to the core if I want or need to. It is still in development, but it has potential. Both are WPF, no basic .NET application can use the lib, you need to include WPF. But that's just something I have to accept (or use hardcode AutoIt or CSharpScript). – Abel Jan 25 '10 at 09:16
8

I have used AutoIt in the past with success.

benPearce
  • 37,735
  • 14
  • 62
  • 96
  • Looks quite like something I need (and it rings a bell, too). Tx – Abel Jan 12 '10 at 22:41
  • Beat me to it! :) Yes, I would say check out AutoItX, which is a way to use AutoIt functionality from a DLL. – Adam Neal Jan 12 '10 at 22:47
  • Since I actually asked for a .NET lib: I don't imm. see how it can be used from within .NET. Can you either show an example or point to one how it can be called from .NET? – Abel Jan 12 '10 at 22:47
  • Some ruby test automation libraries do it by essentially creating a pipe to the I/O of the AutoIt executable. Ugly but it works. – JasonTrue Jan 12 '10 at 22:54
  • I think the bit of info missing is that AutoIt automates at the Windows level not .Net level, so pressing buttons on a form or setting contents of a textbox, could be any form. – benPearce Jan 12 '10 at 22:58
  • that's not really what I mean, I fully understand that it's possible to use AutoIt to automate an existing .NET program. But how can you create a .NET program that uses AutoIt (like a lib or a .NET assembly) to automate Windows. – Abel Jan 12 '10 at 23:19
  • If you include either the executable or the DLL version (AutoItX), you can either use the hacky method (System.Process.Start, for example) and call the AutoIt command-line app, or you can use normal DLL Interop mechanisms if you're using the DLL. – JasonTrue Jan 12 '10 at 23:37
  • Jason, thanks for the explanation, I totally agree and understand. But I was looking for .NET library. Calling into native code using interop is not what I call calling a .NET library... – Abel Jan 18 '10 at 01:20
3

If you haven't seen it yet, and a commercial library is acceptable, you might check out Ranorex:

http://www.ranorex.com/

I used Ranorex 1.5 quite a bit to write small C# UI automation utilities. It was pretty effective! Development seemed faster compared to using the MS UI Automation API directly, since Ranorex has a lot of useful convenience methods already available.

I haven't used Ranorex 2 very much yet, though.

In Ranorex 1.5, there was also support for traditional Win32 development in C++, but I didn't use it. As far as I know, that's still available in Ranorex 2.

I can't speak to the quality of the record/playback support in Ranorex since I never used that feature.

One final plus: Their support team was really responsive and helpful anytime I emailed them.

Bill Agee
  • 3,606
  • 20
  • 17
2

Check out Tools for automated GUI testing on windows

Community
  • 1
  • 1
SwDevMan81
  • 48,814
  • 22
  • 151
  • 184
2

This library is pretty interesting and is fairly simple. Perhaps it will help you.

Chris Dunaway
  • 10,974
  • 4
  • 36
  • 48
  • That's definitely interesting! Not actually an automation lib per se, but it's surely usable and up to that task it seems. I'll have a deeper look at it. – Abel Jan 12 '10 at 23:21
2

I would still suggest FlaUI for autoamating .Net Desktop,Mobile apps. Its based on Microsoft UIA libraries and have support for external controls like the DevExpress Grid too Moreover, it is built on top of TestStack.White so indeed a very good library and has a github page also

Apoorv
  • 2,023
  • 1
  • 19
  • 42
1

I have used WebAii from ArtOfTest with a fair degree of success in automating integration testing for a Silverlight app. It also supports WinForms and Web applications.

Microsoft UI Automation, the successor to Active Accessibility, can do almost all of the Windows UI automation you would need.

JasonTrue
  • 19,244
  • 4
  • 34
  • 61
  • Correct me if I'm wrong, but isn't that browser-automation? I'm really looking for Windows automation. Interesting to keep, though for other types of projects :) – Abel Jan 12 '10 at 22:45
  • You're right, it's certainly more focused on that domain, but it exposes Win32 controls as well. Microsoft UI Automation works for most automation that doesn't have to interact with browsers. http://en.wikipedia.org/wiki/Microsoft_UI_Automation – JasonTrue Jan 12 '10 at 22:51
1

How about CSharpScript, here's an article about it on Codeproject, and here's the link to the main website. Furthermore, it is familiar C#, scripted which can be used to automate anything.

Hope this helps, Best regards, Tom.

t0mm13b
  • 34,087
  • 8
  • 78
  • 110
  • That looks like a promising project that has its merits, but being a scripting language, how can it be applied for automation of "any" Windows application? – Abel Jan 24 '10 at 14:25
  • I wouldn't define it as a scripting language per se, the C# code can be used as a program in its own right, if you think of the Windows Scripting Host, or even AutoIt, even use p/invoke in the code, that's the flexibility of it. – t0mm13b Jan 24 '10 at 17:03