Robot Framework Tutorial on Windows with Examples!

In Robot Framework Tutorial on windows post, we will learn how to install Robot Framework on windows and then start to learn this tool with examples. let’s get started!

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 the report and log in HTML format as well as an XML output. These provide an 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: https://robotframework.org/#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 Jython (JVM) and IronPython (.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 install RobotFramework in this way.

Pip is the standard Python package manager and the latest Python, Jython and IronPython versions contain pip bundled-in. Pip project page is also a 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 the below command.

python -m pip install -U pip

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

Step by Step Installation

1) Python 2 vs Python 3?

Python 2 and Python 3 are mostly the same languages, but they are not fully compatible with each other. The main difference is that in Python 3 all strings are Unicode while in Python 2 strings are bytes by default, but there are also several other backward-incompatible changes. The last Python 2 release is Python 2.7 that was released in 2010 and will be supported until 2020. See Should I use Python 2 or 3? for more information about the differences, which version to use, how to write code that works with both versions, and so on.

Robot Framework 3.0 is the first Robot Framework version to support Python 3. It supports also Python 2, and the plan is to continue Python 2 support as long as Python 2 itself is officially supported. We hope that authors of the libraries and tools in the wider Robot Framework ecosystem also start looking at Python 3 support now that the core framework supports it. (ref: https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#python-2-vs-python-3)

Go to https://www.python.org/ and download Python 2.7.x version as shown below and install it. On April 18th 2021 the latest versions look like below. I installed 2.7.11 version before but you can download the latest version whenever you read this article.

python-2

python-3

2) Open a command prompt and run the below command.

pip install robotframework

pip-1

3) Upgrade the pip with the below command.

python -m pip install -U pip

pip-2

4) Verifying Installation

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

robot –-version

rebot --version

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 specify the version to use explicitly:

pip install --upgrade robotframework
pip install robotframework==2.9.2

How to Uninstall Robot Framework

pip uninstall robotframework

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 to Robot Framework, RIDE does not yet support Python 3. Notice also that OS X RIDE requires 32-bit Python version.

Step by Step Installation

1) Python must be installed. Its installation is described in the 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 the latest version, you will get the 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:

pip install robotframework-ride

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:

pip install robotframework-selenium2library

selenium2library_installation

Upgrade Command:

pip install --upgrade robotframework-selenium2library

selenium2library_upgrade

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

pip install robotframework-selenium2library==1.4.1
pip install --upgrade selenium
pip install selenium==2.34

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

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

First, open the cmd prompt and write “ride.py” and then press Enter. Then, you will see the 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 LinkedIn page
  • Check Title
  • Enter User Name
  • Enter the Wrong Password
  • Click Login
  • Wait 5 seconds
  • Assert Warning Message
  • Close Browser
*** Settings ***
Library           Selenium2Library

*** Variables ***
${Username}       [email protected]
${Password}       wrongpass
${Browser}        Firefox
${SiteUrl}        http://www.linkedin.com
${DashboardTitle}    World’s Largest Professional Network | LinkedIn
${ExpectedWarningMessage}    Hmm, we don't recognize that email. Please try again.
${WarningMessage}    Login Failed!
${Delay}          5s

*** Test Cases ***
Login Should Failed With Unregistered Mail Adress
    Open LinkedinPage
    Check Title
    Enter User Name
    Enter Wrong Password
    Click Login
    sleep    ${Delay}
    Assert Warning Message
    [Teardown]    Close Browser

*** Keywords ***
Open LinkedinPage
    open browser    ${SiteUrl}    ${Browser}
    Maximize Browser Window

Enter User Name
    Input Text    id=login-email    ${Username}

Enter Wrong Password
    Input Text    id=login-password    ${Password}

Click Login
    Click Button    css=[name=submit]

Check Title
    Title Should be    ${DashboardTitle}

Assert Warning Message
    Element Text Should Be    id=session_key-login-error    ${ExpectedWarningMessage}    ${WarningMessage}

