Posts Tagged ‘mobile testing’

Appium Bootcamp – Chapter 8: Additional Information + Resources

August 14th, 2014 by Bill McGee

appium_logoThis is the eighth and final post in a series called Appium Bootcamp by noted Selenium expert Dave Haeffner. 

Read:  Chapter 1 Chapter 2 | Chapter 3 | Chapter 4 | Chapter 5 | Chapter 6 | Chapter 7

Dave recently immersed himself in the open source Appium project and collaborated with leading Appium contributor Matthew Edwards to bring us this material. Appium Bootcamp is for those who are brand new to mobile test automation with Appium. No familiarity with Selenium is required, although it may be useful. 

Now that you’re up and running with Appium locally, in the cloud, and on a CI solution, it’s best to show you where you can find more information. Below is a collection of some great resources to help you find your way when it comes to mobile testing.

Community Support

These are the official tutorials for the Appium project for Android and iOS. They served as inspiration and a base for this getting started series. They are great follow-on material since they cover various topics in more depth, and include Java examples as well.

If you have an issue or a question, this is a great place to turn to. Before posting an issue, be sure to read through the Appium Troubleshooting docs and search the group to see if your question has already been asked/answered.

In addition to the Google Discussion Group, you can hop on the Appium HipChat chat room and ask questions from others in the Appium community.

This is a follow-up post answering loads of questions from a webinar from just after thet Appium 1.0 release. It’s chocked full of a lot of great information.

In this video, Jonathan Lipps (Appium’s Chief Architect) explains mobile automation with Appium.

This is an open-source book that is a work in progress; authored by Jonathan Lipps. It’s working title is “Appium: Mobile Automation Made Awesome”.

Some Android Specific Resources

These links (a video, Q&A, and a blog post) cover how Google approaches Android testing.

uiautomator is a crucial component of Android test automation. In this video, the engineers behind it talk about it’s future.

This video is a walk through Google’s newest Android testing framework. This isn’t directly related to Appium, but it contains some useful information.

Some iOS Specific Resources

Appium relies on Apple’s UI Automation support, and these are some solid resources for understanding it better.

Professional Support

If you are a Sauce customer and encounter an issue when using their platform with Appium, be sure to open a support ticket.

If you’re using Appium and you think you’ve found a bug specific to either Android or iOS, then let Google and/or Apple know. In either case it’s best to make sure that the bug is not an Appium issue before filing an issue.

For Google, file an issue here.

For Apple, file an issue here. Apple keeps all bugs private, so it’s worth also filing a duplicate issue here.

Straight To The Source

These are great instructions on how to search through the Appium source code to find more information.

Some Other Resources

There are over 600 Appium questions posted on Stack Overflow for you to peruse.

Xamarin has a free cheat sheet comparing popular mobile app controls. Definitely worth a look.

Outro

Now you’re ready, armed with all the information you need to continue your mobile testing journey.

Happy Testing!

Read:  Chapter 1 Chapter 2 | Chapter 3 | Chapter 4 | Chapter 5 | Chapter 6 | Chapter 7

About Dave Haeffner: Dave is a recent Appium convert and the author of Elemental Selenium (a free, once weekly Selenium tip newsletter that is read by thousands of testing professionals) as well as The Selenium Guidebook (a step-by-step guide on how to use Selenium Successfully). He is also the creator and maintainer of ChemistryKit (an open-source Selenium framework). He has helped numerous companies successfully implement automated acceptance testing; including The Motley Fool, ManTech International, Sittercity, and Animoto. He is a founder and co-organizer of the Selenium Hangout and has spoken at numerous conferences and meetups about acceptance testing.

Follow Dave on Twitter – @tourdedave

Appium Bootcamp – Chapter 6: Run Your Tests

August 7th, 2014 by Bill McGee

appium_logoThis is the sixth post in a series called Appium Bootcamp by noted Selenium expert Dave HaeffnerRead:  Chapter 1 Chapter 2 | Chapter 3 | Chapter 4 | Chapter 5 | Chapter 6 | Chapter 7 | Chapter 8

Dave recently immersed himself in the open source Appium project and collaborated with leading Appium contributor Matthew Edwards to bring us this material. Appium Bootcamp is for those who are brand new to mobile test automation with Appium. No familiarity with Selenium is required, although it may be useful. This is the sixth of eight posts; two new posts will be released each week.

Now that we have our tests written, refactored, and running locally it’s time to make them simple to launch by wrapping them with a command-line executor. After that, we’ll be able to easily add in the ability to run them in the cloud.

Quick Setup

