Skip to content

Commit

Permalink
Merge pull request #260 from vansweej/selenium
Browse files Browse the repository at this point in the history
Selenium
  • Loading branch information
casualjim committed Mar 23, 2013
2 parents 9d76540 + 74d6fea commit e449289
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 2 deletions.
7 changes: 5 additions & 2 deletions project/build.scala
Expand Up @@ -175,7 +175,9 @@ object ScalatraBuild extends Build {
httpclient,
httpmime,
jodaTime % "provided",
jodaConvert % "provided"
jodaConvert % "provided",
scalatest(sv),
seleniumjava
)),
description := "The abstract Scalatra test framework"
)
Expand Down Expand Up @@ -282,6 +284,7 @@ object ScalatraBuild extends Build {
lazy val scalate: MM = sv => "org.fusesource.scalate" % scalateArtifact(sv) % scalateVersion(sv)
lazy val scalatest: MM = sv => "org.scalatest" %% "scalatest" % scalatestVersion(sv)
lazy val scalaz = "org.scalaz" %% "scalaz-core" % "7.0.0-M8"
lazy val seleniumjava = "org.seleniumhq.selenium" % "selenium-java" % "2.31.0"
lazy val servletApi = "org.eclipse.jetty.orbit" % "javax.servlet" % "3.0.0.v201112011016" artifacts (Artifact("javax.servlet", "jar", "jar"))
lazy val slf4jSimple = "org.slf4j" % "slf4j-simple" % "1.7.2"
lazy val specs: MM = sv => "org.scala-tools.testing" % "specs" % specsVersion(sv) cross specsCross
Expand Down Expand Up @@ -327,7 +330,7 @@ object ScalatraBuild extends Build {

private val scalatestVersion: String => String = {
case sv if sv startsWith "2.8." => "1.8"
case _ => "1.9.1"
case _ => "2.0.M5b"
}

private val specsCross = CrossVersion.binaryMapped {
Expand Down
22 changes: 22 additions & 0 deletions specs2/src/main/scala/org/scalatra/test/specs2/SeleniumSpec.scala
@@ -0,0 +1,22 @@
package org.scalatra
package test
package specs2

import org.specs2.Specification
import org.specs2.specification._
import org.specs2.main.ArgumentsShortcuts._

import SeleniumWebBrowser._

/**
* A base specification structure that starts the tester before the
* specification and stops it afterward. Clients probably want to extend
* ScalatraSpec or MutableScalatraSpec.
*/
trait BaseSeleniumSpec extends BaseSpecification with SeleniumTests {
override def map(fs: =>Fragments) = sequential ^ Step(start()) ^ super.map(fs) ^ Step(stop())
}

trait MutableSeleniumSpec extends Specification with BaseSeleniumSpec

trait SeleniumSpec extends Specification with BaseSeleniumSpec
55 changes: 55 additions & 0 deletions test/src/main/scala/org/scalatra/test/SeleniumWebBrowser.scala
@@ -0,0 +1,55 @@
package org.scalatra.test

object SeleniumWebBrowser {
trait Chrome extends org.scalatest.selenium.Chrome {
/**
* remapping of a selenium/scalatest method since it conflicts with
* a specs2 method
*/
def nameQuery(elementName: String): NameQuery = {
name(elementName)
}
}

trait Firefox extends org.scalatest.selenium.Firefox {
/**
* remapping of a selenium/scalatest method since it conflicts with
* a specs2 method
*/
def nameQuery(elementName: String): NameQuery = {
name(elementName)
}
}

trait HtmlUnit extends org.scalatest.selenium.HtmlUnit {
/**
* remapping of a selenium/scalatest method since it conflicts with
* a specs2 method
*/
def nameQuery(elementName: String): NameQuery = {
name(elementName)
}
}

trait InternetExplorer extends org.scalatest.selenium.InternetExplorer {
/**
* remapping of a selenium/scalatest method since it conflicts with
* a specs2 method
*/
def nameQuery(elementName: String): NameQuery = {
name(elementName)
}
}

trait Safari extends org.scalatest.selenium.Safari {
/**
* remapping of a selenium/scalatest method since it conflicts with
* a specs2 method
*/
def nameQuery(elementName: String): NameQuery = {
name(elementName)
}
}

trait SeleniumTests extends EmbeddedJettyContainer with HttpComponentsClient { }
}

0 comments on commit e449289

Please sign in to comment.