After copied and pasted the 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 the below code to run the test. Report and log results will be automatically generated after the test execution.

robot LinkedinLoginTest.robot

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

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 the 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 (Please update the version when you read this article with the latest ones.)

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

Extract the .zip file and save it under the desired path on your PC. I save the below path.

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

Add the “ 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 the 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.

*** Settings ***
Library  Selenium2Library
 
*** Variables ***
${Username}  [email protected]
${Password}  wrongpass
${Browser}  Chrome
${SiteUrl}  http://www.kariyer.net/
${DashboardTitle}  İş ilanları & Kariyer Tavsiyeleri Kariyer.net'te!
${ExpectedWarningMessage}  Kullanıcı adı, E-posta ve şifrenizi kontrol ederek tekrar deneyin.
${WarningMessage}  Login Failed!
${Delay}  5s

*** Keywords ***  
Open Chrome With Options
     ${options}=  Evaluate  sys.modules['selenium.webdriver'].ChromeOptions()  sys, selenium.webdriver
     Call Method    ${options}    add_argument      start-maximized
     Call Method    ${options}    add_argument      disable-extensions
     Create WebDriver  Chrome    chrome_options=${options}
 
Open Kariyernet
    Open Browser   url=${SiteUrl}   browser=${Browser} 
	
Check Title
    Title Should Be   ${DashboardTitle}  
 
Maximize Browser
    Maximize Browser Window
	
Go to User Login Page	
    #Execute Javascript  document.getElementsByClassName('login-control')[0].style.display='block'
    Click Link    xpath=//a[@href="http://www.kariyer.net/website/kariyerim/login.aspx"]
 
Enter User Name
    Input Text   id=lgnUserName    ${Username}
 
Enter Wrong Password
    Input Text   id=lgnPassword   ${Password}
 
Click Login
    Click Link    xpath=//a[@href="javascript:__doPostBack('ctl00$MasterPageBody$LinkButton1','')"]
 
Assert Warning Message
    Element Text Should Be   css=.error   ${ExpectedWarningMessage}   ${WarningMessage}
*** Settings ***
Resource  ../Resource/setup.robot
Suite Teardown    Close Browser
 
*** Test Cases ***
Login Should Failed With Wrong Username and Password
    [TAGS]  Failed_Kariyernet_Login_Test
    Open Chrome With Options
    Open Kariyernet 
    Check Title
    Go to User Login Page
    Enter User Name
    Enter Wrong Password
    Click Login
    sleep    ${Delay}
    Assert Warning Message

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

GitHub Project

https://github.com/swtestacademy/KariyernetRobotLoginTest 

Thanks,
Onur Baskirt

