【发布时间】:2013-05-17 20:35:52
【问题描述】:
我在我的 Symfony2 项目中使用 Behat 和 Mink 进行集成测试,并成功地在整个站点中使用了以下语法,但在一个地方我遇到了非常奇怪的错误,这些错误似乎没有任何意义(对我来说) :
场景如下:
Scenario: I can create a new event
Given I am on "/event/new"
When I fill in the following:
| Title | Test Event |
| Event Details | Description |
And I check the "Active" option for "Published"
And I press "Save"
Then I should see "New event posted successfully!"
我收到以下错误:
Form submit button for field with xpath
"(//html/.//*[self::input | self::textarea | self::select][not(./@type = 'submit'
or ./@type = 'image' or ./@type = 'hidden')][(((./@id = 'Title' or ./@name = 'Title')
or ./@id = //label[contains(normalize-space(string(.)), 'Title')]/@for) or
./@placeholder = 'Title')] | .//label[contains(normalize-space(string(.)),
'Title')]//.//*[self::input | self::textarea | self::select][not(./@type = 'submit' or
./@type = 'image' or ./@type = 'hidden')])[1]"not found
In step `And I fill in the following:'.
所以我认为它在“标题”字段上出错,但错误消息暗示它正在寻找提交按钮!?如果我将场景中的字段名称更改为不存在的名称,我会收到预期的(并且更具可读性)“未找到字段”错误消息。
【问题讨论】:
-
我已将其缩小到表单中包含的 js 脚本中的一行:
var errorString = '<div class="help-inline time-error">Please select a valid time for your event</div>';如果我将“div”更改为“span”,则测试通过 - 有什么想法吗?