【发布时间】:2015-06-26 09:53:03
【问题描述】:
我正在尝试使用 ScalaTest 和 FluentLenium 在 Play Framework 中填写、提交和测试 Web 表单。看起来应该很简单,但是我遇到了各种各样的问题。
首先,有问题的网络表单的一部分:
<form class="signin" id="loginform" method="POST" action="/login">
<div class="form-group">
<label for="name">Email Address:</label>
<input type="email" class="form-control" placeholder="Enter Email Address" id="email" name="email" required />
...
这在真正的网络浏览器上运行良好。现在,当我尝试填写并提交表单时,问题就来了:
@RunWith(classOf[JUnitRunner])
@SharedDriver(deleteCookies = false)
@SharedDriver(`type` = SharedDriver.SharedType.PER_CLASS)
class TestWebsiteAuthentication extends Specification {
"Application" should {
"login as an administrative user on the web site" in new WithBrowser with GPAuthenticationTestUtility {
browser.goTo(loginURL)
browser.fill("#email").`with`(prerequisiteAccounts.head.userIdentity) must equalTo(OK)
...
在最后一行,我得到一个异常:
[info] x 以管理用户身份登录网站 [错误] 'org.fluentlenium.core.action.FillConstructor@1c25c183' 不等于 '200' (TestWebsiteAuthentication.scala:93) [错误] 预期:200 [错误] 实际:org.fluentlenium.core.action.FillConstructor@1c25c183
有什么想法我在这里做错了吗?
我试过去掉“必须等于(OK)”,但这只会导致表单在提交时失败——不幸的是,我找不到任何关于如何做到这一点的文档,所以我'我基本上是一点一点地拼凑起来的。指向相关文档的指针将不胜感激 - Tyrpesafe 似乎没有任何完整的东西......只是让你开始的“预告片”,但没有深度。 :-(
【问题讨论】:
标签: forms scala playframework-2.0 scalatest fluentlenium