Set up Appium 2 to Run XCUITest (for iOS)

Setup and run an Appium 2 automated iOS test with XCUITestDriver

Image Credit: https://zhiminzhan.medium.com/recommend-a-great-ci-presentation-continuous-integration-at-facebook-6369323da084

“For all of our end-to-end tests at Facebook we use WebDriver, WebDriver is an open-source JSON wired protocol, I encourage you all check it out if you haven’t already. ” — Katie Coons, a software engineer at Product Stability, in “Continuous Integration at Facebook

Video clip from “Continuous Integration at Facebook
Microsoft deprecated Coded UI Test and recommend Selenium and Appium in 2018

Set up Appium Server

brew update # optional, updates brew and tells you if node has a newer version
brew upgrade node@18
brew install node@18
node -v
npm install -g appium@next
appium driver list
courtney@MacBook16 ~ % appium driver list
✔ Listing available drivers
- uiautomator2 [not installed]
- xcuitest [not installed]
- youiengine [not installed]
- windows [not installed]
- mac [not installed]
- mac2 [not installed]
- espresso [not installed]
- tizen [not installed]
- flutter [not installed]
- safari [not installed]
- gecko [not installed]
appium driver install xcuitest
courtney@MacBook16 ~ % appium driver install xcuitest
✔ Installing 'xcuitest' using NPM install spec 'appium-xcuitest-driver'
ℹ Driver xcuitest@4.13.3 successfully installed
- automationName: XCUITest
- platformNames: ["iOS","tvOS"]
appium

Set up Appium Server

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Xcode/Agents/

Download the demo iOS App

Appium Client

gem install --no-document appium_lib
require "appium_lib"
opts = {
caps: {
automationName: 'xcuitest',
platformName: 'ios',
platformVersion: '16.1', # match on in Xcode Simulator
deviceName: 'iPhone 12',
app: "/Users/me/ruby-ios/sample-apps/TestApp.app.zip"
},
appium_lib: {
server_url: "http://127.0.0.1:4723"
},
}
@driver = Appium::Driver.new(opts).start_driver
application_element = @driver.find_element :class_name, 'XCUIElementTypeApplication'
application_name = application_element.attribute :name
puts application_name
gem install rspec
describe "Appium XCUITest TestApp" do
  before(:all) do
opts = {
caps: {
automationName: 'xcuitest',
platformName: 'ios',
platformVersion: '16.1',
deviceName: 'iPhone 12',
app: "/Users/me/ruby-ios/sample-apps/TestApp.app.zip"
},
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 "Get App Name" do
application_element = @driver.find_element :class_name, 'XCUIElementTypeApplication'
application_name = application_element.attribute :name
expect(application_name).to eq("TestApp")
end
end
rspec xcuitest_appium_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