1

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

Milos Pesic
  • 720
  • 2
  • 8
  • 23

1 Answers1

1

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

  • Get the count.
  • Store it in variable
  • Loop it in step definition
Aravin
  • 6,605
  • 5
  • 42
  • 58