Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cucumber : How to read examples from external excel file for Scenarios Outline

My requirement is to read examples from external excel file rather than hard code it into feature file. I have more than 100 examples which is difficult to maintain in feature file. Can you please help me on this.

Here is my scenario -

Scenario Outline: Browser Test

    When I visit the URL <base>/<page>/<ordNumber>/<custName>
    Then the browser contains test <custNumber>

    Examples: 
     | base                         | page   | ordNumber | custName |
     | http://www.stackoverflow.com | orders | 123       | John     |
     | http://www.stackoverflow.com | orders | 456       | Mike     |
     | http://www.stackoverflow.com | orders | 789       | Tom      |

I want to create an excel file with examples data and load it during runtime

examples.xls

 | base                         | page   | ordNumber | custName |
 | http://www.stackoverflow.com | orders | 123       | John     |
 | http://www.stackoverflow.com | orders | 456       | Mike     |
 | http://www.stackoverflow.com | orders | 789       | Tom      |

Thanks.

like image 715
AniSaw Avatar asked Oct 29 '22 01:10

AniSaw


1 Answers

What you are looking for is supported using gherkin with QAF. QAF support different external data providers including json, xml, csv, excel and DB. It also supports multiple bdd syntax.

Using Gherkin or BDD2 with QAF below is the example:

Scenario Outline: Browser Test

    When I visit the URL <base>/<page>/<ordNumber>/<custName>
    Then the browser contains test <custNumber>

    Examples: {'datafile': 'resources/testdata/examples.xls'}

There are lots of other features as well for resource management, execution configuration, driver management and parallel execution.

like image 92
user861594 Avatar answered Nov 16 '22 21:11

user861594