我有像这样的黄瓜功能:
@MainSuite
Scenario: Verify that user can login
Given I can see the login form
Then I set a username
And I set a password
And I click in Login button
Then I see the "wrong-password" message
我需要检查用户是否可以登录5个不同的页面。 我需要在5个不同的地方运行该功能。 就像,我需要在/login.html,/ old_login.html,/ after_restore_password.html等中运行该功能(仅作为示例)。
你知道怎么做吗?
目前,我只有一个硬编码的文件。显然我需要改变它。
this.Given(/^I can see the login form$/, function(done) {
this.goTo('login.html');
browser.wait(EC.visibilityOf(this.loginFormContainer));
done();
});
答案 0 :(得分:1)
创建一个包含您可以访问的不同登录页面的对象。
如果需要执行任何额外的代码,请在步骤def中包含if语句。
this.Given(/^I can see the "(.*)" login form$/, function(loginPage, done) {
var logins = {
login : "login.html",
afterpasswordreset: "after-password-reset.html"
}
loginPage = loginPage.toLowerCase().replace(" ", "");
this.goTo(logins[loginPage]);
browser.wait(EC.visibilityOf(this.loginFormContainer));
done();
});
为每个登录变体制作单独的场景或功能文件,或者只为它们创建场景大纲
修改强>
以下是我将如何实施场景大纲:
@MainSuite
Scenario Outline: Verify that user can login
Given I can see the "<loginType>" login form
And I set a username
And I set a password
When I click in Login button
Then I see the "wrong-password" message
Examples:
| loginType |
| Login |
| After Password Reset |