I knew for a while I could automate my tests using Selenium. What stopped me from actually doing it is the way you had to write your tests: Normally, you either record tests using Selenium IDE (a Firefox add-on) or write unit-tests using Selenium API from C#. What I did not know is that I could write my test scripts in human language!
The problem with recording the tests, you can't do it before your page is written, so you're limited to regression testing only. The problem with writing the tests in C#, you can't have your QA team writing tests (unless you can afford QA team that knows C#!). With RobotFramework you can have your QA team develop tests before developers are done coding, and use them for both acceptance- and regression-testing.
The script basically looks like this:
Open Browser http://google.com/ firefox
Title Should Be Google
Input Text q zvolkov
Click Button btnG
Page Should Contain The Way Of The Future
You save this to a .txt file, feed it to RobotFramework and it spits out a nicely formatted html report. This means you can automate your tests and have them executed on a regular basis by your build server!
There are bunch of predefined commands like "Click Button" and "Page Should Contain", plus you can define your own using same highly readable text-based syntax. For example the following defines new command "Search For" that combines two built-in actions:
Search For [Arguments] ${query}
Input Text q ${query}
Click Button btnG
As you can imagine, with custom commands you can define reusable domain-specific libraries to significantly reduce the effort required for writing new tests.
If you want to invest 15 minutes and try it for yourself, follow these steps:
- Make sure you have Java 1.6.x installed by going to http://www.java.com/en/download/installed.jsp
- Install latest Python 2.6.x (not 3.x!) Windows installer from http://python.org/download/
- Add C:\Python26 and C:\Python26\Scripts to PATH (press Win+Pause, select Advanced System Settings/Advanced/Environment Variables/System Variables/Path/Edit and add “C:\Python26;C:\Python26\Scripts” add the end)
- Install robotframework-2.5.win32.exe (run as administrator!) from http://code.google.com/p/robotframework/downloads/list
- Install Selenium Library Windows installer 2.4 (run as administrator!) from http://code.google.com/p/robotframework-seleniumlibrary/downloads/list
- Make sure you have Firefox installed as my demo uses Firefox by default.
- Unpack robotFramework_demo.zip to a local folder.
- Double-click on test.cmd
This demo shows-off slightly more robust script with parametrized commands in a separate include file etc. I don't know about you but I like it. RobotFramework that is.
Tags: