C# #SpecFlow#For CreateDynamicInstance()-错误-Microsoft.CSharp.RuntimeBinder.RuntimeBinderException:最佳重载方法
我将Specflow 3与Selenium一起用于页面对象模型模式。代码如下: 功能文件C# #SpecFlow#For CreateDynamicInstance()-错误-Microsoft.CSharp.RuntimeBinder.RuntimeBinderException:最佳重载方法,c#,specflow,C#,Specflow,我将Specflow 3与Selenium一起用于页面对象模型模式。代码如下: 功能文件 When I want to edit the profile | Hats | Shoes | | 98 | 99 | 页面类- public IWebElement TxtHat => _driver.FindElement(By.Id("Hat")); public IWebElement TxtShoe => _driver.FindElement(By.
When I want to edit the profile
| Hats | Shoes |
| 98 | 99 |
页面类-
public IWebElement TxtHat => _driver.FindElement(By.Id("Hat"));
public IWebElement TxtShoe => _driver.FindElement(By.Id("Shoe"));
public void FillDetails (string hat, string shoe)
{
TxtHat.SendKeys(hat);
TxtShoe.SendKeys(shoe);
}
步骤定义-
[When(@"I want to edit the profile")]
public void WhenIWantToEditTheProfile(Table table)
{
profile.ClearDetails();
dynamic var = table.CreateDynamicInstance();
profile.FillDetails(var.Hats, var.Shoes);
}
错误
消息:Microsoft.CSharp.RuntimeBinder.RuntimeBinderException:与“Refresh.Pages.UpdateProfilePage.FillDetails(string,string)”匹配的最佳重载方法具有一些无效参数
提前感谢您的帮助 您需要使用“垂直”表格:
When I want to edit the profile
| Field | Value |
| Hats | 98 |
| Shoes | 99 |
数据表的“水平”布局(列标题应为属性名称)仅在创建对象集或集合时才起作用。由于需要单个对象,因此需要一个包含两列的表。列#1是动态
对象中的键或属性名称,第二列是属性值
有关将数据表转换为对象的详细信息:
请注意,文档中谈到了将数据表转换为具体类,但同样的基本原理也适用于将数据表转换为
动态对象。感谢Greg的建议,将功能文件更改为垂直表。但仍然没有运气,相同的重载错误消息。我正在使用table.CreateDynamicInstance()来避免对象。还有其他建议吗?@ginads:请编辑您的问题,并包括异常消息和堆栈跟踪。