Last Updated: 9-25-2013
This project is intended to facilitate automated testing on iOS devices using cucumber and the Page Object pattern.
PREREQUISITES
-Ruby
-Homebrew
-Bundler
In order to use appium you'll first need to install node and npm. Perform the following steps in the terminal to retrieve the necessary items:
brew install node
curl https://npmjs.org/install.sh | sh
export NODE_PATH="/usr/local/lib/node"
export PATH="/usr/local/share/npm/bin:$PATH
npm install -g appium
npm install wd
QUICK START GUIDE
- gem install rufus
- require 'rufus' in your Gemfile
- Create a config.yml in project directory (the one with .xcodeproj in it) with the following information:
browser: iOS
platform: Mac
version: 7.0
app:$HOME/Library/Developer/Xcode/DerivedData/<UNIQUE>/Build/Products/Debug-iphoneos/YourApp.app
- Start appium server in new terminal window
appium -U DEVICE_UDID --app YourApp.app
Deploy to iOS device using XCode or libimobiledevice. Libimobiledevice repo located at: https://github.com/benvium/libimobiledevice-macosx
Run tests
bundle exec cucumber
USING THE RUFUS IRB DRIVER
After installing the gem, open an irb session from the same directory as your config.yml.
require 'rufus/driver'
driver = Rufus.new
driver.start (starts the app)
DEFINING A BUTTON SEQUENCE
Rufus doesn't mind the mindless work of pushing buttons in sequence. The following command will push the goodButton, badButton and sortaOkayButton in sequence 10 times in a row if such a sequence is possible. In this example, the goodButton must be available to be pressed after pushing the sortaOkayButton in order for the loop to continue.
driver.sequence 'goodButton', 'badButton', 'sortaOkayButton', '10'
OTHER DRIVER USE CASES
Push a button by name
driver. 'buttonName'
Get a list of all the button names
driver. (example return: ['go', 'yesButton','noButton'])
Enter 'Hello' into text field
driver.type 'hello' 'textFieldName'
DEPLOYING TO DEVICE WITHOUT USING XCODE
Rufus doesn't necessarily care how your app made it onto the device as long as selenium can see it, but I found the most consistent method to be through libimobiledevice. That project also is included as a submodule to this one. The original repository is https://github.com/benvium/libimobiledevice-macosx. Look at the libimobiledevice Readme in order to configure the environment variables your system needs to use this deployment mechanism.
The only gotcha I ran into was generating the .ipa archive that libimobiledevice uses. Take the following steps to generate the .ipa archive.
- Build the app for deployment to device
- Navigate to the .app file that should be found in the ../Debug-iphoneos/ directory
- Create a folder in that directory named 'Payload'. It must be named Payload.
- Put a copy of the .app file in the Payload directory
- Compress the directory into a .zip archive
- Change the .zip extension to .ipa
- Issue the command ideviceinstaller -i YourApp.ipa (This installs the app)