SHAutomation is a .NET library to help with writing automated UI tests for Windows application. The project is a fork of FLAUI but with undeeded code removed and various fixes/enhancements implemented.
There was a lot of what FLAUI did that was really good but there were a few bits it didn't do too well or we thought we could improve. We removed everything that was obsolete or we thought wasn't really needed anymore such as UIA2. We tidied up a few bits and made everything a bit more user friendly.
Simply install the SHAutomation nuget package, either use the Nuget package manager in Visual Studio or run the following command in the package manager console.
Install-Package SHAutomation
To interact with an application start by launching it and then getting the main window. From there you can find elements and interact with the application UI.
using StreetsHeaver.SHAutomation.UIA3;
using var application = Application.Launch("Application.exe");
{
var window = application.GetMainWindow(automation);
var element = window.Find("elementAutomationId");
}
To interact with an element you would call Click
after finding the element
using StreetsHeaver.SHAutomation.UIA3;
using var application = Application.Launch("Application.exe");
{
var window = application.GetMainWindow(automation);
var element = window.Find("elementAutomationId").Click();
}
Once your code has finished running the application will automatically be closed.
For advanced features and more examples please see the Wiki.