1. Property Transfer TestStep
- Purpose: This dedicated step is designed specifically for transferring property values between TestSteps.
- How it Works:
- Source: You define the source TestStep (where the value originates) and the property to extract from its response (e.g., an XPath expression to extract a specific value from the XML response).
- Destination: You specify the destination TestStep(s) and the property names where you want to store the extracted value.
2. Groovy Script TestStep
- Purpose: Provides maximum flexibility for complex data manipulation and property management.
- How it Works:
- Extract Value: Use Groovy script to extract the desired value from the response of a previous TestStep (e.g., using XPath, JSONPath, or other methods).
- Store in Property: Store the extracted value in a property using the
context.setProperty() method.
- Access Property: In subsequent TestSteps, access the stored value using the property expansion syntax (e.g.,
${#TestCase#propertyName}).
Example: Passing a Session ID
-
Request 1 (Login):
- Send a login request.
- Use a Groovy Script TestStep to extract the session ID from the response (e.g., using XPath).
- Store the session ID in a property:
context.setProperty("sessionId", extractedSessionId)
-
Property Transfer (Optional):
- If you prefer a dedicated step, use a Property Transfer TestStep to transfer the
sessionId property from the "Login" Request to other TestSteps.
-
Request 2 (Other Requests):
- Include the session ID in the request headers using the stored property:
Authorization: Bearer ${#TestCase#sessionId}
Key Considerations:
- Property Scopes: Understand the different property scopes (Project, TestCase, TestStep) and choose the appropriate scope for your needs.
- Error Handling: Implement error handling mechanisms to gracefully handle situations where values might not be extracted as expected.
- Data Types: Be mindful of data type conversions when transferring values between TestSteps.
By effectively utilizing these methods, you can dynamically pass values between TestSteps in SOAP UI, creating more flexible and data-driven tests.