0

Is it possible to generate dynamically test scenarios for each element in array?

I've got two arrays with elements (each for an environment against which I run test suite), like that:

devEnv = ['link1', 'link2', 'link3', 'link4']

testEnv = ['link1', 'link2', 'link3']

In dev env there are 4 link available, in test env only 3.

In protractor + jasmine you can get its in a loop like that: https://stackoverflow.com/a/35114139/6331748

I'm using protractor + cucumber.

When I hardcode in feature file date like that:

Scenario Outline:
    Given I am on main page
    When I click "<linkToGo>" link
    Then I should be on "<linkToGo>" page

    Examples:
        |linkToGo |
        |link1    |
        |link2    |
        |link3    |
        |link4    |

The tests will pass for dev env - all 4 links will be clicked, but on test env there's not link4.

Any ideas how to solve case like that?

Kacper
  • 1,201
  • 1
  • 9
  • 21

1 Answers1

1

I suggest to create 2 different scenario with different Tags

  1. @Dev

    Scenario Outline: To test Dev Enmv Given I am on main page When I click "" link Then I should be on "" page

    Examples: |linkToGo | |link1 | |link2 | |link3 | |link4 |

  2. @Test

    Scenario Outline: To test Test envmt Given I am on main page When I click "" link Then I should be on "" page

    Examples: |linkToGo | |link1 | |link2 | |link3 |

Same Gherkin line is used with same SD. Now depends on your need, pass the tag to Configuration file Hope this will solve your problem.