16

I need to automate desktop applications (not a web browser) testing on Windows, Mac and Linux. On Windows I use SendKeys, what do I use on Mac and Linux? Are there any cross-platform .NET Core SendKeys implementation that I can preferably use from xUnit?

IT Hit WebDAV
  • 5,652
  • 12
  • 61
  • 98

3 Answers3

6

You can use the the mono/.net core SendKeys class for cross platform.

Linux native - xdotool
Mac native - here and here.

igorc
  • 2,024
  • 2
  • 17
  • 29
  • 1
    Thank you Jason. Using SendKeys from .NET Core or .NET Standard would be a perfect solution. However as far as I understand SendKeys is not available in .NET Core (https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.sendkeys?view=netframework-4.7.1), as well as entire System.Windows.Forms namespace. Or am I missing something? – IT Hit WebDAV Jan 17 '18 at 00:47
6

I'm not sure what you are asking for makes sense.

.Net Core only has a subset of APIs in order to provide cross-platform functionality. i.e. shared libraries that will work on different platforms.

By definition this cannot include any platform-specific functionality and things like SendKeys or displaying message boxes (System.Windows.Forms) ARE platform-specific (even WPF and WinForms have different APIs for this).

Is there a .NET Core SendKeys implementation that I can preferably use from xUnit?

I think this is what is confusing me about your question. Unless you're using Selenium or a fat client test tool like SikuliX, EggPlant, HP Functional you don't actually write unit tests for the GUI.

These are often referred to as Integration, System or GUI tests.

Both Selenium & SikuliX are free and will run cross-platform. They can be used to Send Keys. Since you're not interested in Web, SikuliX is what you want.

Overview of SikuliX:

https://www.scribd.com/document/87620043/sikuliscript-Overview-by-student

Training Videos:

SikuliX Tutorial #1 - Intro & Setup https://www.youtube.com/watch?v=VdCOg1bCmGo

SikuliX Tutorial #2 - The Basics https://www.youtube.com/watch?v=I-UYoezac4Q

SikuliX Tutorial #3 - Conditional Automation https://www.youtube.com/watch?v=vuqfDdPlI88

SikuliX Tutorial #4 - Conditional Looping https://www.youtube.com/watch?v=Bb513yh6RGE

SikuliX Tutorial #5 - Game Example https://www.youtube.com/watch?v=xTTIikzxFfc&t=816s

Jeremy Thompson
  • 61,933
  • 36
  • 195
  • 321
2

I am developing a library that does exactly this.

https://github.com/lucassklp/Desktop.Robot

Lucas Simas
  • 141
  • 1
  • 6