我正在使用specflow,并且在我的示例中有一个相当大的表:
它大约有14个字段。
有没有更好的方法将所有这些文件传递到一个item1、item2和item4方法中
我可以看到有一个create set方法,但这似乎不能满足示例的需要,而且只在step....well步骤中。
有没有一种方法可以在对象中传递数据,而不是发送14个字符串?
希望这是有意义的。
答:
史蒂夫
**编辑**添加示例这里是我的示例文件| propLocation | locPropToBuy | propertyType | newBuild | appsLiveProprty | ownershipType | purchPrice | totLoanAmount | intOnlyAmount | prefLoanTermYrs | prefLoanTermMths |的头文件
为此生成的方法将如下所示:
[When(@"the user provides input for the Property and Loan Requirements Section (.*) and (.*) and (.*) and (.*) and (.*) and (.*) and (.*) and (.*) and (.*) and (.*) and (.*) and (.*) and (.*) and (.*) and (.*)")] public void WhenTheUserProvidesInputForThePropertyAndLoanRequirementsSectionEnglandAndYesAndTerracedHouseAndYesAndYesAndStandardAndAndAndAndAndAndAndAndSAnd(string propLocation, string locPropToBuy, string propertyType, string newBuild, string legalOwnership, string ownershipType, string equityShreScheme, string purchPrice, string fullMarketVal, string termShareLoanYrs, string termShareLoanMths, string totLoanAmount, string intOnlyAmount, string prefLoanTermYrs, string prefLoanTermMths)
尽管我最终会将编码值更改为(.*)等。
如果我只传递一个对象或所有值的列表,而不是字符串的长实例,对我来说会更容易。
发布于 2019-02-15 20:55:02
查看Specflow表
When the user provides input for the Property and Loan Requirements Section
| Key | Value |
| propLocation| NYC |
| locPropToBuy| House123 |
| propertyType| House |
| newBuild | Nope |以此类推
使用PropertyLoanData创建一个新类,然后解释该表
public class PropertyLoanData
{
public string propLocation { get; set; }
public string locPropToBuy { get; set; }
public string propertyType { get; set; }
public string newBuild { get; set; }
}。
[When(@"the user provides input for the Property and Loan Requirements Section
public void WhenUserprovidesinputforPropertyAndLoanSection(Table table)
{
var proploandata = table.CreateInstance<PropertyLoanData>();
driver.FindElement(By.Id("propLocation")).SendKeys(proploandata.propLocation);
driver.FindElement(By.Id("locPropToBuy")).SendKeys(proploandata.locPropToBuy);
driver.FindElement(By.Id("propertyType")).SendKeys(proploandata.propertyType);
driver.FindElement(By.Id("newBuild")).SendKeys(proploandata.newBuild);
}https://stackoverflow.com/questions/54520151
复制相似问题