在Yii框架中使用Behat,我观察到它非常奇怪的行为:当使用像
这样的步骤时Behat没有找到一些文本Then I should see "some text"
有些文字是正常的,但有些 - 不是。为了确保我在页面上,我认为我在,我在视图文件中添加了一些标记,Behat看到了它们。
所以,情景是
Scenario: editing journal
Given the following journals are present:
| name | link | description |
| Murzilka | http://www.murz.com | advanced child journal|
| Nature | www nature com | nice journal |
When I am on edit page for journal "Nature"
Then I should see "Update Nature"
Then I should see "nice journal"
Then I should see "1qazxsw2" <-- a marker
Then I should see "2wsxcde3" <-- a marker
Then I should see "www nature com"
然后输出
Scenario: editing journal
# features\journal.feature:21
Given the following journals are present:
# FeatureContext::theFollowingJournalsArePresent()
| name | link | description |
| Murzilka | http://www.murz.com | advanced child journal |
| Nature | www nature com | nice journal |
When I am on edit page for journal "Nature"
# FeatureContext::iAmOnEditPageForJournal()
Then I should see "Update Nature"
# FeatureContext::assertPageContainsText()
Then I should see "nice journal"
# FeatureContext::assertPageContainsText()
Then I should see "1qazxsw2"
# FeatureContext::assertPageContainsText()
Then I should see "2wsxcde3"
# FeatureContext::assertPageContainsText()
Then I should see "www nature com"
# FeatureContext::assertPageContainsText()
The text "www nature com" was not found anywhere in the text of the current page.
奇怪的是,如果我去页面(在测试环境中),我会看到所有这些短语,包括“www nature com”。
答案 0 :(得分:2)
当“我应该看到......”步骤引用输入字段中的文本时,偶尔会出现问题。我发现为此目的有一个预定义的步骤
Then /^the "(?P<field>(?:[^"]|\\")*)" field should contain "(?P<value>(?:[^"]|\\")*)"$/
- Checks, that form field with specified id|name|label|value has specified value.
# FeatureContext::assertFieldContains()
应该像这样使用:
Then the "journal[name]" field should contain "nice journal"
通过此修改,Behat可以找到所有短语。