We’re back with a new blog in our 37 Things You Should Know About Appium and this time we will focus on Ruby. Ruby has become popular in past years as a similar scripting language to Python and Ruby is a dynamic, reflective, object-oriented general-purpose programming language using in variety of different purposes.
In a nutshell, Ruby is a language comparable to Python in its simplicity and clearness, although it does require a bit more investment of time to learn. Once you get used to it though, Ruby can become a very powerful tool due to its well defined and robust design.
You’ll find here all steps you need to start your tests – using Ruby – against real mobile devices in Testdroid Cloud. Before continuing with running with these scripts you should register with Testdroid service.
First and the foremost, you should install Bundler to ensure all necessary gems and dependencies gets installed properly. Then, update your test script (testdroid_*.rb) with necessary information. Always do remember to modify your desired capabilities before you start a test. This will always save you time and effort as you don’t have to run a test to realize there was something wrong with desired capabilities.
Ok, here is how to install:
$ gem install bundler $ bundle install
Launch a test:
$ rspec testdroid_android.rb
NOTE! There are some common settings that you need to set in all scripts regardless of the app type that you are testing. Each testdroid_*.rb file needs to be updated with the following values.
Here are all the values that you need to configure:
- screen_shot_dir – where should screenshots be stored on your local drive
- testdroid_username – your email that you registered in Testdroid Cloud
- testdroid_password – your Testdroid Cloud password
- testdroid_project – has a default value, but you might want to add your own name to this. Project name is visible in your project view in Testdroid Cloud. Each project must have a unique name
- testdroid_testrun – name or number of this test run. Test run names can be modified even at every test run
- testdroid_app – should be the name of the app you uploaded to cloud. Eg. if you uploaded your app using a script this would look something like this: ‘f4660af0-10f3-46e9-932b-0622f497b0d2/Testdroid.apk’ If you uploaded your app through the Testdroid Cloud web UI, you can use here the value ‘latest’ that refers to the latest uploaded app file.
Native iOS Specific Settings
Example script: testdroid_appiumdriver_ios.rb
To run your Appium tests against your native iOS application with real devices you need to edit the testdroid_appiumdriver_ios.rb script.
In addition to the above mentioned Appium capabilities for iOS testing you need set:
- bundleId – this is your application’s unique name
Two Tips for Ruby on Appium
(1) You can launch your Appium test to use the latest app file you uploaded through Testdroid Cloud portal by setting the testdroid_app desired capability value to ‘latest’.
(2) To automate device finding from Testdroid cloud, you could check this Ruby tool contributed by bootstraponline. The tool is actually a port from our Python device_finder.py script based on the Testdroid Cloud API. The API can be utilized to do basically all the things our Portal allows you to do, and then a bit more! Documentation for the API can be found here.
See you again next week!