Set up Appium 2 to Automate Windows Apps
Automating Windows Apps with Appium v2
This tutorial will show you how to set up Appium v2 on a Windows computer to automate a simple Windows desktop app (Calculator).
Set up Appium Server
First, install NodeJS.
Then, install Appium (v2) with NPM, from a command window:
> npm install -g appium
Setup Appium Client
I prefer Ruby as the scripting language, for reasons, check out this article, Why Ruby is the Best Scripting Language for End-to-End Test Automation?
For Ruby installation, check out this section in my another article.
Install the Ruby Appium client library:
> gem install --no-document appium_lib
Install the Appium Windows Driver
Appium, like Selenium, drives an app via external driver software.
To show available drivers:
> appium driver list
The output will look like this:
√ Listing available drivers
- windows@2.12.10 [installed (npm)]
- uiautomator2 [not installed]
- xcuitest [not installed]
- mac2 [not installed]
- espresso [not installed]
- safari [not installed]
- gecko [not installed]
- chromium [not installed]
Install the windows
driver.
> appium driver install --source=npm appium-windows-driver
Enable Developer mode on Windows 10
Type “developer features” in “Type here to search” box, and select “Use developer features” to go to the settings page.
Enable the “Developer mode” there.
Start up Appium Driver
Run appium
in a command window.
> appium
The output shall be like the below:
Keep it running.
Run a sample automation script
Create a sample automation script file: drive_calc.rb
, in a text editor, e.g. Notepad or Visual Studio Code.
require 'appium_lib'
opts = {
caps: {
automationName: "windows",
platformName: "Windows",
deviceName: "Dell",
app: "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App"
},
appium_lib: {
server_url: "http://127.0.0.1:4723",
wait: 0.5
}
}
driver = Appium::Driver.new(opts).start_driver
driver.find_element(:name, "One").click
driver.find_element(:name, "Plus").click
driver.find_element(:name, "Three").click
driver.find_element(:name, "Equals").click
result = driver.find_element(:accessibility_id, "CalculatorResults").text
puts(result)
Run this automation script in a command window.
> ruby drive_calc.rb
You shall see Calculator app launch and do a simple addition.
To learn scripting Appium, check out this book, Practical Desktop App Test Automation with Appium.
A Success Case Study
My father has built a comprehensive suite (over 300+ tests in Appium v1) for TestWise IDE.
A test execution report in BuildWise Continuous Testing Server.