Saturday 25 July 2015

Robot Framework for Automate Testing


Robot F/W is useful to do automate testing. I have created API’s and write test cases on Robot F/W. The main advantage is you can change URL for different environment and test.

Suppose you have written Robot Test cases for API in DEV environment. After some time you have release code to Staging environment. If you have written test cases properly then you can just change the API URL of Staging and test that all functionality is working as expected or not. I am going to explain in details.

It is my personal opinion that installation of Robot Framework is quite tricky. RIDE is UI for Robot Framework.

I’m going to explain how to install easily and best practice to write test cases.


Robot Framework Installation and Setup

 Install Python:

Open Python download page https://www.python.org/downloads/windows/ and select Latest Python 2 Release. As of 05.30.14 it is Python 2.7.6. Download and open Windows X86-64 MSI Installer (2.7.6).
 
image

Click Run and accept defaults.

image

Add Python to the system PATH:

Open Control Panel > System > Advanced > Environment Variables and add Python installation (C:\Python27) and scripts (C:\Python27\Scripts) directories to the system Path variable:

image
image

Verify Python installation in command prompt:

Write python –-version on DOC prompt – It will give Python 2.7.6 – It means you have installed Python successfully.

Install Python Package Manager:

that will allow you to install new packages into Python. Visit the Easy Install home at http://peak.telecommunity.com/DevCenter/EasyInstall and select Installing "Easy Install" link.
From this click download ez_setup.py. Locate it on your hard drive and run it.

image

Now open command prompt and install PIP:

image

 

Install Robotframework package:

In command prompt type pip install Robot framework
image

That should install Robot Framework:

image

Verify installation in command prompt by typing: pybot –version

image

 

Install RIDE (Robot Framework standalone test data editor):

RIDE GUI is implemented using wxPython toolkit. Only wxPython 2.8.12.1 is supported. On Windows download wxPython2.8-win64-unicode-2.8.12.1-py27.exe installer from wxPython download page.
Run installation file and click Run setup:

image

Note: If you’re getting this error during wxPython setup:

image

Please follow the steps here: http://stackoverflow.com/questions/3652625/installing-setuptools-on-64-bit-windows to fix it.

Once fixed proceed with wxPython setup: Accept defaults in Setup Wizard:

image

That should install wxPython:

image

Once wxPython is installed download RIDE from: http://code.google.com/p/robotframework-ride/downloads/list.

Open installation exe file, then click Run:

image

Then click Next:

image

Accept defaults and click Yes to Create desktop shortcut:

image

Verify RIDE installation: either click the desktop RIDE (Robot) icon or open it from command prompt: > ride.py

image

 

Using Standard RF libraries:

Robot Framework comes with Standard libraries listed below:

image

To view the library API (keywords documentation and examples) simply click the link to the corresponding library and then select the appropriate version. This should open library API on the wiki:

image

 

Installing External RF library:

To install external library click EXTERNAL link and then click the link to external library of your interest:
image

Then follow the installation instructions on the library GitHub page:

image

Hope this article is good enough to install and start for Robot Framework auto testing.

I am going to explain about how to write API automate unit test cases using ROBOT F/W in next blog.