A generic, decoupled Windows UI Automation framework using gRPC.
Standard Windows UI Automation code is often tightly coupled to the machine running the automation. This creates challenges for:
- Remote Automation: Driving UI on a separate machine (e.g., a dedicated test rig) from a developer's workstation or CI runner.
- Language Interop: Writing test logic in languages other than C#/.NET (since standard UIA is .NET/COM based).
- Separation of Concerns: Mixing low-level "how to click" logic with high-level "business workflow" logic.
UiAutomationGRPC solves this by splitting the automation into two distinct components:
- The Server (Active Driver): A Windows Service running on the target machine. It has full access to the Windows desktop and exposes the UI Automation capabilities via a generic gRPC API.
- The Client (Test Controller): A lightweight library (SDK) that sends commands to the Server. It can run anywhere network-reachable to the server.
This architecture allows you to write tests that say "Find the button called 'Submit'" without worrying about how that command is executed on the specific Windows instance.
graph TD
Client[Client App] -->|gRPC Command| Server[UiAutomation Service]
Server -->|UIA API| Target[Target Application]
Target -.->|UI State| Server
Server -.->|Status/Response| Client
classDef client fill:#0d548c,stroke:#4c381e,stroke-width:2px;
classDef server fill:#4c381e,stroke:#0d548c,stroke-width:2px;
classDef target fill:#0d548c,stroke:#4c381e,stroke-width:2px;
class Client client;
class Server server;
class Target target;
-
UiAutomationGRPC.Server The generic host service. It implements the gRPC definitions and translates them into actual Windows UI Automation calls (e.g.,
AutomationElement.Find(...)). It can be installed as a Windows Service. -
UiAutomationGRPC.Library The client-side SDK. It hides the complexity of gRPC and provides a clean C# API (e.g.,
driver.FindElement(...)) for developers to write automation scripts. -
UiAutomationGRPC.Client A sample console application demonstrating how to use the Library to automate the Windows Calculator. It serves as a reference implementation for your own test projects.
- Server Machine: Windows OS, Administrator privileges (for Service installation).
- Development: .NET Framework 4.7.2 or later.
You can run the server as a console app for testing, or install it as a service for production.
# From UiAutomationGRPC.Server/bin/Debug/net472/
.\UiAutomationGRPC.Server.exeReference UiAutomationGRPC.Library in your project and connect to the server:
using UiAutomationGRPC.Library;
// Connect to localhost (or remote IP)
using (var driver = new UiAutomationDriver("127.0.0.1:50051"))
{
// Find generic element
var calcWindow = driver.FindElement(new SelectorModel
{
Conditions = new PropertyConditions().NameProperty("Calculator")
});
// Interact
// ...
}See UiAutomationGRPC.Client/README.md for a full tutorial.