Your SlideShare is downloading. ×
  • Like
Setting Apple's UI Automation Free with Appium
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.


Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Setting Apple's UI Automation Free with Appium


By Dan Cuellar, Zoosk

By Dan Cuellar, Zoosk

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads


Total Views
On SlideShare
From Embeds
Number of Embeds



Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

    No notes for slide


  • 1. Setting Apple’sUIAutomation Free with Appium Dan Cuellar 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
  • 3. The Problem
  • 4. The Problem w/ UIAutomation runs only in 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
  • 5. The Solution
  • 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 JavascriptNo HTTP Web Requests in UIAutomation JSHowever…host.performTaskWithPathArgumentsTimeout() can run allyour favorite shell commandsso with friends like cat, curl, and python who needsJavascript and its HTTP web request methods… and Don’t Forget the AppleScript (comes in handy whenyou 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
  • 11. Coding w/ Appium
  • 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_passwordOPTIONAL 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:// To launch the UIAutomation javascript interpretter  python “/path/to/” To launch the webdriver server  Python “/path/to/”
  • 14. Coding Appium like Seleniumfrom selenium import webdrivercommand_url = “http://localhost:4723/wd/hub”iphone = webdriver.DesiredCapabilities.IPHONEdriver = 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
  • 16. Odds & Ends
  • 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. ResourcesAppium Project  or http://appium.ioDiscussion 