Forum Discussion

tcuser234's avatar
New Contributor
2 years ago

Set up examples from external files



I intend to read data from external files and set up Examples for scenarios, rather than defining examples in feature file. Is there any way to achieve it?


Just notice that in the function of before scenario (@beforescenario), there is an object called scenario, and it has an attribute of Examples. I can't find any build-in methods to modify it, i.e. adding an example. Anyone can shed some lights on it?


Thanks in advance!

5 Replies

    • tcuser234's avatar
      New Contributor

      Thanks for your reply. 


      Actually my question is about setting examples. The normal way we feed data for scenarios is to define a section called Examples, then list test data. However, I am looking for a method to feed the data from external files like csv or text. Hope I make myself clear. ğŸ˜

      • SAHMED's avatar
        Occasional Contributor



        Any solution yet? or you still waiting/working. I'm searching for solution like this as well. I want to know If I can get any object for Examples (table). 


        Plus I want to execute my scenario(s) for specific row, not for all at a time but single one at time.




  • rraghvani's avatar
    Champion Level 3

    I thought I found a solution,

    Feature: Calculator
        Scenario Outline: Add two numbers outline
            Given the first number is <first>
            And the second number is <second>
            When the two numbers are added
            Then the results should be <third>
            Examples: {'datafile': 'C:\\Temp\\Book2.csv'}

    Unfortunately, it doesn't work. 


    There's doesn't seem to be any support for external input sources.