HaroldR
8 years agoContributor
Create Property Transfer and set up Transfer Values in a groovy script
Hello all :), First, do you know if it's possible to create a Property Transfer Step from a groovy script? I cannot find any source code to achieve this purpose. For this example, it does not mat...
- 8 years ago
Here's a groovy script that can be easily modified to fit what you want, I think.
import com.eviware.soapui.impl.wsdl.teststeps.registry.PropertyTransfersStepFactory // Define test case to work with. This assumes the same test case the groovy script is in. def tc = context.testCase; // Define TestStep name for PropertyTransfer test step. def tsName = "TestStep Name" // Create test step in the test case using tsName as the name. tc.addTestStep( PropertyTransfersStepFactory.TRANSFER_TYPE, tsName ) // Retrieve the test step created. def testStep = tc.getTestStepByName(tsName); // Set the transfer name. def transferName = "TransferName"; // Add the transfer using transferName provided. testStep.addTransfer(transferName); // Retrieve the transfer created def transfer = testStep.getTransferByName(transferName); // Set the source test step name. This must be an existing test step in the same test case as the groovy script. transfer.setSourceStepName("LMDataStore - Missing Element - 230"); // Set the Property for the source to Response. transfer.setSourcePropertyName("Response"); // Set the Source Path language as Xpath transfer.setSourcePathLanguage(com.eviware.soapui.impl.wsdl.teststeps.PathLanguage["XPATH"]); // Fill in the XPATH statement. May be able to fill this in with GetData, depending. transfer.setSourcePath("""declare namespace ns2='http://mobilityairrequest.meis.af.mil/2.0.0'; //ns2:addMobilityAirRequestResponse[1]/ns2:MethodResponse[1]/ns2:TransactionResponses[1]/ns2:TransactionResponse[1]/ns2:TransactionIdentifier[1]"""); // Set the Target Test Step Name for the property transfer transfer.setTargetStepName("Properties"); // Set the property name to transfer to. transfer.setTargetPropertyName("TransferProperty");