我在我的 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:'.
所以我认为它在“标题”字段上出错,但错误消息暗示它正在寻找提交按钮!?如果我将场景中的字段名称更改为不存在的名称,我会收到预期的(并且更具可读性)“未找到字段”错误消息。