Write Scripts
DocStar allows you to enhance API testing and automation by writing scripts that execute at different stages of an API request. With Pre-Scripts and Post-Scripts, you can dynamically modify requests, validate responses, and automate workflows. Additionally, the Snippets section provides ready-to-use script templates to simplify script writing.
1. Writing pre-scripts
Pre-scripts run before the API request is sent, allowing you to:
✔ Set authentication tokens dynamically.
✔ Generate timestamps or unique identifiers.
✔ Modify request parameters or headers.
✔ Load environment variables for use in the request.
2. Writing Post-Scripts
Post-scripts run after receiving the API response, helping you:
✔ Validate status codes and response formats.
✔ Extract values from the response body for further use.
✔ Compare response time for performance monitoring.
✔ Log errors or unexpected behaviors for debugging.
Using Snippets for Quick Scripting
DocStar provides a Snippets panel with pre-written script templates to simplify automation. You can:
1.Set or retrieve environment variables (e.g., API keys, tokens).
2. Modify request headers dynamically.
3. Check conditions within the response body.
4. Clear stored variables for fresh requests.
Benefits of Writing Scripts in TechDoc
Automate API workflows
Improve testing accuracy
Enhance debugging.
With DocStar’s scripting capabilities, you can make API testing more efficient, automated, and insightful—all within a single platform. 🚀