Behat步骤“我应该看到"看不到 [英] behat step "I should see" does not see

查看:53
本文介绍了Behat步骤“我应该看到"看不到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Yii框架中使用Behat,我观察到它的行为很奇怪:在使用

Using Behat in Yii framework, I am observing its quite strange behaviour: Behat does not find some text when using steps like

Then I should see "some text"

它找到正常的一些文本,但没有-有些.为确保我在页面上,我在视图文件中添加了一些标记,Behat会看到它们.

Some text it finds normaly, but some - not. To be sure that I am on the page I think I am on, I've added sort of markers in the view files and Behat sees them.

因此,情况是

  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"在内的所有短语.

The strange is that if I go to the page (in test environment), I see all those phrases including "www nature com".

推荐答案

当步骤然后我应该看..."引用输入字段中的文本时,会偶尔出现该问题.我发现为此目的有一个预定义的步骤

The problem sporadically appears when the step "Then I should see ..." refers to the text in an input field. I've found out that for this purpose there is a predefined step

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会找到所有短语.

With this modification, Behat finds all phrases.

这篇关于Behat步骤“我应该看到"看不到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