Overview
The Add Snippet step lets you include pre-built, reusable test sequences into your tests. Snippets are modular test components you create once and reuse everywhere, eliminating duplication and ensuring consistency across your test suite.When to Use Add Snippet
Use Add Snippet when you need to:- Reuse common flows: Include login, setup, or teardown sequences across multiple tests
- Maintain consistency: Ensure the same actions are performed the same way everywhere
- Simplify test maintenance: Update a snippet once and all tests using it get the update
- Build modular tests: Compose complex tests from smaller, tested building blocks
- Share common patterns: Let your team reuse proven test sequences
How It Works
Add Snippet inserts all the steps from a saved snippet directly into your current test at the point where you add the snippet. When the test runs, it executes the snippet’s steps as if you had added them manually. You can pass parameters to snippets to override specific values (like login credentials, timeouts, or form data), making them flexible enough to work in different contexts while maintaining the same core behavior.Snippet Nesting
Snippets can contain other snippets, creating nested structures. This allows you to build complex test flows from smaller, reusable components. How nesting depth is calculated:- Root test case = depth 0
- First snippet added = depth 1
- Snippet within a snippet = depth 2
- And so on, up to depth 5
The system tracks the maximum nesting depth across your entire test case and validates before allowing new snippets to be added, preventing you from accidentally exceeding the limit.
Using the Add Snippet Step
When you add an Add Snippet step, you’ll:Select Your Snippet
Choose from a dropdown of all snippets created in your workspace. Each snippet is identified by its descriptive title. The dropdown shows only valid snippets that contain executable steps.If you just created a snippet, it may take a moment to appear in the dropdown. Try refreshing the test editor if your snippet doesn’t show up immediately.
Pass Parameters (Optional)
Toggle “Pass Params” to override specific values within the snippet. Click “Edit Params” to set the values you want the snippet to use instead of its defaults. The following step types support parameter passing:- Fill: Override text values for form fields
- Select: Override dropdown selection values
- Press Keys: Override key combinations
- Wait for Time: Override timeout durations
Real-World Examples
Reusing a Login Flow
Login with Different Credentials
Setup Data Before Testing
Testing Checkout with Different Items
Multi-Environment Testing
Best Practices
Design Effective Snippets
- Single purpose: Each snippet should do one thing well (login, search, checkout)
- Self-contained: Snippets shouldn’t depend on external state or previous steps
- Clear naming: Use descriptive titles like “Login as Admin” or “Create Test Order”
- Provide defaults: Always set sensible default values for all parameters
When to Create Snippets
Create snippets for:- Actions repeated across 3+ tests
- Complex sequences that are error-prone to recreate
- Team-shared patterns everyone should use the same way
- Setup/teardown that must be consistent
- One-off sequences used in a single test
- Steps that change frequently (until they stabilize)
- Overly complex mega-snippets that do too much
Parameter Strategy
- Identify what varies: Focus parameters on values that change between uses
- Keep defaults sensible: Default values should work for the most common case
- Document parameters: Use clear parameter names that indicate their purpose
- Test both modes: Validate snippets work with and without parameter overrides
Maintain Your Snippets
- Review snippets regularly to ensure selectors are still valid
- Update snippets when UI changes instead of creating new ones
- Deprecate snippets that are no longer needed
- Test snippets independently before using them in tests
Troubleshooting
Snippet Not Available
Symptom: Can’t find a snippet in the dropdown Solution:- Verify the snippet exists in your workspace
- Check that the snippet contains valid steps
- Refresh the test editor to reload available snippets
- Ensure you have access to the snippet (permissions)
Snippet Steps Fail
Symptom: Test fails when executing snippet steps Solution:- Test the snippet independently to isolate the failure
- Check if selectors in the snippet are outdated
- Verify environment variables the snippet uses are defined
- Check if the page state is correct before the snippet runs
Parameters Not Working
Symptom: Parameter values aren’t being used Solution:- Verify “Pass Params” toggle is enabled
- Check that you’ve set parameter values for the steps you want to override
- Ensure parameter types match (text for Fill, options for Select, etc.)
- Test the snippet without parameters first to confirm base functionality
Snippet Changes Don’t Appear
Symptom: Updated snippet still shows old behavior Solution:- Refresh your test editor to reload snippet changes
- Clear cache if changes still don’t appear
- Wait a moment for cache updates to propagate
- Check that you saved the snippet changes
Performance Issues
Symptom: Snippet loading causes delays Solution:- Check network connection
- Break large snippets into smaller, focused components
- Reduce snippet complexity if possible
- Verify snippet size is reasonable
Nesting Depth Exceeded
Symptom: Error message saying maximum nesting depth reached when trying to add a snippet Solution:- Simplify your snippet structure by reducing nesting levels
- Break complex nested snippets into separate, parallel snippets
- Review your snippet hierarchy to find opportunities to flatten
- Consider if some nesting can be moved to the test case level
- The maximum nesting depth is 5 levels; restructure if you’re hitting this limit
Understanding Snippet Execution
How Steps Are Inserted
When you add a snippet, its steps are inserted into your test at that point. During execution:- Steps run in sequence as if you’d added them manually
- Parameter overrides apply to the specified steps
- Environment variables resolve at runtime
- The snippet doesn’t create a separate scope - it’s part of your test
Variable Scope
Variables created in snippets:- Are available to steps after the snippet in your test
- Follow the same naming rules as regular variables
- Can conflict if snippet and test use the same names
- Persist throughout the test execution
Parameter Passing Details
Only these step types support parameters:- Fill (override text values)
- Select (override option selections)
- Press Keys (override key combinations)
- Wait for Time (override timeout durations)
Other step types in snippets use their configured values and can’t be overridden via parameters. Parameter names are case-sensitive, so ensure you use the exact name defined in the snippet’s parameter definitions.
Related Steps
- Navigate - Often included in navigation snippets
- Fill - Commonly used in form snippets with parameter support
- Click - Frequently used in interaction snippets
- Check Text - Often included in validation snippets
- Extract Value - Used for data capture snippets
Related Documentation
- Snippets - Comprehensive guide to creating and using snippets, including nesting strategies and debugging techniques

