locked
Exception with Data Driven Coded UI Test RRS feed

  • Question

  • Hi,

    I am trying to implement the data driven coded ui test from the below tutorial.

    https://msdn.microsoft.com/en-us/library/ee624082(v=vs.120).aspx

    [DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", "|DataDirectory|\\data.csv", "data#csv", DataAccessMethod.Sequential), DeploymentItem("data.csv"), TestMethod]
            public void CodedUITestMethod1()
            {
                this.UIMap.UICalculatorWindow.UIItemWindow1.SearchProperties[WinButton.PropertyNames.Name] = TestContext.DataRow[0].ToString();
                this.UIMap.UICalculatorWindow.UIItemWindow2.SearchProperties[WinButton.PropertyNames.Name] = TestContext.DataRow[1].ToString();
                // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
                this.UIMap.AddNumbers();
                this.UIMap.ValidateSumExpectedValues.UIItem3TextControlType = TestContext.DataRow[2].ToString();
                this.UIMap.ValidateSum();
            }

    I followed step by step but lost with the below issue.

    "system.argumentexception: column num1 does not belong to table". 

    I am using vs 2013 on win 8.1.

    Please help me in resolving the issue.

    Wednesday, September 2, 2015 2:18 PM

Answers

  • The code you show does not mention "num1". The values within the square brackets of the three "TestContext.DataRow[...]" expressions are significantly different to those in the web page cited. Their values should be identical to the names used in the top line of the CSV file. The names of some of the UI Controls are also different but that is probably not important here.

    However, I suspect that the problem is in the CSV file. Was it saved with the correct encoding as instructed in the cited web page? After "Step 2 - Create a data set" it says "3. It is important to save the .csv file using the correct encoding. On the FILE menu, choose Advanced Save Options and choose Unicode (UTF-8 without signature) – Codepage 65001 as the encoding."

    See also http://stackoverflow.com/questions/24735579/codedui-test-does-not-read-data-from-csv-input-file/24768318#24768318

    Regards

    Adrian


    • Edited by AdrianHHH Wednesday, September 2, 2015 2:55 PM
    • Marked as answer by ykbharat Thursday, September 3, 2015 7:31 AM
    Wednesday, September 2, 2015 2:54 PM