'How to read csv file based on scenario outline
I am using cucumber and trying to read row from my csv file based on scenario name.
Feature file :
Scenario Outline: Verify content of my probblem1
Scenario, Title1, Title2, Title3, Title4, Title5
Verify content of my probblem1, Text1, Text2, Text3, Text4, Text5,
Verify content of my probblem2, Text1, Text2, Text3, Text4, Text5,
Solution 1:[1]
The short answer is that reading CSV files from a Scenario written in Gherkin is not supported.
If you want to read data from an Excel file, you have to implement it yourself and call that functionality from your step. As @marit notices, Apache POI may be one option.
Solution 2:[2]
The feature you are looking for is supported in gherkin with qaf. You can have examples in CSV/Excel/XML/json/DB
Scenario Outline: Search Keyword using data from file
When I search for "<searchKey>"
Then I get at least <number> results
Then it should have "<searchResult>" in search results
Examples:{'datafile':'resources/testdata.csv'}
where your csv file may look like below:
searchKey,searchResult,number,TestCaseId
QMetry QAF, QMetry Automation Framework,15,TC-001
Selenium ISFW,Infostretch Test Automation Framework,45,111
You can refer documentation and step-by-step tutorial
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Thomas Sundberg |
Solution 2 | user861594 |