appium_lib comes pre-wired with the ability to run our tests in Sauce Labs, but we’re still going to need two additional libraries to accomplish everything; rake for command-line execution, and sauce_whisk for some additional tasks not covered by appium_lib.

Let’s add these to our Gemfile and run bundle install.

# filename: Gemfile

source 'https://rubygems.org'

gem 'rspec', '~> 3.0.0'
gem 'appium_lib', '~> 4.0.0'
gem 'appium_console', '~> 1.0.1'
gem 'rake', '~> 10.3.2'
gem 'sauce_whisk', '~> 0.0.13'

Simple Rake Tasks

Now that we have our requisite libraries let’s create a new file in the project root called Rakefile and add tasks to launch our tests.

# filename: Rakefile

desc 'Run iOS tests'
task :ios do
  Dir.chdir 'ios'
  exec 'rspec'
end

desc 'Run Android tests'
task :android do
  Dir.chdir 'android'
  exec 'rspec'
end

Notice that the syntax in this file reads a lot like Ruby — that’s because it is (along with some Rake specific syntax). For a primer on Rake, read this.

In this file we’ve created two tasks. One to run our iOS tests, and another for the Android tests. Each task changes directories into the correct device folder (e.g., Dir.chdir) and then launches the tests (e.g., exec 'rspec').

If we save this file and run rake -T from the command-line, we will see these tasks listed along with their descriptions.

> rake -T
rake android  # Run Android tests
rake ios      # Run iOS tests

If we run either of these tasks (e.g., rake android or rake ios), they will execute the tests locally for each of the devices.

Running Your Tests In Sauce

As I mentioned before, appium_lib comes with the ability to run Appium tests in Sauce Labs. We just need to specify a Sauce account username and access key. To obtain an access key, you first need to have an account (if you don’t have one you can create a free trial one here). After that, log into the account and go to the bottom left of your dashboard; your access key will be listed there.

We’ll also need to make our apps available to Sauce. This can be accomplished by either uploading the app to Sauce, or, making the app available from a publicly available URL. The prior approach is easy enough to accomplish with the help of sauce_whisk.

Let’s go ahead and update our spec_helper.rb to add in this new upload capability (along with a couple of other bits).

# filename: common/spec_helper.rb

require 'rspec'
require 'appium_lib'
require 'sauce_whisk'

def using_sauce
  user = ENV['SAUCE_USERNAME']
  key  = ENV['SAUCE_ACCESS_KEY']
  user && !user.empty? && key && !key.empty?
end

def upload_app
  storage = SauceWhisk::Storage.new
  app = @caps[:caps][:app]
  storage.upload app

  @caps[:caps][:app] = "sauce-storage:#{File.basename(app)}"
end

def setup_driver
  return if $driver
  @caps = Appium.load_appium_txt file: File.join(Dir.pwd, 'appium.txt')
  if using_sauce
    upload_app
    @caps[:caps].delete :avd # re: https://github.com/appium/ruby_lib/issues/241
  end
  Appium::Driver.new @caps
end

def promote_methods
  Appium.promote_singleton_appium_methods Pages
  Appium.promote_appium_methods RSpec::Core::ExampleGroup
end

setup_driver
promote_methods

RSpec.configure do |config|

  config.before(:each) do
    $driver.start_driver
  end

  config.after(:each) do
    driver_quit
  end

end

Near the top of the file we pull in sauce_whisk. We then add in a couple of helper methods (using_sauce and upload_app). using_sauce checks to see if Sauce credentials have been set properly. upload_app uploads the application from local disk and then updates the capabilities to reference the path to the app on Sauce’s storage.

We put these to use in setup_driver by wrapping them in a conditional to see if we are using Sauce. If so, we upload the app. We’re also removing the avd capability since it will cause issues with our Sauce run if we keep it in.

Next we’ll need to update our appium.txt files so they’ll play nice with Sauce.

 

# filename: android/appium.txt

[caps]
appium-version = "1.2.0"
deviceName = "Android"
platformName = "Android"
platformVersion = "4.3"
app = "../../../apps/api.apk"
avd = "training"

[appium_lib]
require = ["./spec/requires.rb"]
# filename: ios/appium.txt

[caps]
appium-version = "1.2.0"
deviceName = "iPhone Simulator"
platformName = "ios"
platformVersion = "7.1"
app = "../../../apps/UICatalog.app.zip"

[appium_lib]
require = ["./spec/requires.rb"]

In order to work with Sauce we need to specify the appium-version and the platformVersion. Everything else stays the same. You can see a full list of Sauce’s supported platforms and configuration options here.

Now let’s update our Rake tasks to be cloud aware. That way we can specify at run time whether to run things locally or in Sauce.

