How to read csv file based on scenario outline

北城余情 提交于 2019-12-24 12:27:41

问题


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,

回答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.




回答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



来源:https://stackoverflow.com/questions/49812201/how-to-read-csv-file-based-on-scenario-outline

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!