Pioneering Appium with Ruby for Mobile Test Automation, Part 3: Building the Environment
Huzza! More pioneering at hand. I’ll continue where we left off in my previous blog post.
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:
- Check your NodeJS installation. It should be v6 or higher.
Check your NPM installation.
Check your Apache Maven and Apache Ant installations.
Check your Ruby installation. It should be 2.3.3.
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:
- First navigate in Command Prompt to your Devkit folder (within the Ruby installation folder).
Then initialise and install the kit. Do this using the commands below.
Write ruby dk.rb init
Write ruby dk.rb install
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.
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’.
- Check your Rubygems version. It should be 2.1.5 or higher. Rubygems is the plugin manager for Ruby.
gem update –system will update Rubygems
gem update will update the installed gems.
Start with installing the Appium libraries for Ruby.
gem install appium_console
We also need Flaky. This is a dependency for Appium to run.
gem install flaky
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
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
To allow for reading of Gherkin script we need to install its gem too.
gem install gherkin
In the most likely case JSON is already installed on your system. If not, install its gem using the following command:
gem install json
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.
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.
- Install the gem like all the others.
gem install lapis_lazuli
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!