Overview

Robot Framework Tutorial – A complete example

18 Comments

Robot Framework Tutorial

Part I: Robot Framework Tutorial – Overview
Part II: Robot Framework Tutorial – A complete example
Part III: Robot Framework IDE
Part IV: How to Structure a Scalable And Maintainable Acceptance Test Suite
Part V: Robot Framework Tutorial – Writing Keyword Libraries in Java
Part VI: Robot Framework Tutorial – Loops, Conditional Execution and more
Part VII: Robot Framework – Testing Windows Applications
Appendix A: Robot Framework – Compact Sheet

The new Robot Framework Tutorial 2016 series

Please take a look here for an updated version on testing web applications.


The biggest problem when starting a new project with the Robot Framework is probably the pure amount of possible options it is offering:

  • Using Python, Jython, or Java installation?
  • Which input format should be used to implement the tests (HTML, Text, BDD)?
  • This has direct impact on the question whether or not the Robot IDE (RIDE) can be used?
  • How to enable running the same tests locally and on some CI environment?
  • How to exceute the tests at all (scripting, ANT, Maven)?

So what would be the best way to go? Well, I have seen quite some different Robot Framework setups and I sense a certain urge to overly complicate things. Of course it is cool to start the Robot Tests from Eclipse using Maven (we have blogged on this). And writing tests in BDD-style is certainly more agile than using the HTML-format (funny thing, isn’t it, we have blogged on this as well :-)).

But there is one thing that is really cool: Simplicity! And this does not only mean it is simple once everything is setup and works, but it is also simple to understand a problem when things are not working. This is especially important in teams with different technical background.

So let’s start setting up a simple and bulletproof Robot Framework project …

Some initial Thoughts

But B-4 (any Trekkies around :)) starting to setup a new Robot Framework project it must always be analysed which Test-Libraries are needed for testing the System under Test (SuT). A few examples:

  • Testing a web application? Then one will probably include the SeleniumLibrary or Selenium2Library.
  • There is a database involved? Then one of the Database Libraries (Python or Java) should be considered.
  • Need to test SSH/SFTP? Then SSHLibrary is for sure worth a try.

The list could of course be continued for all the available Test Libraries, up to the point where no ready-made Test Library is available. Then you would need to plan writing your own one. (But this is something to cover in an article of its own.)

But why is this important? The Test Libraries used might have direct impact on whether the Python or Jython/Java installation of the Robot Framework must be used (compare Robot Framework Tutorial – Overview). But again, only because some required Test Library is implemented in Java it could still be possible to use the pure Python installation if the Remote Library Interface is supported by that library. Thus these things should really be well thought of before starting.

Tip: The complete code example for this article can be found from GitHub.

Luckily I have done this thinking already for a hypothetical SuT :-). Let’s imagine that this is a web application that makes use of some database (quite typical use case from my experience). To keep things as simple as possible the tested web application will be Google and the database will simply be a local MySQL database instance. Of course there is then no real relation between Google and this local database, but that does not matter for demonstrating the tests. What is more important is to show how to mix different Test Libraries (in this example SeleniumLibrary and DatabaseLibrary) and make use of the Remote Test Library feature of the DatabaseLibrary at the same time. I cannot really tell why, but I tend to use the Java version from the available database libraries.

Thomas Jaspers

Long-term experience in agile software projects using
Java enterprise technologies. Interested in test automation tools and concepts.

Share on FacebookGoogle+Share on LinkedInTweet about this on TwitterShare on RedditDigg thisShare on StumbleUpon

