Skeleton automation framework which tests web applications on desktop and mobile browsers using appium, capybara and cucumber.
This starter project will allow you to run automated tests on native iOS or Android browsers (physical device or simulator) as well as Chrome, Firefox, Safari, IE and Edge on the desktop.
In its current state, tests can be run in Chrome, Firefox, and iOS browser.
Additionally, appium-capybara-seed is designed with the Page Object Model pattern. We use the site_prism gem as a wrapper to implement the Page Object pattern.
In order to use this project, the environment must be configured with necessary dependencies.
- Install Xcode if not already installed
- Install Xcode Command Line Tools if not already installed
- Install Homebrew if not already installed
- Install RVM if not already installed (don't need RVM but it is recommended)
- Install NVM if not already installed (don't need NVM but it is recommended)
- Configure ruby version and install global gems:
# Install ruby-2.3.3 to RVM
$ rvm install ruby -v 2.3.3
# Set ruby-2.3.3 as the ruby version and verify it is set
$ rvm use 2.3.3 && ruby -v
# Install bundler gem (in order to execute 'bundle install' from CLI)
$ gem install bundler
# Install rake gem to run rake tasks
$ gem install rake
- Configure node version and install global node_modules:
# Install node version 4.4.7 to NVM
$ nvm install 4.4.7
# Set node v4.4.7 as the node.js version and verify it is set
$ nvm use 4.4.7 && node -v
# Install appium node_module and verify installation
$ node install -g appium && appium -v
# Install optional appium dependencies
$ npm install -g carthage && carthage version
$ npm install -g appium-doctor
# Make sure appium is setup correctly and identify any issues
$ appium-doctor
- Install ChromeDriver for Google Chrome using homebrew:
# Install chromedriver
$ brew install chromedriver
# Verify chromedriver has been installed
$ chromedriver -v
- Install geckodriver for Mozilla Firefox using homebrew
# Install geckodriver
$ brew install geckodriver
# Verify geckodriver has been installed
$ geckodriver --version
- Install ideviceinstaller using homebrew
# ideviceinstaller allows us to install the SafariLoader.ipa to the iOS device
$ brew install ideviceinstaller
- Install ios_webkit_debug_proxy with homebrew:
$ brew install ios-webkit-debug-proxy
# brew install --HEAD libimobiledevice
# turn on the web inspector on iOS device (settings > safari > advanced)
# start proxy: ios_webkit_debug_proxy -c <DEVICE_UDID>:27753
- Update cucumber.yml to match your devices and simulator versions:
- iOS devices - change UDID to the UDID of your device (find in iTunes when device is connected)
- iOS simulators - change DEVICE_NAME and PLATFORM_VERSION to match the sims on your computer.
These set-up instructions detail the necessary steps only for what this project currently supports on Windows: Chrome and Firefox
- Install scoop, the closest thing to homebrew for Windows
- Install ruby 2.3.3 or higher
- Install ruby devkit and follow the instructions here for set-up
- Install ChromeDriver:
- In PowerShell via scoop:
scoop install chromedriver
- Or install manually here. Be sure to add Chromedriver to your PATH
- Install geckodriver from here. Be sure to add it to your PATH as well.
- Cd to the project directory and install the necessary ruby gems
gem install bundler
, if not already installedbundle lock
bundle install
-> TODO: Add install instructions for IEDriver and/or EdgeDriver
Setup for all tests, regardless of platform and browser:
# Open new terminal window and go to the repo's root directory on your computer
$ cd path/to/the/repo/appium-capybara-seed
# Install gems listed in Gemfile to vendor/gems (will take a little while)
$ bundle install
To run on iOS/Android device or simulator, you must start the appium server:
$ appium
To run on Safari for the physical iOS device, open a new terminal tab/window and start the proxy server:
$ ios_webkit_debug_proxy -c <DEVICE_UDID>:27753 -d
Finally, to trigger cucumber tests, run one of these commands (depending on the platform you want to test):
# The profiles are stored in config/cucumber.yml
# I HIGHLY recommend using cucumber profiles.
# Chrome desktop
$ bundle exec cucumber --profile chrome
# Firefox desktop
$ bundle exec cucumber --profile firefox
# iPhone 6s simulator
# Note: make sure you have this simulator installed on your Mac - see cucumber.yml
$ bundle exec cucumber --profile iphone_6s_sim
# iPhone 6s device
# Note: SafariLoader.ipa should be installed on device and ios_webkit_debug_proxy running
$ rake install_safari_launcher[YOUR_iOS_DEVICE_UDID]
$ bundle exec cucumber --profile iphone_6s_device
# iPhone 6 device
# Note: SafariLoader.ipa should be installed on device and ios_webkit_debug_proxy running
$ rake install_safari_launcher[YOUR_iOS_DEVICE_UDID]
$ bundle exec cucumber --profile iphone_6_device
# Adding html_report profile to generate an html results file. For example:
$ bundle exec cucumber --profile chrome --profile html_report
If you followed the above steps, and they were all successful, then running the tests should be the same as on Mac.
bundle exec cucumber --profile chrome
bundle exec cucumber --profile firefox
should both run the tests in the specified browser.
In order to run tests against Safari on a physical iOS device, appium requires the SafariLauncher iOS app to be installed on the device. Once installed, appium uses SafariLauncher to interact with the Safari browser. See appium docs for more information
- An Apple Developer ID which allows you to sign and deploy the SafariLauncher app to a physical device. Without this, you cannot deploy to a physical device (only simulator). More info
- Xcode installed
- Xcode Command Line Tools installed
- Download the SafariLauncher repo onto your local machine
- Extract the SafariLauncher-master.zip (if it is zipped)
- Open SafariLauncher-master folder
- Double click the SafariLauncher.xcodeproj file to open it in Xcode
- Open the Build Settings for the SafariLauncher target (not the SafariLauncher project)
- Find the 'Code Signing Identity' section
- Set the code signing identity to your Apple Developer profile for all debug and release fields
- Find the 'Provisioning Profile' section (just below Code Signing Identity section)
- Set the provisioning profile to 'Automatic' for all debug and release fields (this should already be done, so you shouldnt need to change)
- Find the 'Packaging > Product Bundle Identifier' section
- Verify that the Product Bundle Identifier is set to 'com.bytearc.SafariLauncher'. If it is not, then switch it to 'com.bytearc.SafariLauncher'.
- Clean and build the app
- Connect device to computer
- Launch the app onto the device and make sure it deploys without error.
- Once successfully deployed to iOS device, stop the build.
- In Xcode, go to 'Product > Archive' in order to begin creating an .ipa file for the SafariLauncher
- Click the 'export' button
- Select 'Save for Development' option and then 'next' button
- Choose the Development Team to use for provisioning
- Choose 'Export one app for all compatible devices' and then 'next' button
- Click the 'export' button
- Select the location to which the ipa package will be downloaded and change the name of the exported file to 'SafariLauncher'
- Click 'export' button
- A SafariLauncher.zip file should now be downloaded to your computer
- Unzip SafariLauncher.zip
- Copy the SafariLauncher.ipa to the appium-capybar-seed root directory
- Now, run the rake task install_safari_launcher[YOUR_DEVICE_UDID] to deploy the app to the device
- If successful, the SafariLauncher will display on the device.
- Keep the app installed on the device so that you don't need to deploy the .ipa each test run.
- On the device, go to Settings > Safari > Advanced
- Turn on Javascript and Web Inspector settings
- In order to locally execute tests on both iOS and Android platforms, you must use a Mac. This is because Xcode and any iOS development can only be done on OSX. Android can run on either Windows or OSX because it is java based.
- In practice, using something like BrowserStack is a great option for regular test execution on multiple platforms. Especially if you are testing in a CI/CD environment.