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 matter because it can be done manually.
Then, in the same script I would like to create a transfer variable, and set up the source and the target. I would write some code in groovy to avoid to create all the variables manually. Doing this would permit me to automate transfer values creation. Any ideas of how to do this ?
Regards,
Harold
Solved! Go to Solution.
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");
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");
Nice msiadak!!!!
Nmrao, my purpose is to compare two responses from the same request sent to two differents endpoints.
I would like to build a script with a for loop to retrieve all node from both responses. I think of doing a list of key value where the key is the node and the value is the contain of the node.
Then I think the best is to make another for loop to compare all nodes from both responses and point out the differences in a report file.
I started to work on this but I'm still wondering what should be the best method to find a solution to this topic?
And thanks for the links, I read a part of both articles somedays ago, I think its are very useful, and I have to take time to read all things.
Hello @msiadak,
I took the time to read your post again to suite my need, thanks for sharing it first!
At this point :
// 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");
TransactionIdentifier[1]
Hi,
I've tried to run this for my case but I receive this error message:
groovy.lang.MissingMethodException: No signature of method: com.eviware.soapui.impl.wsdl.teststeps.DebuggableWsdlGroovyScriptTestStep.addTransfer() is applicable for argument types: (java.lang.String) values: [TransferName] error at line: 19
Being
// Add the transfer using transferName provided.
testStep.addTransfer(transferName);
My testcase consideres this:
DataSource: read file
Property Transfer: transfer to request ==> this is a bug that needs to be fixed, that's why people from SmartBear suggested a groovyscript instead
SOAP request: execute
Property Transfer to a DataSink
DataSink stash
DataSource Loop
I'm using ReadyAPI 2.5.0. Can someone tell me why this is happening?
the only things I have changed were:
the testcase name
the source test step name
the XPATH statement as the namespace of my client is different.
Should there be anything else I'm demanded to change please?
Thanks in advance.
This issue is resolved. Apparently I needed (in version 2.5.0 of ReadyAPI) to set back all authorizations for each testcase on 'Outgoing'. This means that 2.5.0 looses the signature on saving and closing. Not a drama for now as I've upgraded to 2.6.0.
Subject | Author | Latest Post |
---|---|---|