desc 'Run iOS tests'
task :ios, :location do |t, args|
  location_helper args[:location]
  Dir.chdir 'ios'
  exec 'rspec'
end

desc 'Run Android tests'
task :android, :location do |t, args|
  location_helper args[:location]
  Dir.chdir 'android'
  exec 'rspec'
end

def location_helper(location)
  if location != 'sauce'
    ENV['SAUCE_USERNAME'], ENV['SAUCE_ACCESS_KEY'] = nil, nil
  end
end

We’ve updated our Rake tasks so they can take an argument for the location. We then use this argument value and pass it to location_helper. The location_helper looks at the location value — if it is not set to 'sauce'then the Sauce credentials get set to nil. This helps us ensure that we really do want to run our tests on Sauce (e.g., we have to specify both the Sauce credentials AND the location).

Now we can launch our tests locally just like before (e.g., rake ios) or in Sauce by specifying it as a location (e.g., rake ios['sauce'])

But in order for the tests to fire in Sauce Labs, we need to specify our credentials somehow. We’ve opted to keep them out of our Rakefile (and our test code) so that we can maintain future flexibility by not having them hard-coded; which is also more secure since we won’t be committing them to our repository.

Specifying Sauce Credentials

There are a few ways we can go about specifying our credentials.

Specify them at run-time

SAUCE_USERNAME=your-username SAUCE_ACCESS_KEY=your-access-key rake ios['sauce']

Export the values into the current command-line session

export SAUCE_USERNAME=your-username
export SAUCE_ACCESS_KEY=your-access-key

Set the values in your bash profile (recommended)

# filename: ~/*.bash_profile

...
export SAUCE_USERNAME=your-username
export SAUCE_ACCESS_KEY=your-access-key

After choosing a method for specifying your credentials, run your tests with one of the Rake task and specify 'sauce' for the location. Then log into your Sauce Account to see the test results and a video of the execution.

Making Your Sauce Runs Descriptive

It’s great that our tests are now running in Sauce. But it’s tough to sift through the test results since the name and test status are nondescript and all the same. Let’s fix that.

Fortunately, we can dynamically set the Sauce Labs job name and test status in our test code. We just need to provide this information before and after our test runs. To do that we’ll need to update the RSpec configuration incommon/spec_helper.rb.

 

# filename: common/spec_helper.rb

...
RSpec.configure do |config|

  config.before(:each) do |example|
    $driver.caps[:name] = example.metadata[:full_description] if using_sauce
    $driver.start_driver
  end

  config.after(:each) do |example|
    if using_sauce
      SauceWhisk::Jobs.change_status $driver.driver.session_id, example.exception.nil?
    end
    driver_quit
  end

end

In before(:each) we update the name attribute of our capabilities (e.g., caps[:name]) with the name of the test. We get this name by tapping into the test’s metadata (e.g., example.metadata[:full_description]). And since we only want this to run if we’re using Sauce we wrap it in a conditional.

In after(:each) we leverage sauce_whisk to set the job status based on the test result, which we get by checking to see if any exceptions were raised. Again, we only want this to run if we’re using Sauce, so we wrap it in a conditional too.

Now if we run our tests in Sauce we will see them execute with the correct name and job status.

Outro

Now that we have local and cloud execution covered, it’s time to automate our test runs by plugging them into a Continuous Integration (CI) server.

Read:  Chapter 1 Chapter 2 | Chapter 3 | Chapter 4 | Chapter 5 | Chapter 6 | Chapter 7 | Chapter 8

About Dave Haeffner: Dave is a recent Appium convert and the author of Elemental Selenium (a free, once weekly Selenium tip newsletter that is read by thousands of testing professionals) as well as The Selenium Guidebook (a step-by-step guide on how to use Selenium Successfully). He is also the creator and maintainer of ChemistryKit (an open-source Selenium framework). He has helped numerous companies successfully implement automated acceptance testing; including The Motley Fool, ManTech International, Sittercity, and Animoto. He is a founder and co-organizer of the Selenium Hangout and has spoken at numerous conferences and meetups about acceptance testing.

Follow Dave on Twitter – @tourdedave

Appium Bootcamp – Chapter 5: Writing and Refactoring Your Tests

August 5th, 2014 by Bill McGee

appium_logoThis is the fifth post in a series called Appium Bootcamp by noted Selenium expert Dave Haeffner

Read:  Chapter 1 Chapter 2 | Chapter 3 | Chapter 4 | Chapter 5 | Chapter 6 | Chapter 7 | Chapter 8

