Home > Enterprise >  I'm looking to pass a table from a feature to the step definition
I'm looking to pass a table from a feature to the step definition

Time:10-04

I'm trying to write a test that I can run for multiple profile types. My goal is to first take the profile type row and then create a list of labels where the value is true then assert them with a list from the UI (I'm happy with this part).

I've done something similar in the past but can't remember how to grab the table row based on the profile type (this can be passed in to the scenarioContext container) and then name the list based on the true values

Then the user can see the following Fields

 | profile            | label1 | label2 | 
 | customer           | true   | false  |
 | system admin       | true   | true   |

Any advice is appreciated. thank you :)

CodePudding user response:

List<string> expectedValues = new List<string>();

foreach(TableRow row in table.Rows)
{
    if (row[0].Equals(_scenarioContext.Get<string>(Constants.PROFILE)))
    {
        TableRow headers = row;
        foreach (KeyValuePair<string, string> header in headers)
        {
            if(header.Value.Equals("true"))
            expectedValues.Add(header.Key);
        }
        break;
    }
}
  • Related