iOS Automation using Appium

123iOS Automation using Appium

This blog provides the information required to setup mobile testing environment in Mac OS X for testing iOS application using Appium.

Appium is an open source test automation tool for mobile applications. It allows you to test all the three types of mobile applications: native, hybrid and mobile web. It also allows you to run the automated tests on actual devices, emulators and simulators.

Pre-Requisites :

  • Mac OS X (10.7 or higher recommended)
  • XCode (8 and above recommended along with iphone simulator SDK and Command Line Tools should be installed on the MAC machine)
  • Apple Developer Tools (iPhone simulator SDK)
  • Appium Server (Appium-1.5.3.dmg)
  • Platform: iOS 9.3
  • Java (JDK and JRE) :- JavaForOSX2014-001.dmg
  • NodeJS :- http://nodejs.org/download/

Things required from Developer End:

  • Debug Build of Application (To test on simulator .app file is required and to test on Real Device .ipa file is required)
  • Bundle ID of application
  • Package Name of Application
  • Verified UDID of your device

Steps To Setup Appium Server on MAC OS:-

  1. Go to Appium Download Link
  2. Download the latest stable version of the software according to your OS.
  3. Install the downloaded appium .dmg file.
  4. After successful installation, launch Appium and click on the gear icon on the top-left side of the screen.
  5. Make sure that the “Server Address” field is set to the local address “0.0.0.0” and the “Port” field next to it is st to “4723” (or set it to another valid non-used port).

Things Required for Appium on iOS:-

  1. Homebrew
  2. brew doctor
  3. brew install node
  4. brew install ios-webkit-debug-proxy
  5. brew search (To search for an application)
  6. ideviceinstaller

*******************************************************************************************************

Launch Terminal and start the required software installation

Install Homebrew
To download install Homebrew run the install script on the command line as below and let the script do its thing:         ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

MacBook:~ tech$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

==> This script will install:

/usr/local/bin/brew
/usr/local/Library/...
/usr/local/share/man/man1/brew.1

Press RETURN to continue or any other key to abort
==> /usr/bin/sudo /bin/mkdir /usr/local
Password:
==> /usr/bin/sudo /bin/chmod g+rwx /usr/local
==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local
==> /usr/bin/sudo /bin/mkdir /Library/Caches/Homebrew
==> /usr/bin/sudo /bin/chmod g+rwx /Library/Caches/Homebrew

==> Downloading and installing Homebrew...
remote: Counting objects: 3633, done.
remote: Compressing objects: 100% (3466/3466), done.
remote: Total 3633 (delta 36), reused 697 (delta 26), pack-reused 0
Receiving objects: 100% (3633/3633), 2.93 MiB | 24.00 KiB/s, done.
Resolving deltas: 100% (36/36), done.

From https://github.com/Homebrew/homebrew
 * [new branch]      master     -> origin/master
Checking out files: 100% (3636/3636), done.
HEAD is now at 9a591af libxmp: update 4.3.9 bottle.

==> Installation successful!
==> Next steps
Run `brew help` to get started

MacBook:~ tech$ brew doctor

Your system is ready to brew.

MacBook:~ tech$ brew install node

==> Downloading https://homebrew.bintray.com/bottles/node-0.12.5.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring node-0.12.5.yosemite.bottle.tar.gz
==> Caveats
Bash completion has been installed to: /usr/local/etc/bash_completion.d
==> Summary
  /usr/local/Cellar/node/0.12.5: 2681 files, 29M

MacBook:~ tech$ brew install ios-webkit-debug-proxy
==> Installing dependencies for ios-webkit-debug-proxy: libxml2, libplist, libusb, usbmuxd, libtasn1, openssl, libimobiledevice
==> Installing ios-webkit-debug-proxy dependency: libxml2
==> Downloading https://homebrew.bintray.com/bottles/libxml2-2.9.2.yosemite.bottle.tar.gz
######################################################################## 100.0%

==> Pouring libxml2-2.9.2.yosemite.bottle.tar.gz
==> Caveats

This formula is keg-only, which means it was not symlinked into /usr/local.
OS X already provides this software and installing another version in parallel can cause all kinds of trouble.
Generally there are no consequences of this for you. If you build your own software and it requires this formula, you'll need to add to your build variables:

    LDFLAGS:  -L/usr/local/opt/libxml2/lib
    CPPFLAGS: -I/usr/local/opt/libxml2/include

==> Summary
  /usr/local/Cellar/libxml2/2.9.2: 275 files, 11M
==> Installing ios-webkit-debug-proxy dependency: libplist
==> Downloading https://homebrew.bintray.com/bottles/libplist-1.12.yosemite.bottle.tar.gz
######################################################################## 100.0%

==> Pouring libplist-1.12.yosemite.bottle.tar.gz
  /usr/local/Cellar/libplist/1.12: 26 files, 412K
==> Installing ios-webkit-debug-proxy dependency: libusb
==> Downloading https://homebrew.bintray.com/bottles/libusb-1.0.19.yosemite.bottle.1.tar.gz

######################################################################## 100.0%

==> Pouring libusb-1.0.19.yosemite.bottle.1.tar.gz
  /usr/local/Cellar/libusb/1.0.19: 11 files, 368K
