2013-09-24 195 views
0

我正在使用Behat/Mink爲我的php應用程序編寫驗收測試,並發現了一件奇怪的事情:當javascript打開時,Behat找不到輸入字段,而當它找到相同的字段時javascript已關閉。behat javascript失敗,但沒有成功

準確地說:以下情形

Scenario: adding article keywords, no javascript used 
Given I am on "articles/create" 
When I fill in "Articles[title]" with "About all properties" 
... 

完全通過。但只要我添加標籤的JavaScript上述情況

@javascript  
Scenario: adding article keywords 
Given I am on "articles/create" 
When I fill in "Articles[title]" with "About all properties" 

啓動失敗:

When I fill in "Articles[title]" with "About all properties" 
# FeatureContext::fillField() 
Form field with id|name|label|value "Articles[title]" not found. 

可能是什麼原因?

回答

1

@javascript將使用Selenium驅動程序運行您的功能,Selenium可能需要一些時間來加載頁面,您可以嘗試在'我正在...'之後添加一個'我等待...'的步驟。 。希望這只是DOM需要時間來加載。

@javascript  
Scenario: adding article keywords 
Given I am on "articles/create" 
Then I wait 1000 
When I fill in "Articles[title]" with "About all properties" 
+0

非常感謝!有效!我只需調整步驟如下:**然後我等待5秒**。 – Andrew