I am testing a product search form. Products can be searched by various parameters (for example, status, material, light, etc.). When I want to search by status, I do the following:
Scenario Outline: search by status
When I select "<status>" from "search_form_status"
And I press "Search"
And I wait for 3 seconds // implemented
And I follow random link from test result table // implemented
Then I should see "<status>" in the "div#status" element
Examples:
|status |
|enabled |
|disabled|
And everything is all right. But if I wanted to test the same search for, say, productMaterial, I'm stuck as product materials that can be changed at any time (we may need new materials, edit material names, or delete old unused ones). Add to that the fact that materials will differ in the test environment and on the production site. I know I can do something like:
Given I select product material
And let's implement the foreach loop step as follows:
$matList = $this->getSession()->getPage()->findAll('css', "select option");
foreach($matList as $material){
}
}
But how do I create all the other steps like in the example status
? I am guessing that I would like to use the variable $material
in the next steps in the search.feature file for the steps that follow this custom step. But how can I do this? How would I go through the whole list of options and do a bunch of steps on each iteration?
source
to share