Test Automation With Robot Framework

Robot Framework Basics


When it comes to "Test automation" there are a lot of tools and technologies to be found in the industry. For example, there are tools and frameworks like TestNG, JMeter, Katalan Studio, HP Test Suite and Robot Framework, Cucumber etc.
Today I'm planning to speak about the Robot Framework, which is a python based test automation tool. What's special about this framework is the simplicity of the test script that we have to write. If you are familiar with cucumber It's somewhat similar to that. In another way, we can say scripting in robot framework is as simple as using predefined methods to form your automation script.

Installation.


To get your self started with the robot framework you need to have the following list of technologies with you.


If want to connect to your Database then you need to have

  • Visual C++ Redistributable Packages for Visual Studio 2013
  • Java


After the installation, you need to install Robot framework with RIDE.
Open the console and run

  • pip install robotframework
  • pip install robotframework-ride
Now let's install Selenium-Library for Robot as we are planning to do a selenium test automation. Use the bellow mentioned command.
  • pip install robotframework-seleniumlibrary


In your python location go to Scripts folder and open RIDE.py . (Ride is the GUI for Robot framework test automation. (You can use pycham too if you use it) )

The Ride will look like this



NOTE You can save your robot scrip  as a .txt file or a .robot file ( both are accepted by the framework )
The Rest of the concept is really simple. There are three main elements which you need to understand. ( Settings, Keywords, Test Cases )

Settings

When you import settings you need to use (*** Settings ***). And under settings, you can specify the libraries which you wish to use for your script and the post-build actions. Since we have installed the seleniumlibrary, lets import that. For that the script will be like,

*** Settings ***


Keywords

The concept of keywords is like public methods. You can specify a keyword with your own definition with the library specified or other previously defined keywords and use them directly in the test cases. Now let's create a keyword using selenium keywords.
( http://robotframework.org/SeleniumLibrary/SeleniumLibrary.html )

Let's open a browser and go to google and then go to Facebook. For that, the script will look like
NOTE: When you are writing or using a keyword try to use 4 spaces as the keyword-keyword or keyword-variable separation.

*** Keywords ***
Open Chrome With google and redirect to Facebook (This is a name I added)
    Open Browser    https://google.lk    Chrome  (Open browser is a selenium library keyword )
    Go to    https://www.facebook.com  (Go to is a selenium library keyword )


Test Cases

Now All you have to do is use the above-created keywords or library keywords to create your test scripts. Now let's make a small test case with the above-mentioned keyword and using a selenium keyword

*** Test Cases ***
Sample Test (Test Case name)
    Open Chrome With google and redirect to Facebook (This is the keyword which I made)
    Close Browser (This is a selenium library keyword)

If you use command line use  this command
Robot <Path To Project>/Test.Robot  if not you can directly play the command in the RIDE GUI.

This is a very simple script, there are thousands of stuff which you can do with Robot using many libraries including ( sikuli, database liberary, imap... etc. ) .




That's really it. If you are in to test automation or planning to start, try with Robot Framework. I'm pretty sure it'll give you a kick start in your automation journy as QA.


Muditha Perera,
Senior Software Quality Assuarance Engineer,
Intervest Software Technologies


Comments

Post a Comment

Popular posts from this blog

QA Engineering Performance Analysis: Don’t underestimate the power of the 99th percentile

Test Automation With Cucumber