这是我的剧本..
// 3.Enter value into fields
//Firstname
UITestControl objfirstname = new UITestControl(browser);
objfirstname.TechnologyName = "Web";
objfirstname.SearchProperties.Add("Name", "firstname");
objfirstname.SetProperty("Text", "Shobhit");
//Lastname
UITestControl objlastname = new UITestControl(browser);
objlastname.TechnologyName = "Web";
objlastname.SearchProperties.Add("Name", "lastname");
objlastname.SetProperty("Text", "Talwar");
//Email
UITestControl objemail = new UITestControl(browser);
objemail.TechnologyName = "Web";
objemail.SearchProperties.Add("Name", "email");
objemail.SetProperty("Text", "emailaddress");
因为我正在硬编码这些值。我想知道是否有任何方法可以从.xls或其他东西数据驱动这些值。
答案 0 :(得分:0)
您可以从包括csv,xml等在内的几个数据源中获取此类值。
来自MSDN的示例
[DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", "|DataDirectory|\\data.csv", "data#csv", DataAccessMethod.Sequential), DeploymentItem("data.csv"), TestMethod]
public void CodedUITestMethod1()
{
// 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.ValidateSum();
}
更多关于Creating a Data-Driven Coded UI Test
另见Building Data-Driven Coded UI Tests (CUIT) Using A CSV File