Comparing two values from two different responses with conditional goto
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Comparing two values from two different responses with conditional goto
Hello folks,
i have the following setup :
Step 1 : Request A
Step 2 : Request B
Step 3 : CompareValues ( Conditional Goto )
Step 4 : ValueMatch
Step 5 : ValueDontMatch
I now want the conditional goto in step 3 to compare 2 values. One value comes from the response from step 1 and one value comes from the response from step 2. The problem now is that i can only select values from the previous response via xpath.
Is it possible to compare these two values in a conditional goto step, so i can trigger step 4 or step 5 depending on which value is matched or is it only possible by using groovy script ?
Regards
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So I am quite new to SoapUI, but you could do it like this.
I created the following test steps, step 4 and 5 are disabled so that they are only triggered by step 3:
Step 1 - Request
Step 2 - Request
Step 3 - Script
Step 4 - Script
Step 5 - Script
Both steps, 1 and 2, are soap request for the following wsdl: http://www.thomas-bayer.com/axis2/services/BLZService?wsdl
Step 1 - Request -> Request:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:blz="http://thomas-bayer.com/blz/"> <soap:Header/> <soap:Body> <blz:getBank> <blz:blz>64090100</blz:blz> </blz:getBank> </soap:Body> </soap:Envelope>
Step 1 - Request -> Response:
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"> <soapenv:Body> <ns1:getBankResponse xmlns:ns1="http://thomas-bayer.com/blz/"> <ns1:details> <ns1:bezeichnung>Volksbank Reutlingen</ns1:bezeichnung> <ns1:bic>VBRTDE6RXXX</ns1:bic> <ns1:ort>Reutlingen</ns1:ort> <ns1:plz>72774</ns1:plz> </ns1:details> </ns1:getBankResponse> </soapenv:Body> </soapenv:Envelope>
Step 2 - Request -> Request:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:blz="http://thomas-bayer.com/blz/"> <soap:Header/> <soap:Body> <blz:getBank> <blz:blz>85550000</blz:blz> </blz:getBank> </soap:Body> </soap:Envelope>
Step 2 - Request -> Response:
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"> <soapenv:Body> <ns1:getBankResponse xmlns:ns1="http://thomas-bayer.com/blz/"> <ns1:details> <ns1:bezeichnung>Kreissparkasse Bautzen</ns1:bezeichnung> <ns1:bic>SOLADES1BAT</ns1:bic> <ns1:ort>Bautzen, Sachs</ns1:ort> <ns1:plz>02605</ns1:plz> </ns1:details> </ns1:getBankResponse> </soapenv:Body> </soapenv:Envelope>
Step 3 - Script, is a groovy script with the following code
def response1 = context.testCase.getTestStepByName("Step 1 - Request").testRequest.response.responseContent def response2 = context.testCase.getTestStepByName("Step 2 - Request").testRequest.response.responseContent def rootNode1 = new XmlSlurper().parseText(response1) def rootNode2 = new XmlSlurper().parseText(response2) def bezeichnung1 = rootNode1.'**'.find() {node -> node.name() == 'bezeichnung'} def bezeichnung2 = rootNode2.'**'.find() {node -> node.name() == 'bezeichnung'} if(bezeichnung1.equals(bezeichnung2)) { log.info "'${bezeichnung1}' does match '${bezeichnung2}' executing step 4" context.testCase.getTestStepByName("Step 4 - Script").run(null, context) } else { log.info "'${bezeichnung1}' does not match '${bezeichnung2}' executing step 5" context.testCase.getTestStepByName("Step 5 - Script").run(null, context) }
Step 4 - Script has this code:
log.info "step 4"
Step 5 - SCript has this code:
log.info "step 5"
Run the test suite and you will get the this output:
Wed Oct 24 18:09:31 CEST 2018:INFO:'Volksbank Reutlingen' does not match 'Kreissparkasse Bautzen' executing step 5 Wed Oct 24 18:09:31 CEST 2018:INFO:step 5
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @Alex99
You explain in a very good and easy way..keep it up.
Click "Accept as Solution" if my answer has helped,
Remember to give "Kudos" 🙂 ↓↓↓↓↓
Thanks and Regards,
Himanshu Tayal
