2013-09-24 137 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