# UI Automation Support

## Content

UI Automation (UIA) enables accessibility applications, such as screen readers, and coded UI testing to examine user-interface elements. It also enables simulated user interaction from code. The included C1.WPF.Automation library is a set of Automation Peer classes for the ComponentOne WPF controls. Each Automation Peer exposes a matching control class to the Microsoft automation framework so the control can be used effectively in automated UI tests.
There is a free tool called Inspect.exe that enables you to inspect the current UIA tree:
[http://msdn.microsoft.com/en-us/library/windows/desktop/dd318521(v=vs.85).aspx](http://msdn.microsoft.com/en-us/library/windows/desktop/dd318521(v=vs.85).aspx){:target="_blank"}
For more information on WPF accessibility for developers, see:
[http://msdn.microsoft.com/en-us/library/windows/desktop/gg712258.aspx](http://msdn.microsoft.com/en-us/library/windows/desktop/gg712258.aspx){:target="_blank"}

## UI Automation Testing

UI automation testing simplifies the automation of user interactions and validations within applications. ComponentOne controls integrate with testing tools to enable you to create highly effective UI testing environments. This integration allows developers to automate UI tests that can simulate user interactions with ComponentOne controls.
This document enables automation testers and developers to enhance and test applications using Appium.
Prerequisites require a basic understanding of Windows application testing, Appium, Windows Application Driver (WinAppDriver) and programming in C# .NET.

### Software Requirements

* Windows 10 or higher.
* Microsoft Visual Studio - Community Edition or higher with below features:
    * .NET Desktop developement
    * Nuget Package manager
    * Testing tools
* Windows Application Driver
* Node.JS
* Appium

### Automation Testing with Appium

Automation testing is helpful for testing and facilitates the agile software development lifecycle. Appium is an automation testing tool for UI Automation tests and Software Functional Testing for desktop applications. Appium also supports mobile automation. To use Appium with WinAppDriver, follow the below steps:

1. Enable Developer Mode through Windows **Settings \| Update & Security \| For Developers**.
2. Install **Node.JS**. You can download it from the link below:
    [https://nodejs.org/en/download](https://nodejs.org/en/download)
3. To install Appium follow the below steps:
    1. To open **Command** **Prompt**, press **Win + R** \| Type cmd and press **Enter**.
    2. In the Command Prompt, enter the command: **NPM install -g appium** and press Enter. This step installs the Appium on your computer.
4. Install the **WinAppDriver** by following the below steps:
    1. Go to the WinAppDriver github page, the URL is given below:
        [https://github.com/Microsoft/WinAppDriver](https://github.com/Microsoft/WinAppDriver)
    2. Click the **Releases** link, choose latest stable versions.
    3. Expand the **Assets** arrow.
    4. Click **WindowsApplicationDriver.msi** to download it. Once downloaded, install the WindowsApplicationDriver. Run WinAppDriver.

From the File Explorer find the **Windows Application Driver** folder in **Program Files(x86)** if 64-bit OS or **Program** **Files** otherwise. Run the **WinAppDriver.exe** file. The WinAppDriver uses **http** protocol on port number **4723** by default. Note, the WinAppDrive application will fail to start if this port number is not reachable.

>type=note
> **Note**: Run the **WinAppDriver.exe** first before running **WinAppDriver** based UI automation, else test scripts will fail. The **WinAppDriver** is a console application and does not contain an UI.

### Running Tests on Application

For running an Automation test application on any test app, you need to script the test cases that run test on your application. Follow the below steps to run test on your application using Appium:

1. Right-click the solution in **Solution** **Explorer**\. \| **Add a new project**\. \| **Choose Unit Test Project**.
2. Add the script for testing using **Appium**.
3. Run **WinAppDriver** application from the installed location.
4. Build your application.
5. Add the absolute path of the .exe file of your application from the windows explorer as parameter to WindowsDriver class in the test script.
6. Complete the test script as per your requirement.
7. Right-click on the Unit Test Project from the **Solution Explorer** \| **Choose** **Run** Tests.

Observe Appium running the test and reporting test results.