Main Content

How to Setup and Run Test Cases in Robot Framework

Robot Framework uses a keyword-driven testing approach. This makes it simple and straightforward to create test data that will lead to predictable test results. Part of a QA team's mission is to provide accurate, predictable testing processes to ensure smooth delivery of projects. At Promet Source, our QA team has used a number of testing frameworks and systems to enhance the predictability and execution of automated tests. This post covers Robot Framework in detail, from installation to test completion.

Enjoy!


 

Step 1: Install Python Some Packages
 

sudo apt-get install build-essential

 

sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

 

Step 2: Install Python pip

sudo apt-get install -y python-pip

 

Step 3: Install Robotramework

sudo pip install robotframework

 

Step 4: Install wxPython (RIDE dependency)

sudo apt-get install -y python-wxgtk2.8

 

Step 5: Install RIDE (Robotframework IDE)

sudo pip install robotframework-ride


Pro tip: Install with pip package manager to make life easier. 

Many external libraries are available on Robot Framework’s official website. Selenium is a useful library to install.

Setting up the VM

Ubuntu 14.04 VM is easy to setup, much less of headache then creating a Mac VM. 

robot framework_vm setup.jpg

ALA_eCommerce_E2E_TC.robot is the file generated by RIDE after saving it.


robot framework_succesful field entry.jpg

Login gmail with valid credential is the test case name.
Open Browser is a keyword from Selenium2Library to open a browser specified in the parameter.
When the keyword is valid, it will change color to sky blue like in the image above.
After the keyword, there is a highlighted cell in red which indicates that the parameter is necessary.


robot framework_shortcut menu.jpg

Details regarding the usage of the keyword will pop-up when pressing Ctrl while hovering the keyword.


robot framework_one test field.jpg

Above is a valid usage of Open Browser keyword.
It will open a firefox browser and will go to www.gmail.com but will produce an error since you need to specify the real url for Gmail which is https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=https://mail.google.com/mail/&ss=1&scc=1&ltmpl=default&ltmplcache=2&emr=1&osid=1#identifier.

 


robot framework_three test fields.jpg

Script above will open gmail.com in a firefox browser, then input prometqa@prometsource.com in the "Enter your email" text field and then click Next button.
Input text is another valid keyword from Selenium2Library which allows the user to input any text in the text field specified by its locator which is in this case the id of the element. Usage: Input Text <locator> <text>
Click Element allows the user to click any clickable element specified by its locator, which is in this case the id of the element. Usage: Click Element <locator>
Keywords are not case-sensitive. See Click Element above.


robot framework_define targets.jpg

To determine the locator, we need to enable the browser's development tools and use the inspect element functionality.
The common locator to use as a locator is the id, name, value of the element.


robot framework_running test.png

When Robot Framework is done executing the script, it will notify you whether it PASS or FAIL.
Clicking the Report will open a browser and display its detailed report. See image below.


robot framework_test details.jpg

Above is the report automatically generated by Robot Framework after executing the script.
Clicking the test case name "Login gmail with valid credentials" will open a detailed report.


These steps are the basic overview of the setup and process to run tests in the Robot Framework with IDE (RIDE). For more information, visit the Robot Framework offiical website.

For further advice on how to write test cases and share results with your team, read Promet's Essential Guide to Automated Testing for Drupal Developers.

Get News & Updates About Automated Testing, Drupal Development & More With Promet's Newsletter

Subscribe to Our Mailing List