Appium Installation full setup on Mac for real device iOS automation (GUI & Command line tools)

Here I have displayed the procedure for the complete installation of Appium in mac for real device iOS automation. I have given the steps for Command line tool installation and GUI installation of appium in mac.

Command Line Tool Installation of Appium in MAC

Step 1 : Install java JDK:


Step 2 : Install Android Studio:


Scroll till last and find the software as below: 

android-studio-ide-173.4819257-mac.dmg

Step 3 : Install Home brew

--> In Terminal install brew:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Step 4 : Install Node.js

--> install node.js:

download installer: https://nodejs.org/en/download/ and run

Step 5 : Install npm

--> In Terminal install npm:
brew update
brew install node
npm install -g npm


Step 6 : To setup Environment 

To open bash_profile in terminal, type the following command:
nano ~/.bash_profile

or

open -e .bash_profile
If bash profile not available, create a bash_profile by following command

  1. Start up Terminal
  2. Type "cd ~/" to go to your home folder
  3. Type "touch .bash_profile" to create your new file.
  4. Edit .bash_profile with your favorite editor (or you can just type "open -e .bash_profile" to open it in TextEdit.
paste following:

export ANDROID_HOME=/Users/user/Library/Android/sdk
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH

export JAVA_HOME=$(/Library/Java/JavaVirtualMachines/jdk1.8.0_141.jdk)
export PATH=${JAVA_HOME}/Contents/Home/bin:$PATH
export PATH=/usr/local/bin:/usr/local/sbin:~/bin:$PATH

export PATH=$PATH:/opt/bin:$PATH
save (Ctrl+S) and exit

NOTE : As default Android studio and Java takes the above path, if you have changed the path then do change it here with correct version

Step 7. Install Appium

In Terminal install Appium command line:
npm install -g appium@1.6.0-beta1
npm install wd
Step 8. Install Carthage 

Now type the following command to get into WebDriverAgent and Install carthage:
cd /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent

brew install carthage

npm i -g webpack
Step 9. Run Appium in command line

From above steps do 'cd' to get out of all subfolders and then type 'appium'

- cd
- appium

If everything works correct you should get the following line 

[Appium] Welcome to Appium v1.6.0-beta1
[Appium] Appium REST http interface listener started on 0.0.0.0:4723

GUI Installation of Appium in MAC


Follow the Same steps from command line tools from Step 1 to Step 6




Step 7 : Download Appium Desktop 

--> Download Link : https://github.com/appium/appium-desktop/releases

Download the available version for your convenient as 'dmg' file, as my suggestion don't go with the recent release version there might be an issue or bug will exist. So I'd prefer to go with the previous version of latest release version.

Step 8 : Installation Appium Desktop

Once installed Go to 'Application' and right click on 'Appium Desktop' (What you have Downloaded and installed) to show package contents. Then follow the subfolders to get in

-  Contents -> Resources -> app -> node_modules -> appium -> node_modules-> appium-xcuitest-driver -> WebDriverAgent 

Step 9 : Setup Webdriver Agent Server

In terminal do 'cd' space and drag the WebDriverAgent folder and make sure that you are in WebdriverAgent folder and follow the below command

mkdir -p Resources/WebDriverAgent.bundle
    ./Scripts/bootstrap.sh -d
Step 10 : Two pieces of software are currently necessary to run iOS tests on real devices:
Type 'cd' in terminal to get out of sub folders and follow the below commands
  1.  brew install libimobiledevice --HEAD
  2. brew install ideviceinstaller
  3. brew install carthage
  4. npm install -g ios-deploy
  5.  gem install xcpretty
Step 11 :  Open WebDriverAgent.xcodeproj in Xcode. 
Now Go to WebDriverAgent folder as mentioned above in terminal and Open WebDriverAgent.xcodeproj in Xcode. 
For both the WebDriverAgentLib and WebDriverAgentRunner targets, select "Automatically manage signing" in the "General" tab, and then select your Development Team. This should also auto select Signing Ceritificate
By going into the "Build Settings" tab, and changing the "Product Bundle Identifier" from com.facebook.WebDriverAgentRunner to something that 'com.twitter.WebDriverAgentRunner' and enter so that Xcode will accept
Going back to the "General" tab for the WebDriverAgentRunner target, you should now see that it has created a provisioning profile and all is well
Refer below link for more information 
Step 11 : Run WebDriverAgent on your real device from Xcode
-- In Xcode - Click on Product - Do Test - Now you would see webdriver agent running on your connected device
When finished running 
In terminal - in same webdriver Agent folder - 
Do the following Command by replacing the udid as device udid
where udid can be taken from itunes by connecting device
xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=<udid>' test
If this was successful, the output should end with something like:
    Test Suite 'All tests' started at 2017-01-23 15:49:12.585
    Test Suite 'WebDriverAgentRunner.xctest' started at 2017-01-23 15:49:12.586
    Test Suite 'UITestingUITests' started at 2017-01-23 15:49:12.587
    Test Case '-[UITestingUITests testRunner]' started.
        t =     0.00s     Start Test at 2017-01-23 15:49:12.588
        t =     0.00s     Set Up
Step 12 : If above works fine, then you can use your application and run for automation in real device.

-- Get Full project code from bitbucket and open in your Xcode and make sure code signing works fine.

-- Now run the build from your Xcode in your device and once you successfully generated the build from your Xcode

-- In xcode - Click on File -> Workspace Setting - > above advanced menu - click on path derived data (Right arrow) 

-- Now you will get the window popup displayed with recent folder as Derived Data -> Select appname...-> Bulid -> Products -> Debug-iphoneos-> scroll to find the app with recent date and time 

-- Copy the app and paste in your comfortable folder like /Users/user/Documents/yourapp.app

NOTE : For More clarification see the below video link


Step 13 : Open Appium app 

Now, you can open the Appium app from 'Application' and start the Server.

You can add the desired Capabilities 

"platformName": "iOS",
    "platformVersion": "11.0",
    "deviceName": "iPhone 7",
    "automationName": "XCUITest",
    "app": "/path/to/my.app"
Installation of appium in Mac for real device configuration
Installation of appium in Mac for real device configuration

Now you can start the session and you able to see the app gets launched and installed in your device and UI will get displayed.


Post Author Written and Executed by Siddarth

13 comments:

  1. how to find the appium inspector for mac ios

    ReplyDelete
    Replies
    1. Appium inspector not required for mac since you can use Appium-desktop with an already built in inspector:

      Delete
  2. Do we need to follow same steps if I need to automate mobile web application on safari browser?

    ReplyDelete
    Replies
    1. Also, is it necessary to use SafariLauncher proj to run application on safari browser?

      Delete
    2. yes follow the same and in capabilities change as per for browser

      Delete
  3. This comment has been removed by the author.

    ReplyDelete
  4. very nice post .thank you..
    If you want more info visit this blogs.
    ios app development course
    learn ios app development

    ReplyDelete
  5. Great learning experience with proficient trainers in Informatica. Flexible timings with hands on experience with real time scenarios.
    Bpm Tools Training in Bangalore

    ReplyDelete
  6. This information really helped me a lot. It was very informative.
    Devops Services

    ReplyDelete
  7. You’re so interesting! I don’t believe I’ve truly read something like this before. So great to find someone with genuine thoughts on this issue. Really.. many thanks for starting this up. This website is something that’s needed on the internet, someone with some originality!

    CBSE Schools In Ahmedabad
    CBSE Schools In Surat
    CBSE Schools In Rajkot
    CBSE Schools In Visakhapatnam
    CBSE Schools In Kangra
    CBSE Schools In Shimla
    CBSE Schools In Jammu
    CBSE Schools In Solan
    CBSE Schools In Mangalore
    CBSE Schools In Mysore

    ReplyDelete