Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #260 from vansweej/selenium

Selenium
  • Loading branch information...
commit e4492896f50eaf413e3642675c35f8223a2d60ad 2 parents 9d76540 + 74d6fea
@casualjim casualjim authored
View
7 project/build.scala
@@ -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"
)
@@ -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
@@ -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 {
View
22 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
View
55 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 { }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.