cancel
Showing results for 
Search instead for 
Did you mean: 

Property Transfer: if node doesn't exist choose value N/A to write in file

SOLVED
HimanshuTayal
Community Hero

Re: Property Transfer: if node doesn't exist choose value N/A to write in file

Hi @AboveAndBeyond ,

 

Because the syntax your have used in else statement(line number 23) is still incorrect, correct it by using:

 

testRunner.testCase.testSteps['Name of your Test Step'].setPropertyValue("propName",propValue);

Hope it will help.

 


Click "Accept as Solution" if my answer has helped,
Remember to give "Kudos" 🙂 ↓↓↓↓↓



Thanks and Regards,
Himanshu Tayal
AboveAndBeyond
Frequent Contributor

Re: Property Transfer: if node doesn't exist choose value N/A to write in file

Hello @HimanshuTayal 

 

Thank you for your answer and yes this time I don't get an error message, but.... it doesn't work....?

The whole code is written as an answer in the property from the property transfer and in the textfile.????

 

Kind Regards,

AboveAndBeyond

HimanshuTayal
Community Hero

Re: Property Transfer: if node doesn't exist choose value N/A to write in file

Hi @AboveAndBeyond ,

 

You need to do some below minoe changes, hope it will work fine afterwards :

 

1. In your Property Transfer Test Step select result instead of scrpit

2. In your groovy Script Step under else condition, write targetProperty = before testRunner.testCase......

 

 


Click "Accept as Solution" if my answer has helped,
Remember to give "Kudos" 🙂 ↓↓↓↓↓



Thanks and Regards,
Himanshu Tayal
AboveAndBeyond
Frequent Contributor

Re: Property Transfer: if node doesn't exist choose value N/A to write in file

Hi @HimanshuTayal 

 

Thanks for your time and effort but it didn't work for me. I've looked at it with a senior developper and we've found out that for my case it's actually as you had stated in the beginning. The code inside the brackets are actually far more easy than everything that has been written on the internet!  😉  

Also, your last comments were also correct. I needed to change the property for the source in result.  🙂

My code looks like this:

import com.eviware.soapui.impl.wsdl.teststeps.registry.PropertyTransfersStepFactory
import groovy.json.JsonSlurper
import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep


//response for BU
def responseBU = context.expand( 'GET THE DATA WITH THE PICK AND CHOOSE ACTION IN READYAPI' )
def result = "N/A"
//response for ENT
def responseENT = context.expand( 'GET THE DATA WITH THE PICK AND CHOOSE ACTION IN READYAPI' )

if (responseBU == null || responseBU.toString().isAllWhitespace())
{
	result = responseENT.toString()
}
return result

the steps are like this:

soap request (xml answer)

groovy script

property transfer: source for TypeEnterprise = Groovy script,    Property=result

datasink: declared 3 properties where off 1 is called Type, separator = #, Encoding = UTF-8

datasource loop

 

I just want to add that the existing intellisense is not working correctly. When I autocomplete (ctrl + spacebar) to see what I can choose in the menu, "isAllWhitespace" is not present. Strange thing ....

 

Also, we've added the isAllWhitespace as the first time we saw that  responseBU gave an empty response on a response that was equal to Enterprise. So you really need to say to Groovy that the string may not be empty otherwise it's writing the empty string too.

 

View solution in original post

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