Use User Credentials in Generate Scenario
You can load user credentials defined in your project’s test data into your Gherkin scenario. You can also retrieve Time-based One-Time Passwords (TOTP) for users during two-factor authentication (2FA) testing.
Use different user credentials to test login for multiple user roles (e.g., Admin, Editor, Viewer).
This allows you to dynamically load and parameterize user credentials to verify role-based access control without hardcoding credentials.
Before you begin
Ensure that you have added at least one user credential to your project so they can be used in the Recorder.
Loading User Credentials in Gherkin Scenario
To load user credentials in your Gherkin scenario:
Add the
When load test data for user "<user>"
step in your scenario. Ensure this step is added before any steps where user credentials will be used.Add the following example parameters for your scenario:
User Password totp (optional) username defined in test data {{password}}
{{totp}}
Example:
gherkinScenario Outline: create new opportunity When load test data for user "<user>" When login with "<user>" and password "<password>", and totp "<totp>" When create new opportunity with name "<name>" Then verify "<name>" can be found in the page Examples: | user | password | totp | name | | user@force.com | {{password}} | {{totp}} | Conference |
Next click AI Generate Scenario to generate test automation code for the scenario steps.
NOTE
Refer to AI Generate Scenario for more information.
During test runs, the test data will automatically vary based on the user credentials, enabling dynamic and varied test execution.
``