Forum Discussion

imran9561186681's avatar
imran9561186681
New Contributor
4 years ago

Assertion 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]
}