在specflow中使用examples关键字参数化创建问题。 以下是我在场中插入密码的方案和代码:
Scenario Outline: Register Successfully
Given I am shown the Registration view
When I enter ComapnyName in the <CompanyName> field
And I enter UserName in the <UserName> field
And I enter Email in the <Email> field
And I enter Password in the <Password> field
And I enter ConfirmPassword in the <ConfirmPassword> field
And I choose to register my account
Then my user account is created
And I am navigated to my company dashboard
Examples:
| CompanyName | UserName | Email | Password | ConfirmPassword |
| XYZ | Salman Haider | salman.haider@gmail.com | FooBar@123 | FooBar@123 |
public void Password(string password, int n)
{
//Getting and Setting up the values in the Password Field
var passwords = Helper.Driver.FindElements(By.XPath(".//*[@name='password']")).ToList();
passwords[n].SendKeys(password);
Thread.Sleep(2000);
}
当它在字段中输入密码并点击提交按钮显示验证错误,密码长度应为8个字符时,除密码外所需的一个大写和一个特殊字符都是正确的。但是,相同的代码适用于使用表进行参数化。
Scenario: Register Successfully
Given I am shown the Registration view
When I enter credientials
| CompanyName | UserName | Email | Password | ConfirmPassword |
| Seven | Mobeen | usama.rafiq@gmail.com | FooBar@123 | FooBar@123 |
And I choose to register my account
Then my user account is created
And I am navigated to my company dashboard
。但我需要以前的方法才能工作,因为我要输入多个测试数据。