Dave recently immersed himself in the open source Appium project and collaborated with leading Appium contributor Matthew Edwards to bring us this material. Appium Bootcamp is for those who are brand new to mobile test automation with Appium. No familiarity with Selenium is required, although it may be useful. This is the fifth of eight posts; two new posts will be released each week.

Now that we’ve identified some test actions in our apps, let’s put them to work by wiring them up in code.

We’ll start with the iOS app and then move onto Android. But first, we’ll need to do a quick bit of setup.

Quick Setup

Since we’re setting up our test code from scratch, we’ll need to make sure we have the necessary gems installed — and done so in a way that is repeatable (which will come in handy for other team members and for use with Continuous Integration).

In Ruby, this is easy to do with Bundler. With it you can specify a list of gems and their versions to install and update from for your project.

Install Bundler by running gem install bundler from the command-line and then create a file called Gemfile with the following contents:

# filename: Gemfile

source 'https://rubygems.org'

gem 'rspec', '~> 3.0.0'
gem 'appium_lib', '~> 4.0.0'
gem 'appium_console', '~> 1.0.1'

After creating the Gemfile run bundle install. This will make sure rspec (our testing framework), appium_lib (the Appium Ruby bindings), and appium_console (our interactive test console) are installed and ready for use in this directory.

Capabilities

In order to run our tests, we will need to specify the capabilities of our app. We can either do this in our test code, or we can leverage the appium.txt files we used for the Appium Console.

Let’s do the latter approach. But first, we’ll want to create two new folders; one for Android and another for iOS. Once they’re created, let’s place each of the appium.txt files into their respective folders.

├── Gemfile
├── Gemfile.lock
├── android
│   └── appium.txt
└── ios
    └── appium.txt

Be sure to update the app capability in your appium.txt files if you’re using a relative path.

Writing Your First Test

With our initial setup taken care of, let’s create our first test file (a.k.a. “spec” in RSpec). The test actions we identified in the previous post were focused on navigation in the app. So let’s call this spec file navigation_spec.rband place it in the ios folder.

├── Gemfile
├── Gemfile.lock
├── android
│   └── appium.txt
└── ios
    └── appium.txt
    └── navigation_spec.rb

Now let’s write our test to launch Appium for iOS and perform a simple navigation test.

In RSpec, describe denotes the beginning of a test file, whereas it denotes a test. So what we have is a test file with a single test in it.

In this test file, we are starting our Appium session before each test (e.g., before(:each)) and ending it after each test (e.g., after(:each)). More specifically, in before(:each), we are finding the path to the iOSappium.txt file and then loading it. After that we start the Appium session and promote the Appium commands so they will be available for use within our test. We then issue driver_quit in after(:each) to cleanly end the Appium session. This is equivalent to submitting an x command in the Appium console.

The commands in our test (it 'First cell' do) should look familiar from the last post. We’re finding the first cell, grabbing it’s title, click on the cell, and then looking to see if the title appeared on the inner screen.

After saving this file, let’s change directories into the ios folder (e.g., cd ios), and run the test (assuming your Appium Server is running — if not, load up the Appum GUI and click Launch) with rspec navigation_spec.rb. When it’s running, you will see the iOS simulator launch, load up the test app, click the first cell, and then close.

This is a good start, but we can clean this code up a bit by leveraging some simple page objects and a central configuration.

A Page Objects Primer

Automated tests can quickly become brittle and hard to maintain. This is largely due to the fact that we are testing functionality that will constantly change. In order to combat this, we can use page objects.

Page Objects are simple objects that model the behavior of an application. So rather than writing your tests directly against your app, you can write them against these objects. This will make your test code more reusable, maintainable, and easier to fix when the app changes.

You can learn more about page objects here and here.

Refactoring Your First Test

Let’s create a new directory called pages within our ios directory and create two new files in it: home.rb and inner_screen.rb. And while we’re at it, let’s create a new folder to store our test files (called spec — which is a folder RSpec will know to look for at run time) and move our navigation_spec.rb into it.

├── Gemfile
├── Gemfile.lock
├── android
│   └── appium.txt
└── ios
    ├── appium.txt
    ├── pages
    │   ├── home.rb
    │   └── inner_screen.rb
    └── spec
        ├── navigation_spec.rb

Let’s open up ios/pages/home.rb to create our first page object.

 

# filename: ios/pages/home.rb

module Pages
  module Home
    class << self

      def first_cell
        @found_cell = wait { text 2 }
        self
      end

      def title
        @found_cell.name.split(',').first
      end

      def click
        @found_cell.click
      end

    end
  end
end

module Kernel
  def home
    Pages::Home
  end
end

Since the Appium commands are getting promoted for use (instead of passing around a driver object), storing our page objects in a module is a cleaner approach (rather than keeping them in a class that we would need to instantiate).

