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?
-
Have you found any way to mock keyinputs on linux? – karoluS Sep 17 '18 at 22:21
3 Answers
You can use the the mono/.net core SendKeys class for cross platform.

- 2,024
- 2
- 17
- 29
-
1Thank 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
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

- 61,933
- 36
- 195
- 321