| || |
Data Driven Coded UI test
So I am running a data driven coded UI test on a web application. The data is coming from a .csv. Things are iterating through just fine, but the issue I am running into is once it runs out of data in the csv file the test keeps running, but where is injecting the data from the data source it is just blank.
Here is the code. What I am trying to find out is, there something I need to add to make it stop once it runs out of data? Like in the TestCleanup? Or do I just not have something set correctly.
/// Summary description for SomeLoop
public class SomeLoop
private readonly List<string> errors = new List<string>();
public void CodedUITestMethod1()
var RestaurantID = TestContext.DataRow;
var OHome = new OHome();
var orderButton = new HtmlHyperlink(OHome.UIMSNcomInternetExplorWindow.U IOhouseOnlDocument);
var propExp = new PropertyExpression("href", "MenuItem", PropertyExpressionOperator.Contains);
catch (Exception e)
orderButton = null;
// To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
#region Additional test attributes
// You can use the following additional attributes as you write your tests:
////Use TestInitialize to run code before running each test
//public void MyTestInitialize()
// // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
////Use TestCleanup to run code after each test has run
public void MyTestCleanup()
foreach (var error in errors)
///Gets or sets the test context which provides
///information about and functionality for the current test run.
public TestContext TestContext
testContextInstance = value;
private TestContext testContextInstance;
I'd start by checking your csv file in a text editor for extra blank rows. Then add an explicit catch for an empty RestaurantID. (is null, length is zero, etc - you might need to try a few different things before you get one that works).
Also, put a breakpoint in there and run the test in debug mode. See what the values are that are coming through and customize your code to match. That should be enough to let you catch the end of file if the built-in mechanisms aren't working.
Thanks for the response. I will give that a try today.
So it was the csv file...I had blank rows at the bottom. Thanks for your help!!!