To create the Home module we first wrap it in another module called Pages. This helps prevent any namespace collisions as well simplify the promotion of Appium methods.

In Home, we’ve created some simple static methods to mimic the behavior of the home screen (e.g., first_celltitleclick). By storing the found cell in an instance variable (e.g., @found_cell) and returning self, we will be able to chain these methods together in our test (e.g., first_cell.title). And in order to cleanly reference the page object in our test, we’ve made the home method available globally (which references this module).

Now let’s open up ios/pages/inner_screen.rb and create our second page object.

# filename: pages/inner_screen.rb

module Pages
  module InnerScreen
    class << self

      def has_text(text)
        wait { text_exact text }
      end

    end
  end
end

module Kernel
  def inner_screen
    Pages::InnerScreen
  end
end

This is the same structure as our previous page object. In it, we’re performing an exact text search.

Let’s go ahead and update our test to use these page objects.

# filename: ios/spec/navigation_spec.rb

require 'appium_lib'
require_relative '../pages/home'
require_relative '../pages/inner_screen'

describe 'Home Screen Navigation' do

  before(:each) do
    appium_txt = File.join(Dir.pwd, 'appium.txt')
    caps = Appium.load_appium_txt file: appium_txt
    Appium::Driver.new(caps).start_driver
    Appium.promote_appium_methods RSpec::Core::ExampleGroup
    Appium.promote_singleton_appium_methods Pages
  end

  after(:each) do
    driver_quit
  end

  it 'First cell' do
    cell_title = home.first_cell.title
    home.first_cell.click
    inner_screen.has_text cell_title
  end

end

We first require the page objects (note the use of require_relative at the top of the file). We then promote the Appium methods to our page objects (e.g., Appium.promote_singleton_appium_methods Pages). Lastly, we update our test.

Now when we run our test from within the ios directory (e.g., cd ios then rspec) then it will run just the same as it did before.

Now the test is more readable and in better shape. But there is still some refactoring to do to round things out. Let’s pull our test setup out of this test file and into a central config that we will be able to leverage for both iOS and Android.

Central Config

In RSpec, we can configure our test suite from a central location. This is typically done in a file called spec_helper.rb. Let’s create a folder called common in the root of our project and add a spec_helper.rb file to it.

├── Gemfile
├── Gemfile.lock
├── android
│   └── appium.txt
├── common
│   └── spec_helper.rb
└── ios
    ├── appium.txt
    ├── pages
    │   ├── home.rb
    │   └── inner_screen.rb
    └── spec
        ├── navigation_spec.rb

Let’s open up common/spec_helper.rb, add our test setup to it, and polish it up.

 

# filename: common/spec_helper.rb

require 'rspec'
require 'appium_lib'

def setup_driver
  return if $driver
  caps = Appium.load_appium_txt file: File.join(Dir.pwd, 'appium.txt')
  Appium::Driver.new caps
end

def promote_methods
  Appium.promote_singleton_appium_methods Pages
  Appium.promote_appium_methods RSpec::Core::ExampleGroup
end

setup_driver
promote_methods

RSpec.configure do |config|

  config.before(:each) do
    $driver.start_driver
  end

  config.after(:each) do
    driver_quit
  end

end

After requiring our requisite libraries, we’ve created a couple of methods that get executed when the file is loaded. One is to setup (but not start) Appium and another is to promote the methods to our page objects and tests. This approach is taken to make sure that only one instance of Appium is loaded at any one time.

We then configure our test actions so they run before and after each test. In them we are starting an Appium session and then ending it.

In order to use this central config, we will need to require it (and remove the unnecessary bits) in our test.

# filename: ios/spec/navigation_spec.rb

require_relative '../pages/home'
require_relative '../pages/inner_screen'
require_relative '../../common/spec_helper'

describe 'Home Screen Navigation' do

  it 'First cell' do
    cell_title = home.first_cell.title
    home.first_cell.click
    inner_screen.has_text cell_title
  end

end

Note the order of the require_relative statements — they are important. We need to load our page objects before we can load our spec_helper, or else the test won’t run.

If we run the tests from within the ios directory with rspec, we can see everything execute just like it did before.

Now that we have iOS covered, let’s wire up an Android test, some page objects, and make sure our test code to supports both devices.

Including Android

It’s worth noting that in your real world apps you may be able to have a single set of tests and segmented page objects to help make things run seamlessly behind the scenes for both devices. And while the behavior in our Android test app is similar to our iOS test app, it’s design is different enough that we’ll need to create a separate test and page objects.

