Kristiyan Damyanov
Kristiyan Damyanov

Reputation: 59

Copy part of XML content in a separate folder using Groovy

I am trying to copy part of an XML that contains a lot of data. I am trying with something like this:

import com.eviware.soapui.support.XmlHolder   
import jxl.*   
import jxl.write.*   

 // read the file from path
def file = new File('Path.xml')
// for example read line by line
def myTestCase = context.testCase 
propTestStep = myTestCase.getTestStepByName("Data")    

def data= file.filterLine { line ->
    line.contains('<V1>Value</V1><V2>Value</V2>')
}

propTestStep.setPropertyValue("Value Present", data)

but I have problem with writing the content on the property value that I gave ... any idea how I can define that save the value?

In general I am trying to give as a regular expression the xml tags as they should be populated in the request and get only this value ... perhaps I need to use totally different method, but please share this with me if I wrong :)

Edit: The error message that I am getting when I run the code is: groovy.lang.MissingMethodException: No signature of method: com.eviware.soapui.impl.wsdl.teststeps.WsdlPropertiesTestStep.setPropertyValue() is applicable for argument types: (java.lang.String, org.codehaus.groovy.runtime.IOGroovyMethods$4) values: [Value Present, ] Possible solutions: setPropertyValue(java.lang.String, java.lang.String), getPropertyValue(java.lang.String), hope that helps.

Upvotes: 0

Views: 72

Answers (1)

daggett
daggett

Reputation: 28634

the method File.filterLine() returns Writable

and the method WsdlPropertiesTestStep.setPropertyValue(name,value) expects string as a value parameter

you just need to convert data to string

propTestStep.setPropertyValue( "Value Present", data.toString() )

Upvotes: 1

Related Questions