Playframework 2.0和Selenium入门

Jac*_*ter 5 tdd selenium scala playframework playframework-2.0

我正在使用Play framework 2.0.我想用Selenium编写一些基于浏览器的验收测试,但我之前从未使用过Selenium,必须少用Play或Scala集成它.

我可以复制和使用的基本设置是什么?

bja*_*tek 1

这是一个有关如何使用 HTMLUnit 执行此操作的示例(如果对您有帮助的话)。

\n\n

灵感来自:\n https://github.com/joscha/Play20/blob/master/samples/scala/computer-database/test/IntegrationSpec.scala

\n\n
import org.specs2.mutable._\nimport play.api.test._\nimport play.api.test.Helpers._\nimport org.fluentlenium.core.filter.FilterConstructor._\nclass IntegrationSpec extends Specification {\n  "Application" should {\n    "work from within a browser" in {\n      running(TestServer(3333), HTMLUNIT) { browser =>\n        browser.goTo("http://www.myRockstartDomain.com:3333/")\n          browser.$("header h1").first.getText must contain("Play 2.0 sample application \xe2\x80\x94 Computer database")\n          browser.$("#pagination li.current").first.getText must equalTo("Displaying 1 to 10 of 574")\n          browser.$("#pagination li.next a").click()\n          browser.$("#pagination li.current").first.getText must equalTo("Displaying 11 to 20 of 574")\n          browser.$("#searchbox").text("Apple")\n          browser.$("#searchsubmit").click()\n      }\n    }\n  }\n}\n
Run Code Online (Sandbox Code Playgroud)\n