Let’s start by creating spec and pages folders within the android directory and then creating page objects in pages (e.g., home.rb and inner_screen.rb) and a test file in spec (e.g., navigation_spec.rb).

├── Gemfile
├── Gemfile.lock
├── android
│   ├── appium.txt
│   ├── pages
│   │   ├── home.rb
│   │   └── inner_screen.rb
│   └── spec
│       ├── navigation_spec.rb
├── common
│   └── spec_helper.rb
└── ios
    ├── appium.txt
    ├── pages
    │   ├── home.rb
    │   └── inner_screen.rb
    └── spec
        ├── navigation_spec.rb

Now let’s open and populate our page objects and test file.

module Pages
  module Home
    class << self

      def first_cell
        @found_cell = wait { text 2 }
        self
      end

      def click
        @found_cell.click
      end

    end
  end
end

module Kernel
  def home
    Pages::Home
  end
end

This page object is similar to the iOS one except there’s no title search (since we won’t be needing it).

module Pages
  module InnerScreen
    class << self

      def has_text(text)
        wait { find_exact text }
      end

    end
  end
end

module Kernel
  def inner_screen
    Pages::InnerScreen
  end
end

In this page object we’re performing a search for an element by text (similar to the iOS example), but using find_exact instead of text_exact because of how the app is designed (we need to perform a broader search that will search across multiple attributes, not just the text attribute).

Now let’s wire up our test.

require_relative '../pages/home'
require_relative '../pages/inner_screen'
require_relative '../../common/spec_helper'

describe 'Home Screen Navigation' do

  it 'First cell' do
    home.first_cell.click
    inner_screen.has_text 'Accessibility Node Provider'
  end

end

Now if we cd into the android directory and run our test with rspec it should launch the Android emulator, load the app, click the first cell, and then end the session. The emulator will remain open, but that’s something we’ll address in a future post.

One More Thing

If we use the console with the code that we have right now, we won’t be able to reference the page objects we’ve created — which will be a bit of a pain if we want to reference them when debugging test failures. Let’s fix that.

Let’s create a new file in our android/spec and ios/spec directories called requires.rb. We’ll move our require statements out of our test files and into these files instead.

├── Gemfile
├── Gemfile.lock
├── android
│   ├── appium.txt
│   ├── pages
│   │   ├── home.rb
│   │   └── inner_screen.rb
│   └── spec
│       ├── navigation_spec.rb
│       └── requires.rb
├── common
│   └── spec_helper.rb
└── ios
    ├── appium.txt
    ├── pages
    │   ├── home.rb
    │   └── inner_screen.rb
    └── spec
        ├── navigation_spec.rb
        └── requires.rb

Here’s what one of them should look like:

# filename: ios/spec/requires.rb

# require the ios pages
require_relative '../pages/home'
require_relative '../pages/inner_screen'

# setup rspec
require_relative '../../common/spec_helper'

Next, we’ll want to update our tests to use this file.

require_relative 'requires'

describe 'Home Screen Navigation' do

  it 'First cell' do
    cell_title = home.first_cell.title
    home.first_cell.click
    inner_screen.has_text cell_title
  end

end
# filename: android/spec/navigation_spec.rb

require_relative 'requires'

describe 'Home Screen Navigation' do

  it 'First cell' do
    home.first_cell.click
    inner_screen.has_text 'Accessibility Node Provider'
  end

end

Now that we have a central requires.rb for each device, we can tell the Appium Console to use it. To do that, we’ll need to add some additional info to our appium.txt files.

 

# filename: ios/appium.txt

[caps]
deviceName = "iPhone Simulator"
platformName = "ios"
app = "../../../apps/UICatalog.app.zip"

[appium_lib]
require = ["./spec/requires.rb"]
# filename: android/appium.txt

[caps]
platformName = "android"
app = "../../../apps/api.apk"
avd = "training"
deviceName = "Android"

[appium_lib]
require = ["./spec/requires.rb"]

This new require value is only used by the Appium Console. Now if we run arc from either the ios or android directories, we’ll be able to access the page objects just like in our tests.

And if we run our tests from either directory, they will still work as directed.

Outro

Now that we have our tests, page objects, and central configuration all sorted, it’s time to look at wrapping our test execution and make it so we can run our tests in the cloud.

Read:  Chapter 1 Chapter 2 | Chapter 3 | Chapter 4 | Chapter 5 | Chapter 6 | Chapter 7 | Chapter 8

