Contributions
Remove brackets from property which is fetch from another response.
I have expand the response using below groovy script and set the property as well. def json_s = new JsonSlurper() response = context.expand('${Order_Details#Response}') json_response1 = json_s.parseText(response) //response = response.replace('[]','') testRunner.testCase.setPropertyValue("productSKU", String.valueOf(json_response1.extension_attributes.shipping_assignments.items.product_id)) Property got set as =[[5885]] Response ofOrder_Details is: "extension_attributes": { "shipping_assignments": [ { "shipping": { "address": { "address_type": "shipping", }, "method": "simpleshipping_simpleshipping", "total": { "base_shipping_amount": 0, "base_shipping_discount_amount": 0, } }, "items": [ { "product_id": 3245, "base_amount_refunded": 0, "updated_at": "2021-08-26 13:38:25", "weight": 0.374 }] }] now, I have remove the [[ ]] from property. How can I achieve with groovy.687Views0likes1CommentAssertion failed: value's type is invalid
I am new to groovy and automation. While doing the data driven I am getting the error message while running my groovy script. Below is code I am executing. Also while running the steps I have call the property as"${#propertynamel}" Here is code: import groovy.util.* import groovy.json.JsonSlurper def newres def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context) def projectDir = groovyUtils.projectPath File file = new File (projectDir) def firstLevelDir = file.getParent() def filePath = firstLevelDir + "\\Data_Driven\\Jira.csv" context.fileReader = new BufferedReader(new FileReader(filePath)) rows = context.fileReader.readLines() int n = rows.size() for (int i = 1; i<n; i++){ row = rows[i] //log.info row String[] data = row.split(",") //Setting property from csv file testRunner.testCase.getTestStepByName("Properties1").setPropertyValue("cpid", data [0]) testRunner.testCase.getTestStepByName("Properties1").setPropertyValue("referencenumber", data [1]) testRunner.testCase.getTestStepByName("Properties1").setPropertyValue("waybill", data [2]) testRunner.testCase.getTestStepByName("Properties1").setPropertyValue("accountcode", data [3]) testRunner.runTestStepByName("Clickpost_INTRANSIT") newres = context.expand('${Clickpost_INTRANSIT#Response}') obj = new JsonSlurper().parseText(newres) assert obj.cpid == data[0] //assert parse(cpid)[0] == parse(cpid).first() assert obj.referencenumber == data[1] assert obj.waybill == data[2] assert obj.accountcode == data[3] }Solved811Views0likes1Comment