What is RobotFramework?

RobotFramework is a GENERIC test automation framework for acceptance testing and acceptance test-driven development (ATTD). What it means that you can do web, mobile, desktop and other test automation activities with related test libraries. These libraries can be implemented either with Python or with Java, and we can add new higher-level keywords from existing ones. It has also very easy test data syntax that utilizes the keyword-driven testing approach.

RobotFramework project is hosted on GitHub where you can find further documentation, source code, and issue tracker. The core framework is implemented using Python and runs on Jython (JVM) and IronPython (.NET). RobotFramework itself is open source software released under Apache License 2.0, and most of the libraries and tools in the ecosystem are open source.

RobotFramework Architecture

♦ When test execution is started, the framework first parses the test data.

♦ It then utilizes keywords provided by the test libraries to interact with the system under test.

♦ Libraries can communicate with the system either directly or using other test tools as drivers.

♦ Test execution is started from the command line. As a result, you get report and log in HTML format as well as an XML output. These provide extensive look into what your system does.

robotframework

Libraries

Test libraries provide the actual testing capabilities to RobotFramework by providing keywords. There are several standard libraries that are bundled in with the framework, and galore of separately developed external libraries that can be installed based on your needs. You can find all libraries here: http://robotframework.org/#test-libraries

libraries

How to install RobotFramework on Windows?

♣♠♣ Please, see the latest update for RobotFramework and Selenium 3.0 Integration at the end of the article! ♣♠♣

Brief Installation Information:

There are several ways to install RobotFramework. It is implemented with Python; however, it supports also Jyton (JVM) and IronPhyton (.NET). You can find all these installation instructions in this reference link. In this post, we will go with “Installing RobotFramework with pip“. It is the recommended way to install RobotFramework and I suggest you to install RobotFramework in this way.

Pip is the standard Python package manager and latest Python, Jython and IronPython versions contain pip bundled-in. Pip project page is also good reference for pip installation https://pip.pypa.io/en/stable/installing/

pip is already installed if you’re using Python 2 >=2.7.9 or Python 3 >=3.4 downloaded from python.org, but you’ll need to upgrade pip with below command.

Additionally, pip will already be installed if you’re working in a Virtual Envionment created by virtualenv or pyvenv.

Step by Step Installation:

1) Go to https://www.python.org/ and download Python 2.7.x version as shown below and install it.

python-1

python-2

python-3

2) Open command prompt and run below command.

pip-1

3) Upgrade the pip with below command.

pip-2

4) Verifying Installation

After a successful installation, you should be able to execute the created runner scripts with –version option and get both RobotFramework and interpreter versions.

pip-3

If running the runner scripts fails with a message saying that the command is not found or recognized, a good first step is double-checking the PATH configuration. If that does not help, it is a good idea to re-read relevant sections from these instructions before searching help from the Internet or as asking help on robotframework-users mailing list or elsewhere.

Note: If you have any problem please check Path configuration and restart your PC. Path configuration must be as same as below figure.

path_configuration

How to Upgrade RobotFramework

If you are using pip, upgrading to a new version required either using the –upgrade option or specifying the version to use explicitly:

How to Uninstall Robot Framework

Installing RIDE (Standalone RobotFramework Test Data Editor)

RIDE runs only on the regular Python, not on Jython nor IronPython. Python 2.6 is the minimum version. Notice that similarly as Robot Framework, RIDE does not yet support Python 3. Notice also that on OS X RIDE requires 32-bit Python version.

Step by Step Installation:

1) Python must be installed. Its installation is described in above section.

2) wxPyhton must be installed. On Windows you can download an appropriate installer from wxPython download page and click next > next > next to install package. You need to install “8-win32-unicode-2.8.12.1-py27.exe32-bit version.

wxpython_installation

wxpython_installation_2

If you install latest version, you will get below error:

wrong_wxPython_version

For more information about the installation, see http://wxpython.org. For Linux and OS X please check this link.

