在浏览其他在线资源后,我了解到我们无法拥有多个测试数据的背景资料。我有一些场景,用于添加具有不同权限的用户,并且他们首先有登录的常用步骤,这将是我需要为每个场景执行的背景。 我的方案示例
Background: Admin or Super Admin Login
Given Open browser and navigate "xyz" server
When Give user credentials "<username>" and "<password>"
|username|password|
|Admin | 123|
|SuperAdmin| 123|
Then User selects a client
And Click on Go To Dashboard
Then User should be able to log in
@UserPage
Scenario: Admin or super admin user add a new user with admin rights
When Admin user adds a new user
And User fills in all the required information
|username|Client|Password|Retype Password | Email| Admin |
Test data
And Add new user personal information
|FirstName|LastName|Phone|
Test data
Then User with admin rights is created.
我的要求是管理员和超级管理员用户(两者都有不同的权限)可以创建具有或不具有管理员权限的新用户。 所以,我的问题是如何用不同的登录用户测试这个场景,因此后台和场景应该为Admin用户执行一次,对于super admin执行一次。
在推荐的方式上编写和执行这个小黄瓜脚本的任何线索? 谢谢。
答案 0 :(得分:0)
正如Grasshopper所说,你可以压缩下面给出的背景步骤。它可以解决您的问题。
Background: Admin or Super Admin Login
Given Open browser and navigate "xyz" server
@UserPage
Scenario Outline: "<username>" user add a new user with admin rights
When Give user credentials "<username>" and "<password>"
Then User selects a client
And Click on Go To Dashboard
Then User should be able to log in
When Admin user adds a new user
And User fills in all the required information
|username|Client|Password|Retype Password | Email| Admin |
Test data
And Add new user personal information
|FirstName|LastName|Phone|
Test data
Then User with admin rights is created.
Examples:
|username |password|
|Admin | 123 |
|SuperAdmin | 123 |