Automate Windows Calculator (UWP) with Appium 2

Drive Windows UWP apps with Appium 2.

Running the UWP automated test in TestWise

Set up Appium Server

> npm install -g appium@next
> appium driver install windows
> appium driver list
√ Listing available drivers
- windows@2.3.5 [installed (NPM)]
...
> appium
[Appium] Welcome to Appium v2.0.0-beta.52
[Appium] Attempting to load driver windows...
[debug] [Appium] Requiring driver at C:\Users\ME\node_modules\appium-windows-driver
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
[Appium] Available drivers:
[Appium] - windows@2.3.5 (automationName 'Windows')
[Appium] No plugins have been installed. Use the "appium plugin" command to install
the one(s) you want to use.

Set Up Appium Client

> gem install --no-document appium_lib
> gem list appium

*** LOCAL GEMS ***
appium_lib (12.1.3)
appium_lib_core (5.7.0)

First Appium Desktop Automated Script

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"
}
}

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
> ruby simple_calc.rb
Display is 4
opts = {
caps: {
automationName: "windows",
platformName: "Windows",
deviceName: "Dell",
app: "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App"
},
appium_lib: {
server_url: "http://127.0.0.1:4723" # port appium server is running on
}
}
> Get-AppxPackage | out-string -stream | select-string Calculator

Name : Microsoft.WindowsCalculator
PackageFullName : Microsoft.WindowsCalculator_11.2210.0.0_x64__8wekyb3d8bbwe
InstallLocation : C:\Program Files\WindowsApps\Microsoft.WindowsCalculator_11.2210.0.0_x64__8wekyb3d8bbwe
PackageFamilyName : Microsoft.WindowsCalculator_8wekyb3d8bbwe

First Appium Desktop Automated Test

> gem install rspec
require 'appium_lib'
require 'rspec'

describe "Appium Windows UWP App - Calculator" do
before(:all) do
opts = {
caps: {
automationName: "windows",
platformName: "Windows",
deviceName: "Dell",
app: "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App"
},
appium_lib: {
server_url: "http://127.0.0.1:4723"
}
}
@driver = Appium::Driver.new(opts).start_driver
end

after(:all) do
@driver.quit
end

it "Simple Addition" do
@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
expect(result).to eq("Display is 4")
end
end
> rspec calc_spec.rb

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store