behat在使用javascript时失败,但在不使用javascript的情况下成功

behat在使用javascript时失败,但在不使用javascript的情况下成功,javascript,bdd,behat,mink,Javascript,Bdd,Behat,Mink,我正在使用Behat/Mink为我的php应用程序编写验收测试,发现了一件奇怪的事情:当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 proper

我正在使用Behat/Mink为我的php应用程序编写验收测试,发现了一件奇怪的事情:当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.

原因可能是什么?

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"

谢谢!成功了!我只需调整步骤如下:然后我等待5秒钟。