In the first installment on Xebium, Cirilo explained the ideas behind this FitNesse fixture:
Xebium creates a simple way to use Selenium IDE (low learning curve) and FitNesse (ease of maintenance) to it’s fullest when it comes to maintaining a web application test suites.
Xebium is using the same keywords as Selenium IDE. This has the huge advantage that no person should learn another DSL. Since tests are stated this way, they can be copied between Selenium IDE and FitNesse without a hassle (the FitNesse formatter for Selenium IDE is rather trivial). And to be honest: as long as there are XPath and Regular Expressions in the code, it makes no sense to come up with a substitute for verifyText.
So now it is possible to move our Selenium IDE test case in a FitNesse page. Nice. It’s easier to set up tests, since FitNesse is quite flexible in that. On the other hand, just playing back you recorded tests is not the most flexible way to work. There can be a huge maintenance burden on this. It would be a shame not to use the full power of FitNesse in this case. Scenario tables for example can make a nice abstraction where some common action, like logging in, only have to be defined (and maintained) in one place. By moving the login code out of the test and into a scenario, we add another level of indirection. The tests themselves become more readable, as they only state the business requirement and the low level details are directly editable by the tester. This is a lot more flexible than creating Selenium fixtures for every scenario.
| log in user | user | with password | password | | open | https://example.com/login | | type | name-field | @user | | type | password-field | @password | | click | login |
and in your tests, instead of repeating the above, just mention:
| script | | log in user | john | with password | secret | | ensure | do | verifyText | on | #userid | with | John |
Sure, we’re back at creating our own DSL, but we do it 100% in FitNesse. Selenium commands can be added where needed (e.g. assertions). No Java (fixture) code, no developers required to change one line because the templates have changed and, foremost, detailed feedback.
But FitNesse can help out even more. Consider data driven testing. Selenium has (by default) no option for that. Using the same scenario table fixture it’s easy to test logins for a bunch of users.
But we claimed you can copy stuff from FitNesse to Selenium IDE as well and that’s getting harder when you move everything inro scenarios. To overcome this issue the formatter in Selenium IDE can parse tab separated data as well. So after a test has run, the output as provided by FitNesse can be copied back. This is a useful aid for analyzing failed tests.
I tend to make my Xebium commands easely available. First of all the fixture needs to be imported. After that the fixture can be assigned as library:
| import | | com.xebia.incubator.xebium | | library | | selenium driver fixture |
A note for Windows users, though. When performing a lot of tests, Windows tends to run out of sockets. There is a way to configure your machine to work around those silly limitations (at your own risk!).