cancel
Showing results for 
Search instead for 
Did you mean: 

Displaying Log Output as null when trying to set node value using groovy script

Highlighted
New Contributor

Displaying Log Output as null when trying to set node value using groovy script

import com.eviware.soapui.support.XmlHolder
import com.eviware.soapui.impl.wsdl.testcase.WsdlTestRunContext

 

def request1 = testRunner.testCase.testSuite.testCases["GetEmp"].testSteps["GetEmpDtls"].getPropertyValue("Request")

 

def xml1= new XmlHolder(request1)

 

def getnode1=xml1.getNodeValue("saxon:parse(//tem:GetEmp/tem:InputParameters)//USER_ID")
log.info ("GetNodeValue : " +getnode1)

 

def setnode1=xml1.setNodeValue("saxon:parse(//tem:GetEmp/tem:InputParameters)//USER_ID" , "JACK")
log.info ("SetNodeValue : " +setnode1)

 

Log Output:
Mon Mar 09 16:29:48 IST 2020:INFO:GetNodeValue : test
Mon Mar 09 16:29:48 IST 2020:INFO:SetNodeValue : null

 

Expected Logt Output is : SetNodeValue : JACK, BUT Actual Log Output is : SetNodeValue : null
I want to set the node value in above scenario, why null value is displaying?, can you provide solution for above senario.

 

In above script emoji icons are displaying, please find the attached script file.

 

4 REPLIES 4
Highlighted
Community Hero

Re: Displaying Log Output as null when trying to set node value using groovy script

Edit: missed not earlier.
The set method may not be returning any value. Please check javadoc of api


Regards,
Rao.
Highlighted
New Contributor

Re: Displaying Log Output as null when trying to set node value using groovy script

Thank you Rao, can you provide any sample code for this.

 

Regards

Vijay

Highlighted
Community Hero

Re: Displaying Log Output as null when trying to set node value using groovy script

No code in this context is required.
You are trying to log which returns nothing.


Regards,
Rao.
Highlighted
Contributor

Re: Displaying Log Output as null when trying to set node value using groovy script

Hi @VijayKumarS  ,

Your code shold be something  like this

 

def request1 = testRunner.testCase.testSuite.testCases["GetEmp"].testSteps["GetEmpDtls"].getPropertyValue("Request")

 

def xml1= new XmlHolder(request1)

 

def getnode1=xml1.getNodeValue("saxon: parse(//tem:GetEmp/tem:InputParameters)//USER_ID")
log.info ("GetNodeValue : " +getnode1)

-- In this line you are setting the node, it will not return any value

xml1.setNodeValue("saxon: parse(//tem:GetEmp/tem:InputParameters)//USER_ID" , "JACK")

-- Here you to have get the node value after setting it.

def setnode1=xml1.getNodeValue("saxon: parse(//tem:GetEmp/tem:InputParameters)//USER_ID")
log.info ("SetNodeValue : " +setnode1)

 

-Ashwin

Please give a Kudo and accept it as a solution if this works.

New Here?
Join us and watch the welcome video:
Top Kudoed Authors