Getting Started With Appium
Appium Instructions – Quick Start
Appium is a framework to do UIAutomation testing on iOS and Android
Here we look at Appium installation on Mac for iOS testing. In this part we look only at installation and playing with appium.
We are going to use UICatalog app that is available on Apple’s website. We are dealing with 11.3 version here.
So lets get started –
Steps to Install on MacOS –
Mac comes with Python and Ruby installed. But I do not recommend using inbuild ruby.
-
Install RVM(Ruby Version Manager) from here
Only with Ruby
\curl -sSL https://get.rvm.io | bash -s stable --ruby
-
Install Brew if not installed
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
-
Install Node.js
brew install node
-
Install appium server
npm install -g appium
-
Create a custom Gemset (assumes RVM is installed)
rvm gemset create appium
-
Install Appium gem
gem install appium_console
-
Verify Installation was successful (You should see appium_console and appium_lib)
gem list|grep appium
-
Download App (if you havent yet)
Running with Simulator
- Build app –
- Goto (working) folder where you will find *.xcodeproj for the UICatalog project.
- Check the sdks available on the disc by issuing command
xcodebuild -showsdks
- Build from command line using following commands. (Replace
with foreg: iphonesimulator8.3)
xcodebuild -configuration Release -target UICatalog -arch i386 -sdk <simulator sdk>
-
Create appium.txt in your working folder. This file is read by Appium(appium_lib) as input.
Sample appium.txt showing how to use Appium Server Capabilities caps
platformName = "iOS"
app = "./build/Release-iphonesimulator/UICatalog.app"
deviceName = "iPhone Simulator"
-
Start appium server in seperate tab.( I use iTerm for terminal)
appium
-
Start Console
Goto folder where appium.txt is created. Ensure
arc
Running with Device
-
Build app –
- Goto (working) folder where you will find *.xcodeproj for the UICatalog project.
- Check the sdks available on the disc by issuing command
xcodebuild -showsdks
-
Build from command line using following commands.
Replace
-
with foreg: iphoneos8.3 -
with certificate found in keychain foreg: "iPhone Developer: abc(C31234)" -
with provisioning profile found in keychain or use iPhone Configuration Utility foreg: "1234-efgh-ghjr-port"
-
xcodebuild -configuration Release -target UICatalog -sdk <iphone sdk> CODE_SIGN_IDENTITY="<Dev Certificate Name>" PROVISIONING_PROFILE="<Provisioning Profile uuid>"
-
Create appium.txt in your working folder. This file is read by Appium(appium_lib) as input.
Sample appium.txt showing how to use Appium Server Capabilities caps
platformName = "iOS"
app = "./build/Release-iphoneos/UICatalog.app"
deviceName = "iPhone"
-
Start appium server in seperate tab.( I use iTerm for terminal)
(find device uuid either using Xcode -> Orgnaniser or using iPhone Configuration Utility)
appium -U <device uuid>
-
Start Console
Goto folder where appium.txt is created. Ensure
arc
-
Exploring Elements –
-
By Command line – Refer here and here
We look at only 4 commands
-
Page_class – This will give bird’s eye view of iOS app structure
page_class
-
Page Elements (
page
command) – This will list all elements. Further elements can be explored like by name or by idpage
page 'UIAStaticText'
-
Find Elements by name –
find('Egg Benedict')
(Returns element id)find('Egg Benedict').name
(Returns Name Attribute for element)
-
Find Elements by id –
id('Egg').name
-
Ending Session –
x
-
-
By Inspector – Appium also provides with UIInspector. More info can be found here
-
Troubleshooting –
-
.. “`initialize’: platformName must be set. Not found in options:”
Have a look at your appium.txt. Ensure all parameters are set under quotes.Refer Sample appium.txt files
-
“Message: A new session could not be created. (Original error: Could not initialize ideviceinstaller; make sure it is installed and works on your system)”
Install ideviceinstaller from brew. Usually this is not required since appium is supposed to install that. But if it is still missing –
brew install ideviceinstaller