Appium RSpec Setup

Appium Rspec Setup provides a quick way to include both Rspec as a framework to define your tests against and an Appium-compatible library to let it reach through and drive the virtual device of your choice.

Setup and Installation

This gem only sets up Rspec for use with Appium on your app. In addition to this gem, you will need to have installed and set up the Appium application available here: http://appium.io/

Create a GemFile in your app's main directory and add the following line:

gem 'appium_rspec_setup'

Run bundle.

Android

From the command-line, navigate to the main directory for your app and run the following command:

setup_android

When prompted, enter your app's name and the platform (Android).

iOS

From the command-line, navigate to the main directory for your app and run the following command:

setup_ios

When prompted, enter your app's name.


The setup process should complete within a few seconds, adding the following files to your app's main directory:

  • app_config.yml
  • spec/spec_helper.rb

Do NOT delete these files.

Usage

Add test files within your spec/ folder

Run tests from the command-line with the rspec command.

Below is a sample file login_spec.rb for an Android app:

describe 'App Login' do
  before(:all) do
    Appium::Driver.new(desired_caps).start_driver
    Appium.promote_appium_methods RSpec::Core::ExampleGroup
  end

  after(:all) do
    driver_quit
  end

  describe 'user login' do
    it 'should have two text fields' do
      expect(id('login_email_address').nil?).to eq false
      expect(id('login_password').nil?).to eq false
    end

    it 'should have a button' do
      expect(id('login_button').nil?).to eq false
    end

    it 'should go to splash screen' do
        id('login_email_address').send_keys('email')
        id('login_password').send_keys('password')
        id('login_button').click
        expect(id('splash_layout').nil?).to eq false
    end
  end
end

License

The gem is available as open source under the terms of the MIT License.