2013-05-17 214 views
1

我在我的Symfony2項目中使用Behat和Mink進行集成測試,並在整個網站中使用了以下語法,但是在一個地方我發現了一些非常奇怪的錯誤似乎任何意義(給我):用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:'. 

所以我想這是errorin g在「標題」字段中,但錯誤消息意味着它正在尋找一個提交按鈕!?如果我將場景中的字段名稱更改爲不存在的字段名稱,我會得到期望的(並且更具可讀性的)「未找到字段」錯誤消息。

+0

我已經縮小到包括在所述形式的JS腳本內的單個行: '變種Errorstring,則=「

Please select a valid time for your event
」;' 如果我改變‘DIV’到‘跨度’,測試通過 - 任何想法? – tanGee

回答

3

看來,包括HTML片段:

var errorString = '<div class="help-inline time-error">Please select a valid time for your event</div>'; 
在表單中的JavaScript部分

搞砸DOM解析 - 將在實際的形式DIV內容,並與CSS隱藏,然後使用jQuery選擇把它放在我想要它工作的地方!