Pages

Friday, July 25, 2014

Automated testing against physical iOS devices

Update the iPhone's iOS version to the latest

Install Xcode, Apple's IDE for developing iOS software:
http://itunes.apple.com/us/app/xcode/id497799835

Install Homebrew, a package manager that allows user to install, remove and updated applications and packages:
http://brew.sh/
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

Download SafariLauncher, a simple IOS application that automatically launches Mobile Safari after a certain delay:
https://github.com/budhash/SafariLauncher
git clone https://github.com/budhash/SafariLauncher

If you are not already a member in Apple’s iOS Developer Program, spend $99 and join.
https://developer.apple.com/programs/ios/

Build SafariLauncher in xCode:
{ Tell about setting keys and missing field(?) }

Install ios-webkit-debug-proxy:
“The ios_webkit_debug_proxy allows developers to inspect MobileSafari ... on real and simulated iOS devices”
brew install ios-webkit-debug-proxy

Install appium:
http://appium.io/
brew install node
npm install -g appium
npm install wd

Launch ios_webkit_debug_proxy:
ios_webkit_debug_proxy -d
Go to http://localhost:9221/
You should see “iOS Devices” and nothing else
Connect iPhone
You should see “1. localhost:9222 - iPhone” where localhost:9222 is a hotlink
Disconnect iPhone.
Refresh browser. localhost:9222 is no longer a hotline
Reconnect iPhone
Refresh browser. Hotlink is back.
Click link and see: “Inspectable pages for iPhone:”
Launch Safari on iPhone and go to google
Reload browser on Mac and see a line added to the page: “1. https://www.google.com/” where https... is a hotlink
Click hotline and you will see ios_webkit_debug_proxy tool, which you can use like Firebug to inspect elements on the page.

Get the UDID of the iPhone:
http://whatsmyudid.com/
When you see your UDID in iTunes, you may need to right-click it and select Copy. Keyboard shortcut may not work.

Run appium server:
In a new terminal shell, type:
appium --session-override

Write a test that uses SafariLauncher to open your website and make Selenium calls to test the site:
{Beyond scope}

Run your test against the iPhone simulator:
In another terminal shell, type:
mvn -Dtest=com.saucelabs.appium.SimulatorSafariTest test
Watch as the simulator starts (SLOW)
You will see SafariLauncher start (SLOW)
You will see the website launch (SLOW)
You will see your test steps performed.
Look at output of appium window.

Stop appium server:
In the terminal shell where you launched appium, type ctrl-c

Run appium server and tell it the id of the iPhone you want to use:
In same terminal shell used for , type:
appium --session-override --udid e8fae...719
Use the udid for your iPhone, not e8fae...719 shown above.

Run your iPhone test:
In the same terminal shell you used to run the simulator, type:
mvn -Dtest=com.saucelabs.appium.iPhoneSafariTest test
Fix any compilation errors
Watch iPhone screen.
You will see SafariLauncher installed
You will see SafariLauncher run.
After a delay, SafariLauncher will launch your website in Safari.
You will see your test steps performed.
Look at output of appium window.