Solved

VSTS - Datadriven unit test - No TestContext.DataRow option available

Posted on 2014-04-08
1
1,140 Views
Last Modified: 2014-04-16
Hi Guys,

I have a basic test below which I created as a Visual c# unit test project. The test works fine however when I try to read the data from a csv file I don't get the option to use TestContext.DataRow. This worked fine when I used it in a codedUI project. Do I need to add another reference to my project or is there any other reason why I cannot code it this way

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
using OpenQA.Selenium.IE;
using OpenQA.Selenium.Support;


namespace SeleniumTesting
{
    [TestClass]
    public class UnitTest1
    {
       // [TestMethod]
        [DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", "data.csv", "data#csv", DataAccessMethod.Sequential), DeploymentItem("data.csv"), TestMethod]
        public void TestMethod1()
        {
            IWebDriver driver = new InternetExplorerDriver(@"C:\Software\Selenium\IEDriver");
            driver.Navigate().GoToUrl("http://www.google.com.au");
            driver.Navigate().GoToUrl(TestContext.)
            
        }
    }
}

Open in new window


Thanks

Gavin
0
Comment
Question by:victoriaharry
1 Comment
 
LVL 6

Accepted Solution

by:
Craig Kehler earned 500 total points
ID: 40004526
If the data source is a list of urls, I think you need to add .DataRow to your TestContext.

I use selenium in java, so I don't have a working example to base that on... but that's what it looks like based on http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.testcontext.aspx
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question