Evaluate Weigh the pros and cons of technologies, products and projects you are considering.

How to use Selenesse, a combination tool from FitNesse and Selenium

Selenesse, a tool built from Fitnesse and Selenium, uses a "scenario library" to analyze and build tests. Selenesse simplifies all of the complexity of test situations by using Simple List Invocation Method or "SLIM" to estimate and recreate test situations. Learn all of the tips and tricks for Selenesse in this expert tip.

Chris McMahon

Selenesse and SLIM and scenarios
This is the wiki markup in Fitnesse that drives Selenium to search for the term "Selenesse" in Google, and checks the result:

!| scenario | Search google || | open | https://www.google.com || | type; | q | selenesse | | clickAndWait | btnG || | waitForTextPresent | Did you mean: selenese || | ensure | isTextPresent | selenesse | | reject | isTextPresent | watir |

Each line in the test shows a particular aspect of how Selenesseworks:

Selenesse uses the Simple List Invocation Method (SLIM), the newest and most robust test engine for Fitnesse. SLIM understands something called a ScenarioLibrary, a wiki page containing a set of scenarios like the one above. A scenario is a macro, a set of instructions that can be invoked from within a test. In this case, the first line defines a scenario called "Search google".

The second line tells Selenium to open the Google home page.

The third line is a bit more obscure and requires some explanation. Until Selenesse came to be, SLIM by default did not accept methods containing more than one argument. Now, because Selenesse requires it, SLIM will accept methods with more than one argument under certain conditions. Therefore, any Selenium commands that take two or more arguments must be followed by a semicolon, for example "type;" in the scenario above. By default Selenium identifies page elements first by id value, and then by name value. The first argument to the type;() command above is the name attribute of the Google textbox for search terms. Finally, the second argument to type;() is the text to be typed into the search textbox, "selenesse".

The fourth line tells Selenium to click the Google Search button (name=btnG) and to wait until the subsequent page loads before continuing. Selenium also has a click() method that does not wait for the subsequent page to load. In general, Selenesse implements all of the *AndWait methods in Selenium.

The fifth line checks that at some point the text "Did you mean: selenese" appears on the page. "Selenese" is what the Selenium project calls the invocation methods for Selenium. Selenesse implements all of the Selenium waitFor* methods as well. These are critical when testing AJAX calls in web pages. A general pattern for AJAX tests is a click() or select;() method followed by a waitFor as the test waits for certain text to appear in the page, or for a certain page element to appear.

The sixth line checks that the text "selenesse" appears in the Google search results.

The last line checks that the text "watir" does not appear in the Google search results.

Note that Selenesse does not implement any of the verify* methods of Selenium. Instead it uses the native Fitnesse methods ensure(), reject(), and check().

Selenesse and Selenium and Selenium-IDE
With some well-documented exceptions, Selenesse implements Selenium commands as described in the javadoc here. Users may also wish to refer to the Selenium Reference here. The Selenium Reference is less accurate than the javadoc, but does contain significant documentation and background information about how Selenium works.

Selenium-IDE is a test recording tool that may be used with Selenesse. The Selenesse download contains instructions to install a Selenium-IDE "Format" that creates near-perfect Selenesse wiki markup. The code for the Format came originally from Socialtext, Inc., who uses a similar wiki-based test system based on their own Socialtext wiki and not on Fitnesse. The Google search example above looks like this when created with the Selenium-IDE wiki Format:

| type | q | selenesse | | click | btnG | | | verifyTextPresent | Did you mean: selenese | | | verifyTextPresent | Selenesse | |

Remember, Selenesse does not implement the Selenium verify* methods such as verifyTextPresent(), so the user would have to manually translate those to use Fitnesse ensure() like so:

| ensure | isTextPresent | selenesse |

and the Fitnesse check() method is used like

| check | getText | | |

Tests and suites
The Fitnesse scenario exists on a page in Fitnesse called ScenarioLibrary. There is one ScenarioLibrary for each Fitnesse Suite, and that ScenarioLibary may contain an arbitrarily large number of scenarios. Each Fitnesse Suite may contain an arbitrarily large number of Test pages. Each Test page may invoke any scenario in the ScenarioLibrary for that Suite as many times as it likes.

For example, we could have a suite called SuiteSearchGoogle, and under SuiteSearchGoogle would be a single child page named ScenarioLibrary, together a child page TestSearch. Typical URLs for such pages look like
http://localhost:8080/SuiteSelenesseExample.SuiteSearch.ScenarioLibrary http://localhost:8080/SuiteSelenesseExample.SuiteSearch.TestSearch

The Test pages would contain the wiki markup
#!| script | | Search google |

For more information about how to create and optimize scenarios, Tests, and Suites, how to use variables and decision tables, etc. etc., see the documentation for Fitnesse and for SLIM. Fitnesse has far too many features to document here.

Getting Selenesse
Selenesse is available for download or checkout from http://github.com/marisaseal/selenesse.

We recommend that users have some basic familiarity with Fitnesse itself before tackling Selenesse. All of the Selenesse documentation and examples exist as a Fitnesse wiki named SuiteSelenesseExample, so it is helpful for someone wanting to use Selenesse to have a basic understanding of how Fitnesse works.

Related Content:
Introducing Selenesse, the modern bridge between Fitnesse and Selenium
Learn how two testers scaled back pre-existing test frameworks and made us of hybrid automation tools, Fitnesse and Selenium, to drive user interface testing forward.

Sauce Labs adds business value to Selenium testing with IDE
New functionality for Selenium open source testers provided by Sauce IDE. Sauce Labs has added record and playback testability that doesn't require code writing.

That said, after installing Selenesse within Fitnesse, there is extensive documentation on how to use Selenesse, including an executable example of the Google search described here. Finally, there is a mail list for selenesse users (and for the curious) at http://localhost:8080/SuiteSelenesseExample.SuiteSearch.TestSearch. Questions are welcome.

If you try out Selenesse, please drop us a line on the mail list!

Dig Deeper on Topics Archive

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.