cancel
Showing results for 
Search instead for 
Did you mean: 

WinScp and ReadyApI

SOLVED
New Contributor

WinScp and ReadyApI

Hi All

 

Scenario:

I need to fetch content of Winscp log files( from specific location) and compare the data of logs using SOAP UI by hitting another service .

Currently I am doing this manually

Is there any way I can automate this process

Or, any groovy script I can run to automate the whole process

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Hero

Re: WinScp and ReadyApI

Hey @Nikita 

 

I've never used it, but i think you can use the 'File Wait' test step.  The file contents get loaded into a property.  I've had to compare stuff before..... @nmrao developed a groovy script that compared the contents of 2 properties against each other a while back for me.

 

the groovy is as follows:

 

/**
* all work courtesy of Rao
* This groovy script compares the specified property values of two property steps and report the error if any
* For more details: https://community.smartbear.com/t5/SoapUI-Pro/Comparison-of-Two-Property-Values-In-Two-Different-Properties/m-p/175573#M40015
**/
//Define the property names as defined in the property steps
//Say, Name in Property Step 1 : Name in Property Step 2
//This way, it is possible to compare even if property names do not match in two Property Steps
//Add or remove as per your need
def map = ['id1': 'id2', 'name':'name']

//Modify the names of the Property Test step if needed. Here two property steps with given names are defined in the test case.
def p1 = context.testCase.testSteps["Properties1"].properties
def p2 = context.testCase.testSteps["Properties2"].properties

def result = []

def assertPropertyValue = { p1key, p2key ->	
	def temp = p1[p1key].value == p2[p2key].value
	log.info("Comparing $p1key, and $p2key values respectively ${p1[p1key].value} == ${p2[p2key].value} ? $temp")
	temp
}

map.each { result << assertPropertyValue(it.key, it.value) }
assert result.every{it == true}, 'Comparison failed, check log'

You could grab the FileWait content and pass to a Properties step, extract the detail from the Request's response and pass it to another Properties step and then run the groovy to compare the two.  This is how I'd do this - although there's probably other groovy options available.

 

so if you use something like the following test step hierarchy with the above you can probably compare the contents of the log files against any detail transferred to a properties step via your Request step

 

 

FileWaitStep (log contents are saved to step PropertiesStep1)
PropertiesStep1 (holds the content of the FileWaitStep) RequestStep(generates response, grab response detail and pass to PropertiesStep2) PropertiesStep2 (holds the properties from RequestStep) GroovyScriptStep (compares the contents of the PropertiesStep1 to PropertiesStep2)

 

hope this helps,

 

rich

 

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the title of the post to something more descriptive? This will help people when searching for problems.
2 REPLIES 2
Highlighted
Community Hero

Re: WinScp and ReadyApI

Hey @Nikita 

 

I've never used it, but i think you can use the 'File Wait' test step.  The file contents get loaded into a property.  I've had to compare stuff before..... @nmrao developed a groovy script that compared the contents of 2 properties against each other a while back for me.

 

the groovy is as follows:

 

/**
* all work courtesy of Rao
* This groovy script compares the specified property values of two property steps and report the error if any
* For more details: https://community.smartbear.com/t5/SoapUI-Pro/Comparison-of-Two-Property-Values-In-Two-Different-Properties/m-p/175573#M40015
**/
//Define the property names as defined in the property steps
//Say, Name in Property Step 1 : Name in Property Step 2
//This way, it is possible to compare even if property names do not match in two Property Steps
//Add or remove as per your need
def map = ['id1': 'id2', 'name':'name']

//Modify the names of the Property Test step if needed. Here two property steps with given names are defined in the test case.
def p1 = context.testCase.testSteps["Properties1"].properties
def p2 = context.testCase.testSteps["Properties2"].properties

def result = []

def assertPropertyValue = { p1key, p2key ->	
	def temp = p1[p1key].value == p2[p2key].value
	log.info("Comparing $p1key, and $p2key values respectively ${p1[p1key].value} == ${p2[p2key].value} ? $temp")
	temp
}

map.each { result << assertPropertyValue(it.key, it.value) }
assert result.every{it == true}, 'Comparison failed, check log'

You could grab the FileWait content and pass to a Properties step, extract the detail from the Request's response and pass it to another Properties step and then run the groovy to compare the two.  This is how I'd do this - although there's probably other groovy options available.

 

so if you use something like the following test step hierarchy with the above you can probably compare the contents of the log files against any detail transferred to a properties step via your Request step

 

 

FileWaitStep (log contents are saved to step PropertiesStep1)
PropertiesStep1 (holds the content of the FileWaitStep) RequestStep(generates response, grab response detail and pass to PropertiesStep2) PropertiesStep2 (holds the properties from RequestStep) GroovyScriptStep (compares the contents of the PropertiesStep1 to PropertiesStep2)

 

hope this helps,

 

rich

 

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the title of the post to something more descriptive? This will help people when searching for problems.
Moderator

Re: WinScp and ReadyApI

Hi all,

 

Thanks for the reply and for sharing the script Rao created!

 

@Nikita, was your question answered?


Olga Terentieva
SmartBear Assistant Community Manager

New Here?
Join us and watch the welcome video:
Watch the New Interview
APITestingMistake#2
Top Kudoed Authors