Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Selenium Output format for Specs2
JavaScript Scala
Latest commit 0845580 @jesseeichar updated seleniumFormat
Failed to load latest commit information.
src/test/scala/com/camptocamp/specs2/selenium improved waitfor
.gitignore first commit with examples and format improved waitfor
Selenium IDE.png added an image of the script being exported
build.sbt first commit with examples and format


This project contains a selenium IDE format that outputs the recorded selenium script in scala and more specifically for Specs2.

For those not familiar Selenium is a framework for writing integration tests of web-applications. It contains drivers for opening browsers and driving the browser as well as making assertions and verifications of elements on the page. Since it uses the actual browser it can verify that all browser correctly handle the web application.

Selenium IDE is a firefox browser plugin that allows test script development by recording a users input and allowing the script to be re-run and tuned. It allows the scripts to be exported in several formats including Java, RSpec and now Specs2.


Running Tests

To run the exported tests you need to add the dependencies in

Fragment Formatting

The output format uses comments to provide the output format with metadata on how to create the specs. The current rules are:

  • If a comment starts with a - that line indicates the start of a new fragment

More rules will be added in the future for formatting etc...

Example Output

The selenium script

Selenium Script Snapshot

is exported as the following code:

package com.example.tests

    import org.specs2._
    import matcher.ThrownExpectations
    import specification.Step
    import Thread._
    import org.openqa.selenium.WebDriverBackedSelenium

    class `Google Search` extends Specification with ThrownExpectations { 

      lazy val selenium = new WebDriverBackedSelenium(new org.openqa.selenium.firefox.FirefoxDriver(), "")

      def is = 
      sequential                                                ^
      "This specification tests Google Search"    ^ Step(() => selenium) ^ 
        "Searching for toys should return a toys r us result"             ! scala_specs2_1^
        "clicking the Bilder link should open the results for images search"        ! scala_specs2_2 ^
                                                                                    Step(selenium.stop()) ^

      def scala_specs2_1 = {
        import selenium._
        `type`("q", "toys")
        isTextPresent("Toys\"R\"Us") must beTrue

      def scala_specs2_2 = {
        import selenium._
        isTextPresent("Verwandte Suchanfragen") must beTrue

      val TIMEOUT = 30
      private def doWait(assertion: => Boolean) = 
        (1 to TIMEOUT).view map {_=> sleep(1000)} find { _ => assertion }

Something went wrong with that request. Please try again.