Start from Logged-in State

Starting from a Logged-in State
- Check “Start from logged-in state”
- Select a login test from the dropdown
- Your test will begin with the authentication state from the selected test
- Tests that require an authenticated user
- Avoiding redundant login steps
- Maintaining consistent test states
Save Login State

Saving Login State Configuration
- Your test performs a login that other tests might need
- You want to make the authentication state reusable
- You’re creating a dedicated login test
Login states are saved at the end of test execution and can be used by other tests that select this test as their login state source.
Best Practices
-
Create Dedicated Login Tests
- Make separate tests for different user roles
- Keep login tests focused and minimal
- Use clear naming conventions (e.g., “Admin Login”, “Customer Login”)
-
State Management
- Save login states from tests that perform authentication
- Reuse login states to reduce test execution time
- Consider test dependencies when managing states
-
Security Considerations
- Use environment variables for credentials
- Regularly update saved login states
- Clear authentication data in teardown tests when needed
Common Scenarios
Multiple User Roles
When testing features that require different user roles:E-commerce Flow
For an e-commerce website:Troubleshooting
Common authentication issues and solutions:-
Login State Not Available
- Ensure the login test has “Save login state” enabled
- Check if the login test completed successfully
- Verify the correct login test is selected
-
Session Expiration
- Consider adding refresh token handling
- Implement automatic re-login when needed
- Use shorter test sequences
-
State Conflicts
- Clear cookies/storage in teardown tests
- Use separate login states for different flows
- Implement proper test isolation
For more complex authentication scenarios or custom implementations, refer to our JavaScript Actions guide.