About Dave Haeffner: Dave is a recent Appium convert and the author of Elemental Selenium (a free, once weekly Selenium tip newsletter that is read by thousands of testing professionals) as well as The Selenium Guidebook (a step-by-step guide on how to use Selenium Successfully). He is also the creator and maintainer of ChemistryKit (an open-source Selenium framework). He has helped numerous companies successfully implement automated acceptance testing; including The Motley Fool, ManTech International, Sittercity, and Animoto. He is a founder and co-organizer of the Selenium Hangout and has spoken at numerous conferences and meetups about acceptance testing.

Follow Dave on Twitter – @tourdedave

Sign Up for the First-Ever Appium Roadshow on August 20th in New York City

July 30th, 2014 by Bill McGee

appium_logoWe don’t know if you heard, but mobile is kind of a big deal.

Naturally, Appium – the only open source, cross-platform test automation tool for native, hybrid, and mobile web apps – emerged out of the need to Test All The (Mobile) Things.  Last May, battle-tested Appium 1.0 was released, and now this Appium show is hitting the road!

Details and ticket links below. Hope to see you in New York!

*****

Sign Up for the First-Ever Appium Roadshow on August 20th

Appium Roadshow – NYC is a two part, day-long event held on Wednesday, August 20 at Projective Space – LES in Manhattan’s Lower East Side.

Part 1 – Appium in the Wild

8:30 AM – 1:00 PM – Free

The morning session will showcase presentations from Gilt Groupe, Sharecare, Softcyrlic, and Sauce Labs. Topics will cover real-world examples, lessons learned, and best practices in mobile app test automation using Appium. Featured speakers include:

  • Matthew Edwards – Mobile Automation Lead, Aquent
  • Daniel Gempesaw – Software Testing Architect, Sharecare
  • Matt Isaacs – Engineer, Gilt Groupe
  • Jonathan Lipps – Director of Ecosystem and Integrations, Sauce Labs
  • Sundar Sritharan – Delivery Manager, Softcrylic

This event is free. Breakfast and lunch included. Reserve your seat now – register here.

Part 2 – Appium Workshop

1:30 PM – 5:30 PM – $100

Matthew Edwards, a leading contributor to the Appium project, will provide a hands-on workshop to help you kick start your Appium tests.  He’ll talk you through how to set up the environment needed for native iOS and Android automation with Ruby.  You’ll then download and configure the Appium.app to enable test writing. Then, Matthew will demonstrate how to kick up an Appium server and then run a test.

This event is limited to just 40 participants. Reserve your seat now – register here.

 

[Live Panel] Mobile Testing with Appium

May 15th, 2014 by Bill McGee

2014-04-24_Appium_SM_Images_Facebook_851x315px

As we know from the survey we conducted early this year, mobile testing is incredibly prominent in the QA world. To support this growing field, we’ve heavily invested in the open source project Appium; the leading cross-platform framework for testing hybrid and native mobile applications. Used by organizations large and small, including Expedia and Gilt Groupe, Appium provides a language-agnostic means to automatically test mobile functionality without modifying an app in any way. 

To help celebrate the release of the  latest battle-tested version 1.0 [Orion], we’re thrilled to announce our next webinar: “Live Panel: Appium Core Committers Answer Your Questions” with leading contributors to the project, Jonathan Lipps, Matthew Edwards, and Dan Cuellar. Join us for this panel discussion on Thursday, May 29, from 11AM-12PM PDT.

Questions to the panelists may include:

  • Appium’s philosophy
  • An overview of the 1.0 release
  • The roadmap ahead
  • Best practices for automating mobile tests

A live Q&A will follow. All attendees are encouraged to participate.

Register here today – you won’t want to miss this one!

Appium 1.0 [Orion] and Appium Inspector on OSX Mavericks Demo [VIDEO]

May 12th, 2014 by Bill McGee

appium_logo_final

‘Appy Monday!

Our friend Shantikant Jagtap just released a comprehensive post highlighting the Appium 1.0 [Orion] launch, new Appium features, how to download Appium, and how to use it with the OSX app on Mavericks and Appium Inspector.

Be sure to check out the post here and watch the video demo below, which highlights how to use the Appium OSX app, plus how to record a script using Appium Inspector.

Have an idea for a blog post, webinar, or more? We want to hear from you! Submit topic ideas (or questions!) here.

Online Workshop – Learn How Gilt Groupe Uses Appium to Automate Their Mobile Testing

December 19th, 2013 by Bill McGee

1/14/2014 Update: We’ll be posting a link to the recorded webinar in several days.

We’re teaming up with the Gilt Groupe for our next online workshop! Join us on Tuesday, January 14th, 2014 at 11:00am PST to learn about how Gilt uses Appium to automate their mobile testing. Today, mobile purchases make up more than 40% of Gilt’s sales, and the mobile e-commerce market continues to rage – in the U.S. alone, mobile commerce will grow an estimated 63% to around $34.2 billion, up from $21 billion in 2012.

