Solved

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

Posted on 2014-04-08
1
1,117 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
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 fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
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 …

867 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now