首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Specflow scenario outline examples表到对象?

Specflow scenario outline examples表到对象?
EN

Stack Overflow用户
提问于 2019-02-05 00:17:00
回答 1查看 377关注 0票数 0

我正在使用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)

尽管我最终会将编码值更改为(.*)等。

如果我只传递一个对象或所有值的列表,而不是字符串的长实例,对我来说会更容易。

EN

回答 1

Stack Overflow用户

发布于 2019-02-15 20:55:02

查看Specflow表

代码语言:javascript
复制
When the user provides input for the Property and Loan Requirements Section
| Key         | Value      |
| propLocation| NYC        |
| locPropToBuy| House123   |
| propertyType| House      |
| newBuild    | Nope       |

以此类推

使用PropertyLoanData创建一个新类,然后解释该表

代码语言:javascript
复制
    public class PropertyLoanData
    {
      public string propLocation { get; set; }
      public string locPropToBuy { get; set; }
      public string propertyType { get; set; }
      public string newBuild     { get; set; }
    }

代码语言:javascript
复制
   [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);
    }
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54520151

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档