==> Installing ios-webkit-debug-proxy dependency: usbmuxd
==> Downloading https://homebrew.bintray.com/bottles/usbmuxd-1.0.10.yosemite.bottle.1.tar.gz
######################################################################## 100.0%

==> Pouring usbmuxd-1.0.10.yosemite.bottle.1.tar.gz
  /usr/local/Cellar/usbmuxd/1.0.10: 11 files, 156K
==> Installing ios-webkit-debug-proxy dependency: libtasn1
==> Downloading https://homebrew.bintray.com/bottles/libtasn1-4.5.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring libtasn1-4.5.yosemite.bottle.tar.gz
  /usr/local/Cellar/libtasn1/4.5: 56 files, 572K
==> Installing ios-webkit-debug-proxy dependency: openssl
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2c.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring openssl-1.0.2c.yosemite.bottle.tar.gz
==> Caveats
A CA file has been bootstrapped using certificates from the system keychain. To add additional certificates, place .pem files in  /usr/local/etc/openssl/certs and run /usr/local/opt/openssl/bin/c_rehash
This formula is keg-only, which means it was not symlinked into /usr/local.
OS X already provides this software and installing another version in parallel can cause all kinds of trouble.
Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries

Generally there are no consequences of this for you. If you build your own software and it requires this formula, you'll need to add to your build variables:
    LDFLAGS:  -L/usr/local/opt/openssl/lib
    CPPFLAGS: -I/usr/local/opt/openssl/include
==> Summary
  /usr/local/Cellar/openssl/1.0.2c: 463 files, 18M
==> Installing ios-webkit-debug-proxy dependency: libimobiledevice
==> Downloading https://homebrew.bintray.com/bottles/libimobiledevice-1.2.0.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring libimobiledevice-1.2.0.yosemite.bottle.tar.gz
  /usr/local/Cellar/libimobiledevice/1.2.0: 64 files, 1.2M
==> Installing ios-webkit-debug-proxy
==> Downloading https://homebrew.bintray.com/bottles/ios-webkit-debug-proxy-1.4_2.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring ios-webkit-debug-proxy-1.4_2.yosemite.bottle.tar.gz

  /usr/local/Cellar/ios-webkit-debug-proxy/1.4_2: 16 files, 172K
MacBook:~ tech$ brew install ideviceinstaller
==> Installing ideviceinstaller dependency: libzip
==> Downloading https://homebrew.bintray.com/bottles/libzip-0.11.2.yosemite.bottle.2.tar.gz
######################################################################## 100.0%
==> Pouring libzip-0.11.2.yosemite.bottle.2.tar.gz
  /usr/local/Cellar/libzip/0.11.2: 81 files, 536K
==> Installing ideviceinstaller
==> Downloading https://homebrew.bintray.com/bottles/ideviceinstaller-1.1.0_1.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring ideviceinstaller-1.1.0_1.yosemite.bottle.tar.gz
  /usr/local/Cellar/ideviceinstaller/1.1.0_1: 7 files, 80K

MacBook:~ tech$

**************************************Installation Completed****************************************

After installing and as suggested in the command line, to check for any issues with the installation run:-
brew doctor
brew install node
brew install ios-webkit-debug-proxy

To search for an application:
brew search

Now the system is ready to test iOS Application using Appium.

*******************************************************************************************************

What are Desired Capabilities?
Desired Capabilities are a set of keys and values sent to the Appium server to tell the server what kind of automation session we’re interested in starting up.

Testing on Simulator :

Below are the steps to test and run the iOS App on Simulator:-

  1. Launch Simulator

    Steps to Launch Simulator:

    • Launch XCode from your machine and open your app’s project.
    • Navigate to XCode -> Open Developer Tool -> iOS Simulator and bring up the simulator.

7

    1. Launch Appium1
    2. Click on iOS settings on Appium3
    3. Check “App Path” if unchecked and enable the textbox next to it.
    4. Provide the absolute path to the .app file of your app.
    5. Check BundleID option and provide BundleID of the application .
    6. Check “Force Device” option and choose the most appropriate Device on which you wants to perform test
    7. Make sure that “UDID” option is unchecked.
    8. Check “Prelaunch application” option.It will launch the application successfully. Here in the below image it is unchecked.5
    9. Appium Server is ready to accept incoming requests from your tests. Run your server by clicking on the “Launch” button on top-right corner of Appium Server.

Testing on Real Device :

Below are the steps to test and run the iOS App on Real Device

  1. Connect your Device
  2. Be sure that the connected device UDID is associated with the test application( .ipa file )
  3. Launch Appium
  4. Click on iOS settings on Appium
  5. Check “App Path” if unchecked and enable the textbox next to it.
  6. Provide the absolute path to the .app file of your app.
  7. Check BundleID option and provide BundleID of the application .
  8. Check UDID option and provide UDID of the application.
  9. Appium Server is ready to accept incoming requests from your tests. Run your server by clicking on the “Launch” button on top-right corner of Appium Server.

Code to Run iOS Test using Appium on Real Device :

 

 

 

 

 

 

1 thought on “iOS Automation using Appium

Leave a Reply

%d bloggers like this: