Pioneering Appium with Ruby for Mobile Test Automation, Part 3: Building the Environment

Appium installation

Huzza! More pioneering at hand. I’ll continue where we left off in my previous blog post. If you are interested in reading more about Test Automation be sure to read our guide, Test Automation: nearly everything you need to know.

We’re still focusing on putting together a Ruby-based Appium setup for Windows intended to test Android applications on a real device.

Quick recap: We installed Ruby and its DevKit, the Java Development Kit, Android Studio, Apache Maven and Apache Ant, Node.js and of course Appium. Read how to do this in Part 1 for Windows or Part 2 for Mac.

Using the Command Prompt

All the pieces are in place, so now we need to connect them to each other. Fire up Command Prompt (cmd.exe) and start with checking the various installations that we have done so far. Type in the commands as stated below to see whether the software is installed correctly. Text written in italics indicates input for the Command Prompt:

  1. Check your NodeJS installation. It should be v6 or higher.
    node –version
  2. Check your NPM installation.
    npm –version
  3. Check your Apache Maven and Apache Ant installations.
    ant -version
    mvn -version
  4. Check your Ruby installation. It should be 2.3.3.
    ruby –version
Finding all the right versions

Where Ruby Devkit comes in

To install some of the required Ruby plug-ins we need, the Ruby Devkit is required. This library allows for building of native extensions. In my previous post I mentioned installing the Devkit but never described the actual steps. In case you didn’t manage to install it, here are the steps to take:

  1. First navigate in Command Prompt to your Devkit folder (within the Ruby installation folder).
    cd C:\Ruby\devkit
  2. Then initialise and install the kit. Do this using the commands below.
    Write ruby dk.rb init
    Write ruby dk.rb install
  3. If you didn’t do it already, set the system variables for the Ruby Devkit.
    Add, for example C:\Ruby\devkit\bin, to the existing Path variable.

Ruby’s Gems!

Now everything is verified, installed and updated we can start gathering the required plug-ins for Ruby. A Plug-in for Ruby is called a ‘gem’.

  1. Check your Rubygems version. It should be 2.1.5 or higher. Rubygems is the plugin manager for Ruby.
    gem –version
    gem update –system will update Rubygems
    gem update will update the installed gems.
  2. Start with installing the Appium libraries for Ruby.
    gem install appium_console
  3. We also need Flaky. This is a dependency for Appium to run.
    gem install flaky
  4. The Bundler gem is required to execute the test scripts. Besides that it’s a very useful tool for setting up projects quickly.
    gem install bundler
  5. We’ll have Cucumber as the tool to interpret the Gherkin script and start the tests. Thus we need to install its gem too.
    gem install cucumber
  6. To allow for reading of Gherkin script we need to install its gem too.
    gem install gherkin
  7. In the most likely case JSON is already installed on your system. If not, install its gem using the following command:
    gem install json
It’s quite a fancy collection of gems we have

Now, all the gems are in one place and all the software has been installed. There is just one more thing we need to do to finish the set-up: creating the files and folders we’ll be using.

Lapis Lazuli

Let’s not do this manually. There’s a nifty gem that can do this for us: Lapis Lazuli. It’s intended for web automation, but we can use the structure too.

  1. Install the gem like all the others.
    gem install lapis_lazuli
  2. Then use Lapis Lazuli to create the folder structure for you. To do this, use the following commands.
    cd [the path of the folder where you want to create your project]
    lapis_lazuli create [project name]

And we’re done. The entire environment has been set up. Next time we can start writing code and making the first attempt at connecting to a real device. Yay!


Lapis Lazuli

Written by: spriteCloud

This is the spriteCloud company author. We use this profile when posting general company-related things and as a catch-all for posts that were written by former colleagues.

Subscribe to our mailing list!

Stay up-to-date on all things quality assurance,
test automation, and cybersecurity.

We’re spriteCloud, a leader in software and cybersecurity testing.

Aside from interesting articles, we also have a team of software testers that can help your organisation.

Have a look at our testing solutions.