Reputation: 720
I've written a feature:
Feature: Open List item
Scenario: As a valid user I can open list item
When I press list item number 0
Then I do something...
Then I go back
What I would need is to open every item of ListView (not only 0th), so how could I specify a loop that would in the end iterate through whole ListView, or some specified maximum index - ie. for parameter value 5 it should execute this scenario for 0th, 1th, 2nd, 3rd, 4th and 5th item.
So, two questions: 1) How to create a loop? 2) How to parametrize execution
Regards, Milos
Upvotes: 1
Views: 254
Reputation: 7077
1. If you know the exact loop count, you can use scenario outline
in cucumber.
Feature: Open List item
Scenario: As a valid user I can open list item
When I press list item number <count>
Then I do something...
Then I go back
Examples:
| count |
| 1 |
| 2. |
| .. |
| n |
More details about scenario outline: https://github.com/cucumber/cucumber/wiki/Scenario-Outlines
Or
2. You can get count using query()
& iterate using for each
loop in ruby
For getting count query("view").count
Upvotes: 1