3) RIDE can be installed with pip using these commands:

RIDE_installation

4) After a successful installation, RIDE can be started from the command line by running ride.py. Alternatively, you can specify a file or directory to open as an argument like ride.py path/to/tests.

ride_installed

ride_open

Install Selenium 2 (WebDriver) Library

Selenium2Library is a web testing library for Robot Framework that leverages the Selenium 2 (WebDriver) libraries from the Selenium project.

The recommended installation method is using pip.

Installation Command:

selenium2library_installation

Upgrade Command:

selenium2library_upgrade

If you want, you can also install a specific version or upgrade only the Selenium tool used by the library:

You can find more information and how to use Selenium2Library in this page.

How to use Robot Framework with Selenium2Library & RIDE & Command Prompt

First, open cmd prompt and write “ride.py” and then press Enter. Then, you will see RIDE editor.

Go to File >> New Project and then give a name to your project as shown below.

create_project

Then, Click Text Edit

project_2

Then copy paste robot code which is shown below. You can find Selenium2Library commands here: http://robotframework.org/Selenium2Library/doc/Selenium2Library.html I wrote below test case according to Selenium2Library commands.

Test Scenario:

  • Open LinkedinPage
  • Check Title
  • Enter User Name
  • Enter Wrong Password
  • Click Login
  • Wait 5 seconds
  • Assert Warning Message
  • Close Browser
After copied and pasted above code, when you click “Edit” tab, you will see the test details as shown below.

project_3

When you click “Run” tab, you will see below screen and when you click the “Start” button, test will start to run. You can follow the test on log windows.

project_4

When you click “Report” and “Log” buttons you will see detailed log and report information in HTML format.

report_log_buttons

report

log

You can also run your test via command prompt. You should run below code to run the test. Report and log results will be automatically generated after the test execution.

project_5

Summary

In this post, I tried to explain how to install Robot Framework and Selenium2Library. Then, we did a sample test automation example. You can start from here and advance your Robot Framework knowledge and skills. Also, instead of RIDE IDE, you can use SublimeText, IntelliJ, or Eclipse.

I want to share good references with you below.

Nice Article and Videos: http://www.eficode.fi/blogi/maintainable-automatic-tests-for-your-web-application/

SublimeText Editor Plugin: https://packagecontrol.io/packages/Robot%20Framework%20Assistant

Robot Framework and Appium: http://blog.zymr.com/mobile-test-automation-using-robot-framework

Nice Introduction Article: http://www.virtuousprogrammer.com/?p=264

Several Robot Framework Articles: http://seleniummaster.com/sitecontent/index.php/selenium-robot-framework-menu

UPDATE [11.05.2017]

Robot Framework and Selenium 3.0 Integration

As you know, After Selenium 3.0 we need to declare browser drivers before executing our test scripts. Thus, we need to do below settings for our Robot Framework automation projects. I will describe the settings for Chrome Driver version 2.29, Chrome Browser Version 57.0.2987.133, and Selenium 3.3.2, Robot Framework 3.0.2, Python 2.7.11

First, you need to download latest chrome driver here: https://sites.google.com/a/chromium.org/chromedriver/downloads

Extract the .zip file and save under the desired path in you PC. I save below path.

C:\Selenium\drivers\chrome\chromedriver.exe

Add “ webdriver.chrome.driver” environmental variable and assign it to the chrome driver path as shown below.

Add, chrome driver location to the system path as shown below.

Then, update your test codes as follows.  The environment where I am running the tests is blocking all the third party extensions in chrome browser. That’s why I disabled the extensions with Chrome options.

The Test Scenario: The test opens www.kariyer.net and then goes to the login page and does an invalid login operation.

And the result is passed as shown. You can also do the similar settings for firefox and IE driver and browsers.

Githubhttps://github.com/swtestacademy/KariyernetRobotLoginTest 

Good Luck!
-Onur