Your Groovy scripts have access to the XML content of the request and can modify it. You can change the request text before, during the test run, and right before the request is sent.
There are several ways to use these scripts:
As a Groovy Script test step.
As a setup or teardown script on the test case level in functional tests.
As an event in the project.
The following examples modify XML content of a test step with the Add Pet name. We assume the test step has this content:
This example modifies the name and status of a pet.
If you use this script as the Setup Script of a test case, it modifies the XML before each run of the test case:
![]() |
You can already remove empty XML nodes by using the Remove Empty Content property. However, it only removes empty end nodes, and can leave empty parent nodes. To remove those, use the following script: