SlideShare ist ein Scribd-Unternehmen logo
1 von 19
Setting Apple’s
UIAutomation Free
      with Appium
                          Dan Cuellar
                        d@zoosk.com
    Lead Software Engineer, Test Team
Overview
 The Problem

 The Solution
   Run UIAutomation From The Command Line
   Break It Out Of Javascript
   Control it in Real-Time

 How to Code With Appium

 Demo

 Odds & Ends
The Problem
The Problem w/ UIAutomation
 runs only in Instruments.app
 must be written in Javascript
 does not support realtime control
 many useful js methods (e.g. HTTP requests) have been
  removed
 difficult to build libraries and re-use code
 cannot integrate w/ existing Selenium automation
 requires adding http servers to your app’s source code
The Solution
Solving the Problem
 need command line control

 needs to run on the simulator and real devices

 need to break out of javascript

 need realtime control

 should not require you to add code to your app

 shoud not require the application source code
Command Line Control
 /usr/bin/instruments
     -t templatePath (path to Automation.tracetemplate)
     (path to compiled ios application)
     -e UIASCRIPT (path to UIAutomation javascript test)
     -e UIARESULTSPATH (path where results will be saved)
     [-w device udid]

 /usr/bin/xcodebuild (run inside project.xcodeproj)
     -sdk (sdk version)
     -target (build target)
     [-scheme (scheme)]
     TARGETED_DEVICE_FAMILY=1|2 (1=iPhone, 2=iPad)
Breaking Out Of Javascript
No HTTP Web Requests in UIAutomation JS

However…

host.performTaskWithPathArgumentsTimeout() can run all
your favorite shell commands

so with friends like cat, curl, and python who needs
Javascript and its HTTP web request methods

… and Don’t Forget the AppleScript (comes in handy when
you need to dismiss OS permissions dialogs)
Making It Real-Time
 Technique 1, file based communication
   Javascript loop looking for sequentially number files in a
    predetermined folder for commands
   Have your program write raw javascript to the file
   Read the file using cat
   Run the command using eval()
   Write the sequentially numbered response file using
    whatever you like (I chose python)

 Technique 2, setup a proxy web service
   Curl to ask if there’s a command you should run
   Curl back posting the result
Result
 Now you can control UIAutomation from any language
  that can write files or make web requests
   You can reuse all that non javascript based (java, c#,
    python, ruby, php) automation code you have for your
    selenium tests
   Run tests that use a web browser and an iOS device at the
    same time
   The possibilities are endless
Coding w/ Appium
Pre-Requisites
 install Xcode

 install Xcode Command Line Tools

 Set up a ~/.appium file
  [appium]
  username = an_osx_admin_username
  password = an_osx_admin_password

OPTIONAL

 sudo easy_install pip

 sudo pip install bottle (required for webdriver server)

 sudo pip install selenium (required to code against the webdriver
  server)
Running Appium
 git clone git://github.com/hugs/appium

 To launch the UIAutomation javascript interpretter
   python appium.py “/path/to/my.app”

 To launch the webdriver server
   Python server.py “/path/to/my.app”
Coding Appium like Selenium
from selenium import webdriver

command_url = “http://localhost:4723/wd/hub”
iphone = webdriver.DesiredCapabilities.IPHONE

driver = webdriver.Remote(command_url, iphone)

