无法在 Specflow 文件中将类型 'int' 转换为 'string'

Cannot convert type 'int' to 'string' in a Specflow file

我正在尝试 运行 测试通过 Specflow 创建的用例,但出现错误。代码背后的想法是我有一个功能文件、一个步骤定义文件和一个页面文件。我可以打开浏览器,但是当它应该在登录页面中输入凭据时,它不断收到错误消息:无法将类型 'int' 转换为 'string' 在步骤定义文件中注释的行中。

特征文件:

Feature: Login in the website

  Scenario Outline: Login with the credentials

    Given That I am on the Login page
    When User enters
     | email                        | password     |
     | gt862@student.gqwiypoh.se    | 12345        |
    Then The client will be on the account page

步骤定义文件:

 LoginPage loginpage = null;


        [Given(@"That I am on the Login page")]
        public void GivenThatIAmOnTheLoginPage()
        {
            IWebDriver webDriver = new ChromeDriver();
            webDriver.Navigate().GoToUrl("http://automationpractice.com/index.php?controller=authentication&back=my-account");
            loginpage = new LoginPage(webDriver);   
        }

        [When(@"User enters")]
        public void WhenUserEnters(Table table) //This is the method that I keep having problems
        {
            dynamic data = table.CreateDynamicInstance();

            loginpage.Login((string)data.email, (string)data.password);
        }


        [Then(@"The client will be on the account page")]
        public void ThenTheClientWillBeOnTheAccountPage()
        {
            loginpage.LoginButton();
        }

    }

我在其中获取文本框和按钮名称的登录页面文件:

 public IWebDriver Webdriver { get; }

        public LoginPage(IWebDriver webdriver)
        {
            Webdriver = webdriver;
        }

        //UI Elements
        public IWebElement txtEmail => Webdriver.FindElement(By.Name("email"));

        public IWebElement txtPassword => Webdriver.FindElement(By.Name("passwd"));

        public IWebElement btnLogin => Webdriver.FindElement(By.CssSelector("#SubmitLogin > span"));

        public void Login(string Email, string Password)
        {
            txtEmail.SendKeys(Email);
            txtPassword.SendKeys(Password);

        }

        public void LoginButton() => btnLogin.Submit();
    }

下面也是测试报告的截图。

请问您可能是什么问题,我该如何解决?

提前谢谢大家。

我会说 CreateDynamicInstance12345 识别为 int 而不是字符串。

将绑定更改为以下应该有效:

[When(@"User enters")]
public void WhenUserEnters(Table table) //This is the method that I keep having problems
{
    dynamic data = table.CreateDynamicInstance();

    loginpage.Login(data.email.ToString(), data.password.ToString());
}