Can Behat表可用于检查多个文本标签

时间:2014-03-12 01:50:17

标签: cucumber behat mink

将Behat与mink和Drupal扩展一起使用。

我特意有一个包含多个标签的页面,我想确认所有文本。我想这样做而不必输入类似的内容。

Then I should see "Filter"

有没有办法检查所有希望使用Pystrings或Tables的文本,它们可以用来填充文本字段:

And I fill in "Options" with:

只是认为可能更容易一次检查所有内容而不必提供多个步骤

=====

更新

在向dblack提供一些指示后,我在其自己的功能中使用了以下内容来测试属于同一页面的所有标签:

注意:我使用mink和UIBusinessSelector扩展       “登录”也是一个自定义功能

  

后台:所有方案都需要管理员登录,然后创建过滤器,然后确认页面标签          鉴于我以管理员身份登录          当我进入“产品过滤器”页面时          然后点击“添加过滤器按钮”

   Scenario Outline: Verifying page text
   Then I should see "<ThisText>"
   Examples:
  | ThisText |
  | Filter by SKUs             |
  | Filter by Package Name     |
  | Filter by Campaign Medium  |
  | Filter by Product Category |
  | Filter by Product Selection |
  | Filter by Product Holiday Experience |
  | Filter by Product Star Rating |
  | Filter by Product Destination |
  | Filter by Product Duration |
  | Filter by Product Supplier |
  | Filter by Air Ex Point     |
  | Filter by Land Ex Point    |
  | Filter by Product departure |
  | Filter by Ship name        |
  | Filter by Cruise Line      |
  | Remove $0 products        |
  | Human readable name       |

1 个答案:

答案 0 :(得分:1)

如果您想使用表格检查每个标签,可以使用scenario outlines

Scenario Outline: Check labels
    Given I am logged on as "someuser"
    When I go to the homepage
    Then I should see "<mylabel>"
    Examples:
    | mylabel          |
    | Filter           |
    | Some Other Label |
    | Another Label    |

缺点是场景大纲是模板,其中场景大纲为每个提供的示例运行一次 - 例如,您只是想知道页面上的所有标签,所以您真的不想登录并请求每个标签。

如果我想确保一个页面包含它应该包含的所有标签,我会这样做(该场景只运行一次):

Scenario: Check labels
    Given I am logged on as "someuser"
    When I go to the homepage
    And I should see "Filter"
    And I should see "Some Other Label"
    And I should see "Another Label"