fields = driver.find_elements_by_tag_name('textField’)
fields[0].send_keys(3)
fields[1].send_keys(4)

buttons = driver.find_elements_by_tag_name('button’)
buttons[0].click()
Demo
Odds & Ends
Failed Prototypes
 Applescript iOS Simulator Automation
   Did not work on actual devices
   Seemed to be highly sensitive to iOS and OS X version
   Not a reliable

 Javascript Server Within UIAutomation
   I could not get a server booted up while running in
    Instruments
Pitfalls
 Bug in UIAutomation causes 1 second delay between
  commands
   I get around this by sending batches of commands

 Noticed NIBs and XIBs are supported while storyboards
  are a more of a crapshoot

 It’s tricky to make elements accessible in objective C
   Some controls (UISegmentedControl) are missing supported
    accessibility methods
   Applying a label to text will hinder your ability to read the
    text in the control (you need to encapsulate it)
Resources
Appium Project
   https://github.com/hugs/appium or
    http://appium.io



Discussion
   https://groups.google.com/d/forum/appium-discuss

Weitere ähnliche Inhalte

Was ist angesagt?

Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...Ondřej Machulda
 
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)Ondřej Machulda
 
Browser Automated Testing Frameworks - Nightwatch.js
Browser Automated Testing Frameworks - Nightwatch.jsBrowser Automated Testing Frameworks - Nightwatch.js
Browser Automated Testing Frameworks - Nightwatch.jsLuís Bastião Silva
 
Automated Smoke Tests with Protractor
Automated Smoke Tests with ProtractorAutomated Smoke Tests with Protractor
Automated Smoke Tests with Protractor🌱 Dale Spoonemore
 
Tech Talk #5 : Android Automation Test with Espresso - Trần Văn Toàn
Tech Talk #5 : Android Automation Test with Espresso - Trần Văn ToànTech Talk #5 : Android Automation Test with Espresso - Trần Văn Toàn
Tech Talk #5 : Android Automation Test with Espresso - Trần Văn ToànNexus FrontierTech
 
Titanium - Making the most of your single thread
Titanium - Making the most of your single threadTitanium - Making the most of your single thread
Titanium - Making the most of your single threadRonald Treur
 
Automated ui testing with selenium. drupal con london 2011
Automated ui testing with selenium. drupal con london 2011Automated ui testing with selenium. drupal con london 2011
Automated ui testing with selenium. drupal con london 2011Yuriy Gerasimov
 
React Native: The Development Flow
React Native: The Development FlowReact Native: The Development Flow
React Native: The Development FlowRitesh Kumar
 
The current state of web
The current state of webThe current state of web
The current state of webRitesh Kumar
 
Front-End Testing: Demystified
Front-End Testing: DemystifiedFront-End Testing: Demystified
Front-End Testing: DemystifiedSeth McLaughlin
 
Uploading files using selenium web driver
Uploading files using selenium web driverUploading files using selenium web driver
Uploading files using selenium web driverPankaj Biswas
 
Continous UI testing with Espresso and Jenkins
Continous UI testing with Espresso and JenkinsContinous UI testing with Espresso and Jenkins
Continous UI testing with Espresso and JenkinsSylwester Madej
 
Introduction to Selenium IDE
Introduction to Selenium IDEIntroduction to Selenium IDE
Introduction to Selenium IDEdrnikki
 

Was ist angesagt? (20)

Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
Workshop: Functional testing made easy with PHPUnit & Selenium (phpCE Poland,...
 
Java Applet
Java AppletJava Applet
Java Applet
 
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
 
Browser Automated Testing Frameworks - Nightwatch.js
Browser Automated Testing Frameworks - Nightwatch.jsBrowser Automated Testing Frameworks - Nightwatch.js
Browser Automated Testing Frameworks - Nightwatch.js
 
Automated Smoke Tests with Protractor
Automated Smoke Tests with ProtractorAutomated Smoke Tests with Protractor
Automated Smoke Tests with Protractor
 
applet using java
applet using javaapplet using java
applet using java
 
Tech Talk #5 : Android Automation Test with Espresso - Trần Văn Toàn
Tech Talk #5 : Android Automation Test with Espresso - Trần Văn ToànTech Talk #5 : Android Automation Test with Espresso - Trần Văn Toàn
Tech Talk #5 : Android Automation Test with Espresso - Trần Văn Toàn
 
Titanium - Making the most of your single thread
Titanium - Making the most of your single threadTitanium - Making the most of your single thread
Titanium - Making the most of your single thread
 
Java applet
Java appletJava applet
Java applet
 
Automated ui testing with selenium. drupal con london 2011
Automated ui testing with selenium. drupal con london 2011Automated ui testing with selenium. drupal con london 2011
Automated ui testing with selenium. drupal con london 2011
 
React Native: The Development Flow
React Native: The Development FlowReact Native: The Development Flow
React Native: The Development Flow
 
The current state of web
The current state of webThe current state of web
The current state of web
 
Front-End Testing: Demystified
Front-End Testing: DemystifiedFront-End Testing: Demystified
Front-End Testing: Demystified
 
Selenium IDE
Selenium IDESelenium IDE
Selenium IDE
 
Uploading files using selenium web driver
Uploading files using selenium web driverUploading files using selenium web driver
Uploading files using selenium web driver
 
Continous UI testing with Espresso and Jenkins
Continous UI testing with Espresso and JenkinsContinous UI testing with Espresso and Jenkins
Continous UI testing with Espresso and Jenkins
 
Introduction to Selenium IDE
Introduction to Selenium IDEIntroduction to Selenium IDE
Introduction to Selenium IDE
 
Java Applets
Java AppletsJava Applets
Java Applets
 
Selenium Overview
Selenium OverviewSelenium Overview
Selenium Overview
 
Selenium Automation
Selenium AutomationSelenium Automation
Selenium Automation
 

Ähnlich wie Setting Apple's UI Automation Free with Appium

Android UI Testing with Appium
Android UI Testing with AppiumAndroid UI Testing with Appium
Android UI Testing with AppiumLuke Maung
 
Plug yourself in and your app will never be the same (1 hr edition)
Plug yourself in and your app will never be the same (1 hr edition)Plug yourself in and your app will never be the same (1 hr edition)
Plug yourself in and your app will never be the same (1 hr edition)Mikkel Flindt Heisterberg
 
Introduction to Software Development
Introduction to Software DevelopmentIntroduction to Software Development
Introduction to Software DevelopmentZeeshan MIrza
 
ApppiumDoc_version2015
ApppiumDoc_version2015ApppiumDoc_version2015
ApppiumDoc_version2015Amit DEWAN
 
[JMaghreb 2014] Developing JavaScript Mobile Apps Using Apache Cordova
[JMaghreb 2014] Developing JavaScript Mobile Apps Using Apache Cordova[JMaghreb 2014] Developing JavaScript Mobile Apps Using Apache Cordova
[JMaghreb 2014] Developing JavaScript Mobile Apps Using Apache CordovaHazem Saleh
 
The Future of Selenium Testing for Mobile Web and Native Apps
The Future of Selenium Testing for Mobile Web and Native AppsThe Future of Selenium Testing for Mobile Web and Native Apps
The Future of Selenium Testing for Mobile Web and Native AppsSauce Labs
 
RichFaces - Testing on Mobile Devices
RichFaces - Testing on Mobile DevicesRichFaces - Testing on Mobile Devices
RichFaces - Testing on Mobile DevicesPavol Pitoňák
 
Good practices for debugging Selenium and Appium tests
Good practices for debugging Selenium and Appium testsGood practices for debugging Selenium and Appium tests
Good practices for debugging Selenium and Appium testsAbhijeet Vaikar
 
Electron - cross platform desktop applications made easy
Electron - cross platform desktop applications made easyElectron - cross platform desktop applications made easy
Electron - cross platform desktop applications made easyUlrich Krause
 
Appium understanding document
Appium understanding documentAppium understanding document
Appium understanding documentAkshay Pillay
 
Android Programming made easy
Android Programming made easyAndroid Programming made easy
Android Programming made easyLars Vogel
 
Apache Cordova In Action
Apache Cordova In ActionApache Cordova In Action
Apache Cordova In ActionHazem Saleh
 
How React Native, Appium and me made each other shine @Frontmania 16-11-2018
How React Native, Appium and me made each other shine @Frontmania 16-11-2018How React Native, Appium and me made each other shine @Frontmania 16-11-2018
How React Native, Appium and me made each other shine @Frontmania 16-11-2018Wim Selles
 
Android & iOS Automation Using Appium
Android & iOS Automation Using AppiumAndroid & iOS Automation Using Appium
Android & iOS Automation Using AppiumMindfire Solutions
 
Performance and Scalability Testing with Python and Multi-Mechanize
Performance and Scalability Testing with Python and Multi-MechanizePerformance and Scalability Testing with Python and Multi-Mechanize
Performance and Scalability Testing with Python and Multi-Mechanizecoreygoldberg
 

Ähnlich wie Setting Apple's UI Automation Free with Appium (20)

Android UI Testing with Appium
Android UI Testing with AppiumAndroid UI Testing with Appium
Android UI Testing with Appium
 
Plug yourself in and your app will never be the same (1 hr edition)
Plug yourself in and your app will never be the same (1 hr edition)Plug yourself in and your app will never be the same (1 hr edition)
Plug yourself in and your app will never be the same (1 hr edition)
 
Introduction to Software Development
Introduction to Software DevelopmentIntroduction to Software Development
Introduction to Software Development
 
ApppiumDoc_version2015
ApppiumDoc_version2015ApppiumDoc_version2015
ApppiumDoc_version2015
 
Applets
AppletsApplets
Applets
 
[JMaghreb 2014] Developing JavaScript Mobile Apps Using Apache Cordova
[JMaghreb 2014] Developing JavaScript Mobile Apps Using Apache Cordova[JMaghreb 2014] Developing JavaScript Mobile Apps Using Apache Cordova
[JMaghreb 2014] Developing JavaScript Mobile Apps Using Apache Cordova
 
The Future of Selenium Testing for Mobile Web and Native Apps
The Future of Selenium Testing for Mobile Web and Native AppsThe Future of Selenium Testing for Mobile Web and Native Apps
The Future of Selenium Testing for Mobile Web and Native Apps
 
RichFaces - Testing on Mobile Devices
RichFaces - Testing on Mobile DevicesRichFaces - Testing on Mobile Devices
RichFaces - Testing on Mobile Devices
 
Good practices for debugging Selenium and Appium tests
Good practices for debugging Selenium and Appium testsGood practices for debugging Selenium and Appium tests
Good practices for debugging Selenium and Appium tests
 
Electron - cross platform desktop applications made easy
Electron - cross platform desktop applications made easyElectron - cross platform desktop applications made easy
Electron - cross platform desktop applications made easy
 
Android CI and Appium
Android CI and AppiumAndroid CI and Appium
Android CI and Appium
 
Appium understanding document
Appium understanding documentAppium understanding document
Appium understanding document
 
Lecture 22
Lecture 22Lecture 22
Lecture 22
 
Basic of Applet
Basic of AppletBasic of Applet
Basic of Applet
 
Android Programming made easy
Android Programming made easyAndroid Programming made easy
Android Programming made easy
 
Apache Cordova In Action
Apache Cordova In ActionApache Cordova In Action
Apache Cordova In Action
 
How React Native, Appium and me made each other shine @Frontmania 16-11-2018
How React Native, Appium and me made each other shine @Frontmania 16-11-2018How React Native, Appium and me made each other shine @Frontmania 16-11-2018
How React Native, Appium and me made each other shine @Frontmania 16-11-2018
 
Android & iOS Automation Using Appium
Android & iOS Automation Using AppiumAndroid & iOS Automation Using Appium
Android & iOS Automation Using Appium
 
Javalecture 1
Javalecture 1Javalecture 1
Javalecture 1
 
Performance and Scalability Testing with Python and Multi-Mechanize
Performance and Scalability Testing with Python and Multi-MechanizePerformance and Scalability Testing with Python and Multi-Mechanize
Performance and Scalability Testing with Python and Multi-Mechanize
 

Mehr von mobiletestsummit

MOET: Mobile End-to-End Testing
MOET: Mobile End-to-End TestingMOET: Mobile End-to-End Testing
MOET: Mobile End-to-End Testingmobiletestsummit
 
iOS Automated Testing with Calabash: Tips and Tricks
iOS Automated Testing with Calabash: Tips and TricksiOS Automated Testing with Calabash: Tips and Tricks
iOS Automated Testing with Calabash: Tips and Tricksmobiletestsummit
 
Cross-Platform Testing with Frank
Cross-Platform Testing with Frank Cross-Platform Testing with Frank
Cross-Platform Testing with Frank mobiletestsummit
 
Calabash-Driver Lightning Talk by Dominik Dary
Calabash-Driver Lightning Talk by Dominik DaryCalabash-Driver Lightning Talk by Dominik Dary
Calabash-Driver Lightning Talk by Dominik Darymobiletestsummit
 

Mehr von mobiletestsummit (6)

Sikuli for Mobile Testing
Sikuli for Mobile TestingSikuli for Mobile Testing
Sikuli for Mobile Testing
 
Automating Firefox OS
Automating Firefox OSAutomating Firefox OS
Automating Firefox OS
 
MOET: Mobile End-to-End Testing
MOET: Mobile End-to-End TestingMOET: Mobile End-to-End Testing
MOET: Mobile End-to-End Testing
 
iOS Automated Testing with Calabash: Tips and Tricks
iOS Automated Testing with Calabash: Tips and TricksiOS Automated Testing with Calabash: Tips and Tricks
iOS Automated Testing with Calabash: Tips and Tricks
 
Cross-Platform Testing with Frank
Cross-Platform Testing with Frank Cross-Platform Testing with Frank
Cross-Platform Testing with Frank
 
Calabash-Driver Lightning Talk by Dominik Dary
Calabash-Driver Lightning Talk by Dominik DaryCalabash-Driver Lightning Talk by Dominik Dary
Calabash-Driver Lightning Talk by Dominik Dary
 

Setting Apple's UI Automation Free with Appium

  • 1. Setting Apple’s UIAutomation Free with Appium Dan Cuellar d@zoosk.com Lead Software Engineer, Test Team
  • 2. Overview  The Problem  The Solution  Run UIAutomation From The Command Line  Break It Out Of Javascript  Control it in Real-Time  How to Code With Appium  Demo  Odds & Ends
  • 4. The Problem w/ UIAutomation  runs only in Instruments.app  must be written in Javascript  does not support realtime control  many useful js methods (e.g. HTTP requests) have been removed  difficult to build libraries and re-use code  cannot integrate w/ existing Selenium automation  requires adding http servers to your app’s source code
  • 6. Solving the Problem  need command line control  needs to run on the simulator and real devices  need to break out of javascript  need realtime control  should not require you to add code to your app  shoud not require the application source code
  • 7. Command Line Control  /usr/bin/instruments  -t templatePath (path to Automation.tracetemplate)  (path to compiled ios application)  -e UIASCRIPT (path to UIAutomation javascript test)  -e UIARESULTSPATH (path where results will be saved)  [-w device udid]  /usr/bin/xcodebuild (run inside project.xcodeproj)  -sdk (sdk version)  -target (build target)  [-scheme (scheme)]  TARGETED_DEVICE_FAMILY=1|2 (1=iPhone, 2=iPad)
  • 8. Breaking Out Of Javascript No HTTP Web Requests in UIAutomation JS However… host.performTaskWithPathArgumentsTimeout() can run all your favorite shell commands so with friends like cat, curl, and python who needs Javascript and its HTTP web request methods … and Don’t Forget the AppleScript (comes in handy when you need to dismiss OS permissions dialogs)
  • 9. Making It Real-Time  Technique 1, file based communication  Javascript loop looking for sequentially number files in a predetermined folder for commands  Have your program write raw javascript to the file  Read the file using cat  Run the command using eval()  Write the sequentially numbered response file using whatever you like (I chose python)  Technique 2, setup a proxy web service  Curl to ask if there’s a command you should run  Curl back posting the result
  • 10. Result  Now you can control UIAutomation from any language that can write files or make web requests  You can reuse all that non javascript based (java, c#, python, ruby, php) automation code you have for your selenium tests  Run tests that use a web browser and an iOS device at the same time  The possibilities are endless
  • 12. Pre-Requisites  install Xcode  install Xcode Command Line Tools  Set up a ~/.appium file [appium] username = an_osx_admin_username password = an_osx_admin_password OPTIONAL  sudo easy_install pip  sudo pip install bottle (required for webdriver server)  sudo pip install selenium (required to code against the webdriver server)
  • 13. Running Appium  git clone git://github.com/hugs/appium  To launch the UIAutomation javascript interpretter  python appium.py “/path/to/my.app”  To launch the webdriver server  Python server.py “/path/to/my.app”
  • 14. Coding Appium like Selenium from selenium import webdriver command_url = “http://localhost:4723/wd/hub” iphone = webdriver.DesiredCapabilities.IPHONE driver = webdriver.Remote(command_url, iphone) fields = driver.find_elements_by_tag_name('textField’) fields[0].send_keys(3) fields[1].send_keys(4) buttons = driver.find_elements_by_tag_name('button’) buttons[0].click()
  • 15. Demo
  • 17. Failed Prototypes  Applescript iOS Simulator Automation  Did not work on actual devices  Seemed to be highly sensitive to iOS and OS X version  Not a reliable  Javascript Server Within UIAutomation  I could not get a server booted up while running in Instruments
  • 18. Pitfalls  Bug in UIAutomation causes 1 second delay between commands  I get around this by sending batches of commands  Noticed NIBs and XIBs are supported while storyboards are a more of a crapshoot  It’s tricky to make elements accessible in objective C  Some controls (UISegmentedControl) are missing supported accessibility methods  Applying a label to text will hinder your ability to read the text in the control (you need to encapsulate it)
  • 19. Resources Appium Project  https://github.com/hugs/appium or http://appium.io Discussion  https://groups.google.com/d/forum/appium-discuss