gjaiwal
2 years agoOccasional Contributor
Execute Scenario from AfterFeature function
I was trying to call a specific scenario from a specific Feature file.
And it looks like the listed Scenario is not getting executed.
The scenario is related to deleting everything that is created inside the test cases.
It needs to open up the browser and execute the code, same as the normal Scenario.
Have a look at the code here:
AfterFeature(function (feature){
// Perform some action after executing a feature file, for example:
for (i = 0; i < Features.Count; i++) {
var name = Features.Item(i).Name;
// Check the feature name
if (name.indexOf("TeardownFeature") >= 0) {
// Features.Item(i).Run(); NOT WORKING
// Iterate through scenarios
for (j = 0; j < Features.Item(i).Scenarios.Count; j++) {
var scenarioName = Features.Item(i).Scenarios.Item(j).Name;
// Check the scenario name
if (scenarioName.indexOf(feature.Name) >= 0) // I gave same scenario name as exiting feature
Features.Item(i).Scenarios.Item(j).Run(); // NOT WORKING
}
}
}
})
This is another issue from the original post?
Check your project settings,
and define what you want your project to do, if an error occurs.
Or capture the error and deal with it appropriately, instead of allowing TC to deal with it.