英文:
Angular bracket arguments don't get replaced in Cucumber Feature file after completion of execution in cucumber js
问题
我正在使用Cucumber JS与Node.js和WebdriverIO。
我在步骤定义文件中编写了钩子,如下所示:
Given(/^I login with username (.*) and password (.*)$/, function(username,password) {
pageModule.open();
pageModule.Login("abc","abc");
return Promise.resolve();
});
我已经使用以下方式的特性文件:
Scenario: Create New
Given I login with username "<username>" and password "<password>"
执行后,生成的报告显示特性文件中的<username>
和<password>
未替换为实际值。
英文:
I'm using cucumber js with node js and webdriverio.
I have written hooks in step definition file like..
Given(/^I login with username (.*) and password (.*)$/, function(username,password) {
pageModule.open();
pageModule.Login("abc","abc");
return Promise.resolve();
});
I have used Feature file as follows
Scenario: Create New
Given I login with username "<username>" and password "<password>"
After execution , reports are generated like.. <username> and <password> in feature file is not replaced with actual values
答案1
得分: 1
如果您需要使用多个用户名和密码:
-
我们需要将其声明为“Scenario Outline”而不仅仅是“Scenario”。
-
我们需要按以下格式创建一个“Scenario Outline”:
Scenario Outline: 创建新用户
Given 我使用用户名和密码 登录
Examples:
|username|password|
|firstUserName|firstPassword|
|secondUserName|secondPassword|
通过这种方式,我们的场景将使用示例表中显示的多个示例重复执行,以证明我们正在验证的内容。
英文:
If you need to take multiple user names and passwords:
-
We need to declare it as Scenario Outline instead only Scenario
-
We need to create a Scenario Outline in below format:
Scenario Outline: Create New
Given I login with username <username> and password <password>
Examples:
|username|password|
|firstUserName|firstPassword|
|secondUserName|secondPassword|
By this way, our scenario will be repeated with multiple examples what we are proving in Examples table shown like above.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论