Cucumber jvm 使用不同的登录名运行功能文件
在这里,我们需要使用不同的登录名运行相同的功能文件,并从标记中提供登录用户名 使用user1和user2运行功能文件Cucumber jvm 使用不同的登录名运行功能文件,cucumber-jvm,gherkin,cucumberjs,Cucumber Jvm,Gherkin,Cucumberjs,在这里,我们需要使用不同的登录名运行相同的功能文件,并从标记中提供登录用户名 使用user1和user2运行功能文件 @user1 @user2 Feature: Feature-1 Background : Given I am login with user Scenario: Scenario: 使用user1运行功能文件 @user1 Feature: Feature-2 Background : Given I am login with user Scen
@user1 @user2
Feature: Feature-1
Background :
Given I am login with user
Scenario:
Scenario:
使用user1运行功能文件
@user1
Feature: Feature-2
Background :
Given I am login with user
Scenario:
Scenario:
使用小黄瓜语言的场景大纲概念,您可以在其中传递用户名和密码作为示例。例如:
-- Feature file
Scenario Outline: Verify Login Functionality
Given There is a user "<username>" and <password>"
When I login to the application
Examples:
|username|password|
|user1|pass1|
|user2|pass2|
-- Spec file
Given(/^There is a user (.*) and (.*)$/, async function(username, password) {
driver.findElement(Locator to identify the username element).sendKeys(username);
driver.findElement(Locator to identify the password element).sendKeys(password);
});
--功能文件
场景概要:验证登录功能
假设存在一个用户“”和“
当我登录到应用程序时
示例:
|用户名|密码|
|user1 | pass1|
|user2 | pass2|
--规格文件
给定(/^有一个用户(.*)和(.*)$/,异步函数(用户名、密码){
findelelement(用于标识用户名元素的定位器)。sendKeys(用户名);
driver.findelelement(用于标识密码元素的定位器)。sendKeys(密码);
});
在这里,上面编写的相同测试场景将针对两个不同的用户重复。
将这两个正则表达式作为spec文件中的参数,并使用selenium将其发送到用户名和密码文本字段一旦我登录,我将执行一些操作,然后注销,然后我希望与另一个用户重新登录,以执行相同的操作。场景大纲将以这种方式工作,相同的测试场景将使用num重复例如,首先它将使用user1登录,执行一些操作并注销。成功注销后,cucumber将不会移动到另一个场景。它将使用user2重复相同的场景,并将执行与使用user1相同的操作。