【发布时间】:2019-04-10 15:21:35
【问题描述】:
我一直在试图弄清楚如何将场景大纲示例解析为(自定义)对象,而无需在步骤名称中显式使用。
Scenario Outline: Customer makes an appointment
Given The user enters details on the page
When The user submits the page
Then The appointment details are shown.
Examples:
| Reason | Firstname | Lastname | Email |
| A | John | Doe | johndoe@mail.com |
| B | Jane | Doe | janedoe@mail.com |
我现在正在尝试找出如何将示例行解析为自定义约会对象
我一直在用表查看 CreateInstance,但这似乎不起作用
[Given(@"The user enters details on the page")]
public void EnterDetails(Table table)
{
var appointment = table.CreateInstance<Appointment>();
driver.FindElement(By.Id("Firstname")).SendKeys(appointment.Firstname);
}
运行时出现错误
Message: TechTalk.SpecFlow.BindingException : Parameter count mismatch! The binding method EnterDetails(Table)' should have 0 parameters
这是约会课
public class Appointment
{
public AppointmentReason Reason { get; set; }
public string Firstnam { get; set; }
public string Lastname { get; set; }
public string Email { get; set; }
}
谁能指出正确的方向如何将示例行解析为约会对象?
【问题讨论】: