I am using Play framework 2.0. I would like to write some browser-based acceptance test using Selenium, but I have never used Selenium before must less integrated it with Play or Scala.
What is a basic setup that I can copy and work from?
Here is an example on how to do it with HTMLUnit, if that helps you.
Inspired from: https://github.com/joscha/Play20/blob/master/samples/scala/computer-database/test/IntegrationSpec.scala
import org.specs2.mutable._
import play.api.test._
import play.api.test.Helpers._
import org.fluentlenium.core.filter.FilterConstructor._
class IntegrationSpec extends Specification {
"Application" should {
"work from within a browser" in {
running(TestServer(3333), HTMLUNIT) { browser =>
browser.goTo("http://www.myRockstartDomain.com:3333/")
browser.$("header h1").first.getText must contain("Play 2.0 sample application — Computer database")
browser.$("#pagination li.current").first.getText must equalTo("Displaying 1 to 10 of 574")
browser.$("#pagination li.next a").click()
browser.$("#pagination li.current").first.getText must equalTo("Displaying 11 to 20 of 574")
browser.$("#searchbox").text("Apple")
browser.$("#searchsubmit").click()
}
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With