Forum Discussion

HaroldR's avatar
7 years ago

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...
  • groovyguy's avatar
    7 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.
    // 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.
    // Set the Source Path language as Xpath
    // Fill in the XPATH statement. May be able to fill this in with GetData, depending.
    transfer.setSourcePath("""declare namespace ns2='';
    // Set the Target Test Step Name for the property transfer
    // Set the property name to transfer to.