Kommentare

  • Savino

    So far I have no experience in Selenium and Roborframework but I found this article really nice and helpful. Thanks.

  • Uwe

    Hi Leute,

    i have tried to install all the packets as descriped here, but I got an error starting start_Sample_TestSuite.bat:

    These is, what I have installed:

    python-2.6.6.amd64.msi
    jython-installer-2.5.3.jar
    robotframework-2.7.4.win-amd64.exe
    wxPython2.8-win64-unicode-2.8.12.1-py26.exe
    robotframework-ride-0.51.win-amd64.exe
    dblibrary-2.0-server.jar
    robotframework-seleniumlibrary-2.9.1.win-amd64.exe

    and MySQL 5.5 Server

    OS is Windows 7, 64 Bit

    Here is the error log from std out:
    18:39:55.077 ERROR – Failed to start new browser session, shutdown browser and clear all session data
    java.lang.RuntimeException: Firefox refused shutdown while preparing a profile
    at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.waitForFullProfileToBeCreated(FirefoxChrome
    Launcher.java:367)
    at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.populateCustomProfileDirectory(FirefoxChrom
    eLauncher.java:120)
    at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.launch(FirefoxChromeLauncher.java:90)
    at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.launchRemoteSession(FirefoxChromeLauncher.j
    ava:412)
    at org.openqa.selenium.server.browserlaunchers.FirefoxLauncher.launchRemoteSession(FirefoxLauncher.java:114)
    at org.openqa.selenium.server.BrowserSessionFactory.createNewRemoteSession(BrowserSessionFactory.java:381)
    at org.openqa.selenium.server.BrowserSessionFactory.getNewBrowserSession(BrowserSessionFactory.java:125)
    at org.openqa.selenium.server.BrowserSessionFactory.getNewBrowserSession(BrowserSessionFactory.java:86)
    at org.openqa.selenium.server.SeleniumDriverResourceHandler.getNewBrowserSession(SeleniumDriverResourceHandler.j
    ava:811)
    at org.openqa.selenium.server.SeleniumDriverResourceHandler.doCommand(SeleniumDriverResourceHandler.java:437)
    at org.openqa.selenium.server.SeleniumDriverResourceHandler.handleCommandRequest(SeleniumDriverResourceHandler.j
    ava:407)

    I have tried this work around:
    https://3lncr.wordpress.com/2010/03/04/selenium-rc-0-1-1-and-firefox-3-6-profile-issue/

    changing in “install.rdf” the value of em:maxVersion to 99.6 because Firefox is very fast counting the version number and now it is 16 😉

    Is there any solution for this problem?

    Best regards and thank you very much
    Uwe

    PS: The RIDE is also not very stable…

  • Thomas Jaspers

    Hi Uwe,

    unfortunately I cannot directly check things out currently, but the reason could be very well be a too old version of the Selenium-Server.

    Did you use the latest one coming with the Robot Framework Selenium package for your tests?

    With RIDE it depends a bit, what are your concrete problems with it? Sometimes it might be wise not to use a new release right away ;).

    Best Regards
    – Thomas

  • Uwe

    OK – I have got it by myself

    After installing these packets:

    python-2.6.6.amd64.msi
    jython-installer-2.5.3.jar
    robotframework-2.7.4.win-amd64.exe
    wxPython2.8-win64-unicode-2.8.12.1-py26.exe
    robotframework-ride-0.51.win-amd64.exe
    dblibrary-2.0-server.jar

    and of course MySQL 5.5 Server

    I installed these here

    easy_install rtomac-robotframework-selenium2library-e8d7493
    easy_install decorator
    easy_install selenium
    easy_install Selenium2Library

    Now it works 🙂

  • Ranjana

    25. April 2013 von Ranjana

    i have started executing test cases ,i have three .txt files commom ,google and testcase in same folder C:\myDemo .but while executing test case getting error like
    C:\Python27>pybot C:\mydata\RFramework\Demo\myFirstTest.txt
    [ ERROR ] Error in file ‘C:\mydata\RFramework\Demo\myFirstTest.txt’ in table ‘Se
    tting’: Non-existing setting ‘Resource common.txt’.
    [ ERROR ] Error in file ‘C:\mydata\RFramework\Demo\myFirstTest.txt’ in table ‘Se
    tting’: Non-existing setting ‘Resource google-search.txt’.
    ==============================================================================
    myFirstTest :: This is our first test case.
    ==============================================================================
    Go To Google Page[Documentation] Go to google page and serch somet… | FAIL |
    Test case contains no keywords

    Can u help me..why my resource file not recognising

  • Thomas Jaspers

    It is quite hard without seeing the complete setup ;), but when you include the Resource-Files you either have to use a complete path or a path relative to the location of your Testsuite File. You could also tr executing pybot from the “C:\mydata\RFramework\Demo\” directory, just in case.

    Another potential problem – which might be even more likely – when using the TXT-format of Robot Framework is that you have to add additional spaces between “commands” and parameters.

    Non-existing setting ‘Resource google-search.txt’.

    The above error might indicate that you have to add additional spaces after the “Resource” statement.

    • Ranjana

      26. April 2013 von Ranjana

      Yes I do agree that without seeing the set up..I have tried all options of changing the spaces from 2 to 4 🙂 but no luck.gud to have ur email id in this case…

  • Sri

    8. May 2013 von Sri

    HI ,
    I am facing error while starting the test scripts with ride tool..
    WARN ] Keyword ‘Capture Page Screenshot’ could not be run on failure: No browser is open. Please help

  • Thomas Jaspers

    Hi Sri,

    it has been some time since I did this example. Is the Selenium-Server running? Otherwise it would be good to have more details from the Robot Framework Log-File (not the Report) to see what might be going wrong there.

    Cheers
    – Thomas

  • Sai

    Hi,

    Is there a way to stop the screen shot capturing for every [WARN] message..
    I know there is a setup called run_on_failure=nothing which would not capture screen shots on any failures .In my case I have a keyword which Opens browser if not already open

    ex: ${status} ${msg} Run KeyWord and ignore error Get browser
    run keyword if ‘${status}’==’FAIL’ open browser @args

    In the above example selenium first checks for browser
    window and if it doesn’t find any window already open then it generates a warning
    msg ( captures screen shot at this point)

    How could I stop capturing screen shots on this particular scenarios

  • Thomas Jaspers

    Hi Sai,

    for these kind of questions is probable better to use the Robot Framework forum:
    https://groups.google.com/forum/#!forum/robotframework-users

    It is very active and I guess you will get an answer there quite quickly :).

    Best Regards
    – Thomas

  • greg

    Hi

    Could you also please explain how to get the coverage data for the robot test cases using jacoco coverage engine.

    Thanks
    Greg

  • Mark Levison

    How would code coverage help you? I can’t see what it will tell you that would be useful.

    Cheers
    Mark

  • joechang

    15. May 2014 von joechang

    hi everybody
    I Just beginning to use it
    I have one question
    I set Variable inside Url Parameter
    but this Parameter Will add Plus
    *** Variables ***
    ${SN} this is test String

    *** Test Cases ***

    Open Browser https://www.google.com?SN=${SN} browser=gc

    Browser URL
    https://www.google.com?SN=+this is test String

    surplus ‘+’
    How can usage in Correct
    anybody can teach me ?
    thank everybody

  • Ronald

    Thanks for this very clear article. It makes starting to use the framework really easy. Would you have any other articles comparing the RObot Framework to other comparable, open source tools?

  • Thomas Jaspers

    Thanks Ronald, that is good to hear :).
    I am almost always planning such articles, but I have little time currently to write them up, as this of course requires some decent knowledge of the tool to compare with as well :-).

  • vishnu

    8. August 2014 von vishnu

    here is what i get when i execute the “pybot –version” on the windows cmd.
    I have set the PATH variable to C:\Python26;C:\Python26\Scripts
    I still get this error::

    Microsoft Windows [Version 6.2.9200]
    (c) 2012 Microsoft Corporation. All rights reserved.

    C:\Users\VishnuSaiReddy>python –version
    Python 2.6.6

    C:\Users\VishnuSaiReddy>pybot –version
    ‘pybot’ is not recognized as an internal or external command,
    operable program or batch file.

    Have installed a 64 bit python version and

    wxPython3.0-win64-py26 64-bit Python 2.6

  • Frank

    I could not get RobotFramework IDE running under Windows7 64 bits with
    python-2.7.8
    jython 2.5.3 (on java1.7.0_60)
    wxPython2.8-win64-unicode-2.8.12.1-py27
    robotframework-2.8.6.win32
    robotframework-ride-1.2.3.win32

    PATH was updated to include python, jthon, jybot, and scripts…etc.
    The IDE icon was created, but nothing was shown.
    Anyone with similar problem?

Comment

Your email address will not be published. Required fields are marked *