First RobotFramework Test!
There are so many test frameworks, drivers and other tools out there I want to try. For example, Selenesse has been at the top of my list of things to try for months (and I’ll get to it sometime soon!) However, I couldn’t resist the offer from Pekka Klarck, one of the Robot Framework contributors, to give me a live one-on-one demo of Robot Framework a couple of weeks ago. This weekend, I finally had time to try to write my first test (really, to finish up a test that Pekka had started for me).
My first test is below. I always struggle mightily when I learn some new tool or language, and this was no exception. (Apparently my more-geeky friends also struggle with new things, but they don’t whine publicly about it like I do). The user doc for RF leaves a bit to be desired from a non-programmer perspective. However, they are actively improving it. With much help from Pekka (and suggestions from many in the Twitterverse who also use RF), I have gotten over this first beginner hump, I can see lots of possibilities.
You can write RF tests in various formats, including HTML tables. I like the plain text format, because to me, simple is good. It makes the tests more amenable to version control, because you can easily diff versions to see what has changed. If you try that with html table tests you’ll have lots of noise.
I love the flexibility of this tool. I am trying it out with the RF Selenium libraries, but you can use it with a variety of tools, including tools to test non-Web apps such as Java Swing. There’s a lot of potential there.
I like the fact that you can define whatever “keywords” you want, so you can create your own domain-specific language and the test can document itself and the code that it is testing. The inline-documentation aspect is also one of my favorite features of FitNesse.
My team is pretty happy with our current tools: FitNesse for testing behind the GUI, Canoo WebTest for GUI regression tests, and Ruby/Watir scripts to help with exploratory testing. We’ve long wanted to try Selenium, though, and RF would give us an easy way to do that. We’re always experimenting, and an experiment with RF will tell us whether there’s value in adopting it.
For myself, I think RF will be useful in my public presentations and classes. I’m always looking for ways to teach good test automation design, and I think I can do this fairly easily with RF. I’ve seen Dale Emery and Elisabeth Hendrickson do good demos with RF. I’ve also seen Antony Marcano, Andy Palmer and Gokjo Adzic do good demos with FitNesse, so I’m not saying one is better for this purpose than the other!
Here’s my test. I also copied it in below, though the spacing might be wacky there. I put comments in for myself that might help you, too. Download the RF-Selenium library demo and try it for yourself. If you have any issues I am glad to try to help. It would help me learn, too!
—-
lisas_first_test.txt
# new line and 2 spaces are cell delimiters.
# the asterisks have to start in the first col
# Look at the selenium keywords in http://code.google.com/p/robotframework-seleniumlibrary/wiki/LibraryDocumentation
# Look at the quick start guide for more http://code.google.com/p/robotframework/wiki/QuickStartGuide
Actually you don’t even need the # if you type up above the first table. Tables can be in any order. ‘*** Test Cases***’ is an example of a table.
Run it with ./rundemo.py lisas_first_test.txt
To start the server for the app under test manually, python httpyserver.py start
*** Test Cases ***
invalid account
navigate to the login page
type in username invalid
type in password xxx
click submit
verify the invalid account error message
*** Keywords ***
navigate to the login page
log hello, world!
open browser ${LOGIN PAGE} ${BROWSER}
title should be Login Page
${title} = Get Title
should start with ${title} Login
type in username [Arguments] ${username}
input text username_field ${username}
type in password [Arguments] ${password}
input text password_field ${password}
click submit
Click Button login_button
verify the invalid account error message
Title should be Error Page
Page should contain Invalid user name and/or password
*** Settings ***
Library SeleniumLibrary
Test Teardown close browser
*** Variable ***
${LOGIN PAGE} http://localhost:7272
${BROWSER} firefox
Tags: RF, RobotFramework, test frameworks, test tools
March 29th, 2010 at 11:31 am
While reading through Cockburn’s book on use cases, it really strikes me that we should be able to write down use cases as test cases. I would apply some tidying to achieve that in your example:
type in username invalid
would become
enter username “invalid”
type in password xxx
would become
with password “xxx”
click submit
verify the invalid account error message
The last two I would combine to
rejects login with “Invalid user name and/or password”
I assume in the next few tests I would like to apply some method extractions, as the interface gets more clear, but I refuse to apply this up-front without particular contextual information at hand.
March 29th, 2010 at 11:44 am
Thanks, Markus, I will apply those changes. I do plan to extract out duplicate ‘code’, preferably into separate files, as I add to this. I wish I had a better sample app. Of course I can use my company’s app, but it doesn’t make a very good generic example to show other people.
March 30th, 2010 at 5:32 pm
Thanks a lot for writing this blog post about Robot Framework and for a positive initial review. I agree that the entry level documentation is in bad shape and needs to be improved. I just started updating the SeleniumLibrary demo [1] and plan to create some very simple “first tests” that can be distributed with the core framework too. Help in creating examples and improving documentation is very highly appreciated!
[1] http://code.google.com/p/robotframework-seleniumlibrary/issues/detail?id=106
May 26th, 2010 at 7:18 am
Hi Lisa,
A collegue of mine attended one of your tutorials at StarEast and was very impressed
We are in the process of implementing an agile testing methodology on a project and I was wondering if you could share some high level info regarding your current project? I find real world examples typically have more impact in my organization
If this is something that can be shared I would love to know@
Number of Fitnesse tests?
Number of Canoo Web tests?
Amount of time spent on manual testing?
% testing you guys perform via the API?
% of testing you guys perform via the front end?
May 26th, 2010 at 7:43 am
Well, that’s a big question and it’d end up being a whole blog post at least. But the quick answer is we have about 4500 JUnit tests (each having multiple assertions), 550 FitNesse test pages (with tens of thousands of test steps), about 13000 Canoo WebTest test steps, and 1650 Watir test assertions. We have done a pretty good job of getting a right-side-up automated test pyramid.
May 27th, 2010 at 4:15 pm
thanks, I really appreciate the info.
I think you highlight an important point – that for really good testing you do need to hit the application from different angles – and you are using several tools to do that via testing the java classes, the application API, the web front end, etc
Apologies for getting waaaay off topic but I’m curious to know how/ why you are using Watir for exploratory testing? I always thought exploratory testing was more a “manual testing’ discipline
December 19th, 2010 at 11:37 am
I am newbie to robot framework.Can you please provide some doc& example
how to use with selenium to test java application.
Thanks in advance.
January 7th, 2011 at 12:33 pm
Check out my article in the Testing Planet from last summer: http://blog.softwaretestingclub.com/2010/07/the-testing-planet-has-landed/ It includes links that should be helpful to you. (Sorry I missed your comment before!)
October 16th, 2011 at 7:39 pm
java programming lesson…
[...]Agile Testing with Lisa Crispin » Blog Archive » First RobotFramework Test![...]…