This repo is intended to show examples on how to use Appium with our Titanium SDK stack.
For the raw notes, you can go here: https://wiki.appcelerator.org/display/qe/Appium+Research. But, this README will formalize those notes.
This link provides a quick overview of Appium and its core architectural concepts: https://github.com/appium/appium/blob/master/docs/en/about-appium/intro.md.
You can follow this installation guide to setup Appium on your machine: https://github.com/appium/appium/blob/master/README.md.
Or, you can follow the below steps, which I used for this repo. The steps will be similar to the ones from the above link, but I will provide some extra notes/caveats:
-
You will need node version >= 4 AND npm version >= 3. If you installed node 4.X from nodejs.org, the node installation comes with npm version 2.X. To install npm version >= 3, use npm e.g:
[sudo] npm install -g npm@3.10.10
. -
Install Appium:
[sudo] npm install -g appium
.
Note: Appium's installation guide doesn't recommend (which is kind of weird) you to install its module with sudo
. Because if you do, you will encounter these type of issues: appium/appium#7057. To fix/workaround this issue, simply run chown on the Appium's node_modules directory: sudo chown -R <user> /usr/local/lib/node_modules/appium/node_modules
.
- This is an optional step, but you should install
appium-doctor
:[sudo] npm install -g appium-doctor
. This module will check if your machine is setup properly for Appium and recommend any fixes:
$ appium-doctor
info AppiumDoctor Appium Doctor v.1.2.5
info AppiumDoctor ### Diagnostic starting ###
info AppiumDoctor ✔ Xcode Command Line Tools are installed.
info AppiumDoctor ✔ DevToolsSecurity is enabled.
info AppiumDoctor ✔ The Authorization DB is set up properly.
info AppiumDoctor ✔ The Node.js binary was found at: /usr/local/bin/node
info AppiumDoctor ✔ Carthage was found at: /usr/local/bin/carthage
info AppiumDoctor ✔ HOME is set to: /Users/wluu
WARN AppiumDoctor ✖ ANDROID_HOME is NOT set!
WARN AppiumDoctor ✖ JAVA_HOME is NOT set!
WARN AppiumDoctor ✖ adb could not be found because ANDROID_HOME is NOT set!
WARN AppiumDoctor ✖ android could not be found because ANDROID_HOME is NOT set!
WARN AppiumDoctor ✖ emulator could not be found because ANDROID_HOME is NOT set!
WARN AppiumDoctor ✖ Bin directory for $JAVA_HOME is not set
info AppiumDoctor ### Diagnostic completed, 6 fixes needed. ###
info AppiumDoctor
info AppiumDoctor ### Manual Fixes Needed ###
info AppiumDoctor The configuration cannot be automatically fixed, please do the following first:
WARN AppiumDoctor - Manually configure ANDROID_HOME.
WARN AppiumDoctor - Manually configure JAVA_HOME.
WARN AppiumDoctor - Manually configure ANDROID_HOME and run appium-doctor again.
WARN AppiumDoctor - Add '$JAVA_HOME/bin' to your PATH environment
info AppiumDoctor ###
info AppiumDoctor
info AppiumDoctor Bye, run appium-doctor again when all manual fixes have been applied!
info AppiumDoctor
- In this repo, run
npm install
; this will install dependencies used by the mocha tests.
At the time of this writing, Appium will not work with iOS devices straight out-of-the-box. You will need to configure Appium some more to work with iOS devices (no configuring needed for Android devices). To configure it for iOS devices, you can follow these steps from appium-xcuitest-driver's README: https://github.com/appium/appium-xcuitest-driver#manual-configuration-alternative.
Or, you can follow the below steps. It's similar to appium-xcuitest-driver's README, but I've added some extra notes:
- Install
ios-deploy
:[sudo] npm install -g ios-deploy --unsafe-perm=true
.
Note: The reason why you need the --unsafe-perm
flag is because you will encounter this issue: http://stackoverflow.com/questions/34195673/ios-deploy-fail-to-install-on-mac-os-x-el-capitan-10-11.
-
Install
deviceconsole
:[sudo] npm install -g deviceconsole
. -
Here is the tricky/frustrating part.
-
cd to the directory where you installed
appium
. For example, if you did a global (e.g.[sudo] npm install -g
) install, go to/usr/local/lib/node_modules/appium
. -
From there, cd into
node_modules/appium-xcuitest-driver/WebDriverAgent
and openWebDriverAgent.xcodeproj
in Xcode. -
Warnings may appear, about project settings, when you open the Xcode project; allow Xcode to automatically fix the issues.
Note: I didn't record the exact warnings, but Xcode was able to resolve them.
- Next, select the Build Settings for the WebDriverAgent project. Make sure of the following:
a. The Code Signing Identity is correctly set for Debug:
Note: I don't think it's necessary to set the identity for Release.
b. The Provisioning Profile is correctly set for Debug:
- Next, select the Build Settings for the WebDriverAgentRunner target. Make sure of the following:
a. The Code Signing Identity is correctly set for Debug:
Note: I don't think it's necessary to set the identity for Release.
b. The Provisioning Profile is correctly set for Debug:
- Finally, select the Build Settings for the WebDriverAgentLib target. Make sure the Code Signing Identity is correctly set for Debug (no need to set the Provisioning Profile):
The next sections will describe how to setup and run the Appium tests for the target test apps.
-
For the KitchenSink test app, you will need to generate a new
tiapp.xml
withappc new
and replace the test app's tiapp.xml. -
To run against iOS:
a. Only build (don't run) the KitchenSink app for iOS e.g: appc run -p ios --build-only
.
b. In test/ks_ios_test.js
on lines 30-32, specify the simulator, iOS version, and the .app
generated from the previous step e.g:
...
deviceName: 'iPhone 7 Plus',
platformVersion: '10.2',
app: '/Users/wluu/github/qe-appium/KitchenSink/build/iphone/build/Products/Debug-iphonesimulator/KitchenSink.app',
...
c. Start Appium by running appium
.
d. Open another terminal window and in this repo, run npm run test-ios
. This will launch the specified iOS simulator, install the KitchenSink and Webdriver apps to the simulator, and start running the mocha tests.
- To run only against Android (Genymotion emulator only):
a. Launch a Genymotion emulator.
b. Only build (don't run) the KitchenSink app for Android e.g: appc run -p android --build-only
.
c. In test/ks_android_test.js
on lines 30-34, specify the Android version running in the Genymotion emulator, emulator device (from adb devices
), the .apk
generated from the previous step, the app package (app id), and the app activity e.g:
...
platformVersion: '6.0',
deviceName: '192.168.56.101:5555',
app: '/Users/wluu/github/qe-appium/KitchenSink/build/android/bin/KitchenSink.apk',
appPackage: 'com.appcelerator.kitchensink',
appActivity: '.KitchensinkActivity',
...
c. Start Appium by running appium
.
d. Open another terminal window and in this repo, run npm run test-android
. This will install the KitchenSink and Webdriver apps to the emulator and start running the mocha tests.
- For the monkeypush test app, you will need to generate a new
tiapp.xml
withappc new
and replace the test app's tiapp.xml.
Notes:
- Make sure to include the
ti.cloud
module in thetiapp.xml
. - The app assumes that you are properly setup for push notification (i.e. correct certs, registered on 360 dashboard).
-
Only build (don't run) the monkeypush app for iOS device e.g:
appc run -p ios -T device --build-only
. -
Connect your iOS device to your machine.
-
In
test/ios_push_test.js
on lines 83-86, specify the device name, iOS version, device udid, and the.ipa
generated from the previous step e.g:
...
deviceName: 'Pippin',
platformVersion: '9.3.4',
udid: 'f8052c8714f0b9585a8f89274f447bbd4eda1601',
app: '/Users/wluu/github/qe-appium/monkeypush/build/iphone/build/Products/Debug-iphoneos/monkeypush.ipa'
...
- Start Appium by running
appium
. - Open another terminal window and in this repo, run
npm run test-ios-device
. This will install the monkeypush and Webdriver apps to the connected device and start running the mocha tests.
- For the monkeyjunk test app, you will need to generate a new
tiapp.xml
withappc new
and replace the test app's tiapp.xml.
Notes:
- Make sure to include the
ti.cloud
andti.cloudpush
module in thetiapp.xml
. - The app assumes that you are properly setup for push notification (i.e. sender id, server key, registered on 360 dashboard).
-
Only build (don't run) the monkeyjunk app for Android device e.g:
appc run -p android -T device --build-only
. -
Connect your Android device to your machine.
-
In
test/android_push_test.js
on lines 83-87, specify the device name (fromadb devices
), Android version on device,.apk
generated from the previous step, app package (app id), and app activity e.g:
...
platformVersion: '7.1',
deviceName: 'FA6AR0303369',
app: '/Users/wluu/github/qe-appium/monkeyjunk/build/android/bin/monkeyjunk.apk',
appPackage: 'com.appc.junk',
appActivity: '.MonkeyjunkActivity'
...
- Start Appium by running
appium
. - Open another terminal window and in this repo, run
npm run test-android-device
. This will install the monkeyjunk and Webdriver apps to the connected device and start running the mocha tests.