Find out how Gilt has streamlined testing of this vital part of their business, and what they are doing today on the testing front.

In the workshop, Matt Isaacs, Engineer at Gilt Groupe will cover how mobile testing at Gilt has changed since the early days of Gilt mobile. Then Mike Redman, Director of Sales Engineering at Sauce, will explain how to run your Appium tests on the Sauce cloud. This will be followed by a live Q&A. Register today!

Gilt-Man-smaller

Announcing iOS 7 support in the Sauce Labs Cloud

October 31st, 2013 by Ashley Wilson

ios7_01

Today we’re excited to let you know that you can now test your hybrid and native apps with iOS 7 on Sauce. With more than 200M downloads since its release, we know that this is an important platform for our users to test on.

To get started, visit our browsers and platforms page for Appium and copy and paste the DesiredCapabilities provided for either version of iOS (or Android) you want to test on. And if you’re new to mobile test automation in general, check out our Getting Started with Appium guide.

If you have any issues, give us a shout. Otherwise, happy (iOS 7) testing!

Come Visit Sauce at Apps World 2013

October 11th, 2013 by Bill McGee

Want a great reason to visit London later this month? Our very own Santiago Suarez Ordoñez, Senior Infrastructure Developer, will be sitting on an Apps World 2013 panel on October 23rd titled “Best practices in managing QA testing for the multi-device nightmare”. Apps World 2013 is Europe’s largest multi-platform app event and takes place at Earls Court 2 in central London on the 23rd and 24th of this month.

The panel will be moderated by Martin Wrigley, Executive Director, App Quality Alliance (AQuA) and Santi will be alongside Matthew Brown (Test Manager, Apptivation), Philipp Benkler (Founder & CEO, Testbirds) Paul Rutter (Test Manager – Mobile Platforms, BBC) and Becky Wetherill (Product Director, Borland) – a royal QA roster!

Topics to be discussed include determining how many devices to test, whether or not emulators can be effective as a substitute to testing on actual devices, the balance  of functional, compatibility & performance testing requirements across devices, issue resolution strategies post launch and more.

Once you’ve tucked the panel under your belt (and all of the juicy take-aways), please be sure to take a quick jaunt to stand 217 and say hello to Saucers! We’ll be demo’ing Appium, an open source test automation framework that aims to turn multi-device QA testing from nightmare to a dream. Did we mention there will also be a spiffing robot too?

So hop on the tube and come join the Saucers at Apps World 2013. Cheerio!

Announcing Appium on Sauce: Native & Hybrid iOS App Testing in the Cloud

February 5th, 2013 by Ashley Wilson

Today we are extremely excited to announce the initial release of Appium on Sauce, a new way to automatically test your native and mobile web hybrid iOS apps in the cloud.

everestonsauce

Appium on Sauce has its roots in Appium, an open source project written in Node.js that draws from Dan Cuellar’s work on iOS Auto. Appium currently supports iOS testing with Android support in the works. Using the WebDriver JSON Wire Protocol to drive Apple’s UIAutomation, Appium takes Selenium commands from your app and translates those into a readable format for UIAutomation. With this seamless transition happening under the hood, Appium requires no recompiling or modifications to your app, and allows you to write tests in your favorite programming language and testing frameworks using the Selenium API and language-specific libraries.

tutorial_diagram

Support for mobile web hybrid and native app testing has been on our radar screen for a while now, particularly since the Mobile Testing Summit, where we were first introduced to the project now known as Appium. Given its out-of-the-box compatibility with Selenium, goal of cross-platform support across iOS and Android, and flexible approach to automation, pairing Appium with our cloud to provide a turnkey service for automatically testing native and hybrid apps made perfect sense.

And the best part? Appium on Sauce requires no setup or maintenance of iOS infrastructure. Tests can run in parallel across dozens of machines, allowing them to complete much faster than if they were running serially. Additionally, you can plug Appium on Sauce into your existing CI setup and let the cloud serve as your build server.

To get a quick of idea of how Appium on Sauce works, check out the demo video below featuring Everest, an iPhone app that helps you achieve personal goals.

For the next few weeks, Appium on Sauce will be available by invitation-only as we grow our ability to support more users. To sign up for an invite, visit http://saucelabs.com/appium and tell us a bit about your app and why you’d like to test it in the cloud. We expect to open up Appium on Sauce to everyone in the coming weeks so stay tuned to our blog and Twitter for an announcement on that.

And in the meantime, if you’re a Node developer working on a mobile app development or testing, please consider contributing to Appium to help make it better!

Happy testing!