我使用的是Play framework 2.0。我想用Selenium编写一些基于浏览器的验收测试,但我以前从未使用过Selenium,必须减少它与Play或Scala的集成。
什么是我可以复制和使用的基本设置?
如果有帮助的话,这里有一个关于如何使用HTMLUnit的例子。
灵感来源: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()
}
}
}
}