22 thoughts on “Robot Framework Tutorial on Windows with Examples!”

  1. Hi Onur,

    Really nice information which presented in a way that everyone can understand & implement, I am beginner in Robot Framework tool, on first day of learning after installation of Python, wxPython, Robot Framework, RIDE, I execute your script but it showing one error message and test case get failed.

    Please check below log after execution :-

    Note : I just changed project name to SAMSLoginTest instead of LinkedinLoginTest.
    ——————————————————————————————————————————————————-
    Starting test: SAMSLoginTest.Login Should Failed With Unregistered Mail Adress
    20170412 20:21:32.448 : INFO : Opening browser ‘Firefox’ to base url ‘http://www.linkedin.com’
    20170412 20:21:32.461 : FAIL : No browser is open
    20170412 20:21:32.462 : WARN : Keyword ‘Capture Page Screenshot’ could not be run on failure: No browser is open
    20170412 20:21:32.464 : FAIL :
    WebDriverException: Message: ‘geckodriver’ executable needs to be in PATH.

    Ending test: SAMSLoginTest.Login Should Failed With Unregistered Mail Adress

    ——————————————————————————————————————————————————-
    Could you kindly let me know what I should need to fix this?

    Thanks,
    Amol.

    Reply
  2. Dear Onur,

    First I tried with firefox. I got below error.
    WebDriverException: Message: ‘geckodriver’ executable needs to be in PATH.

    As per your link http://www.swtestacademy.com/marionette-driver-selenium-3/
    I downloaded C:\Marionette#geckodriver.exe
    Still I get same error.

    Then I tried it with IE, I get below error.
    WebDriverException: Message: ‘IEDriverServer.exe’ executable needs to be in PATH. Please download from http://selenium-release.storage.googleapis.com/index.html and read up at https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver

    My task is to try with IE.

    Can you please help?

    Reply
    • Hi,

      I tried to fix problem but I also failed. I think it is about compatibility issue.

      First, you need to add new environmental variables
      for Chrome: webdriver.chrome.driver and it should equal to Chrome driver path such as C:\Selenium\drivers\chrome\chromedriver.exe (download and save the driver from its download page.)
      for Firefox: webdriver.gecko.driver and it should equal to Firefox driver path such as C:\Selenium\drivers\firefox\geckodriver64.exe (download and save the driver from its download page.)

      Then, update your selenium, python, robotframework libraries and rerun your tests with Chrome and Firefox. I opened the browser without problem but I also got some weird compatibility errors.

      Reply
    • I solved the Selenium 3.0 and Robot Framework integration for Chrome. I explained how I did those settings in the article. You can do the similar settings for IE and Firefox also. This may be a good guidance for you. I hope it helps.

      Reply
  3. Hi Onur, I have installed all the prerequisites as per your blog. However when I run the command, ‘ride.py’ from command prompt, a word file with the same name ‘ride.py’ which is in the location “C:\Python27\Scripts” instead of launching RIDE.
    I dont understand where I made a mistake. Can you guide me on how I can solve this issue ?

    Reply
    • Did you set the python paths correctly? But the problem is still going on, it is not necessary to use RIDE IDE. Use Sublime text or another editor and run robot command to run your tests. It is described in the article. If you did the same setup, it should work. Try to setup from the beginning again. Maybe you missed something but I also not figure out what did you missed. I am sorry. :(

      Reply
  4. Hi Onur,

    I am new to robot framework. I am done with installing RIDE using python. But I actually need to deal with .net code. So, i need to install ironpython for the same.
    At a point you said that robot framework works with python, jython or ironpython. But at some other point you mentioned that RIDE supports only python. Can you please help me in clearing the above statements?

    And one more favour, can you provide me with the steps to use robot framework using ironpython as all the steps available online are a bit ambigious and I didnt succeed with the setup.

    Thanks

    Reply
  5. i followed all prescription my test suite was ran, when i was using fire fox browser. now i running the test suite with google chrome browser but its didn’t run. i have downloaded chrome driver and set to be in path. please someone help me. the error message which is ‘Chrome driver ‘ executable needs to be in path.

    Reply
  6. Hi Onur,

    Thanks for the excellent steps with more details.

    I have installed robot framework in my windows 7,64 bit.

    Installed Selenium2Library and have been trying to import in RIDE. But always showing in RED.

    Why it’s not detecting ?
    How do I know it’s installed properly.?

    The pip install of Selenium2Library was success.

    I have written small script to open a web page.Getting an error that “No keyword ” with name found.Because of Selenium2Library is not detecting.

    Other library import are success like importlib, SSHLibrary.

    Reply
  7. How to automate windows component using robot framework. I need to set profile picture( upload image from windows components)
    Chosse file keyword is not working. getting cannot focus element error message

    Reply
  8. Hi,

    Thanks for the above information.

    I would like to ask something,plz clearmy doubt.

    I want to learn RPA. But dont have idea which RPA Tool is good according to future wise, also let me know which RPA tool need not to have coding knowledge.
    in qmnong 3, that is UI PATH or Automation anywhere or Blue prism.

    Reply
  9. Hi Onur.

    I have a problem with a css class selector.
    In website the class is: class=”help-block help-block-error”.
    What should I write to my code that it would work? I have tried to check about this for sometime now, and I haven’t found any answers yet.

    Reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.