0

Using Behat with mink and Drupal extensions.

I essentually have a page with multiple labels and I want to confirm the text of them all. I want to do this without having to enter something like.

Then I should see "Filter"

Is there a way to check all the text im expecting using Pystrings or Tables in a similar way they can be used to populate text fields:

And I fill in "Options" with:

Just thought it maybe easier to check it all at once rather than having to provide multiple steps

=====

Update:

After being provided some direction from dblack I used the following inside its own feature to test all labels that fall on the same page:

Note: I use the mink and UIBusinessSelector extensions Also the 'login' is a custom function

Background: All scenarios require an admin login, then create a filter then confirm page labels
Given I login as an admin
When I go to the page "Product Filter"
And I click the "Add Filter Button"

   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       |
Rudie
  • 52,220
  • 42
  • 131
  • 173
Scotty G
  • 11
  • 1
  • 6

1 Answers1

1

If you want to use a table to check each of your labels, you could use 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    |

The drawback is that scenario outlines are templates, where the scenario outline is run once for each of the examples provided - for your example, you just want to know all the labels are on the page so you don't really want to make a log in and request for each label.

If i wanted to ensure a page contained all the labels it was supposed to, I would just do this (the scenario would be run just once):

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"
dblack
  • 79
  • 8
  • Hi, Tried that but the problem is that it resets the scenario using "scenario outline" and then it wont execute the steps provided in the scenario outline. Eg. i have a background step that logs the user in. Then this step checks the page text but the problem is how do I get to the page I need to as it essentually just runs the login step and I cannot define a page for it to go to in the Scenario Outline ? anyway around that without going to the page in the 'background' which would then affect the rest of the scenario tests I have included in the feature – Scotty G Mar 14 '14 at 00:19
  • Hi Scotty, the background and other steps in the scenario should be executed for each example - i have edited my answer to reflect that, but also given a better example. Scenario outlines (to support your wish for putting the labels in a table) have their place, but probably not the best idea for your needs? – dblack Mar 17 '14 at 05:08
  • Hi dblack, essentually I wanted to get away from listing them all as "I should see". found a way to do it based on your initial response, however I needed to create a seperate feature that contained a 'background' detailing all the initial step to lead up to that page. - Have udpated the initial question with this. – Scotty G Mar 17 '14 at 23:38