I have a run test case step in Test1 which calls a Test2. Test2 only has one JDBC step at the moment. I want to return the entire result set from Test2 to Test1, preferably in the form of a single "object". How do I do that? How do I access the rows and columns in that "object" via a groovy script? Something like this:
Test 2 - JDBC step :
return TableLikeObject or Json.
Test1 - Groovy test step :
TableLikeObject table = Test 2 - JDBC returned value.
table.getRow(1).getColumn('Employee name')
Test1 calls Test2.
Solved! Go to Solution.
@rajs2020 : you can do it by following way:
//if in same Test Case
def teststep = testRunner.getTestCaseByName("TestCase2").getTestStepByName('JDBC Step')
//if in different Test Case
def teststep = testRunner.testCase.testSuite.getTestCaseByName("TestCase2").getTestStepByName('JDBC Step')
Click "Accept as Solution" if my answer has helped,
Remember to give "Kudos" 🙂 ↓↓↓↓↓
1. Create a test case level custom property for Test2. Say JDBCRESPONSE.
2. Set the value to above property when jdbc step is run.
3. In Test1, add a "Run Test Case" step, the wizard allows which Return Properties you want from Test 2.
Hi @rajs2020 ,
JDBC return a xml-like response, you can think of it as XML response and use
import com.eviware.soapui.support.XmlHolder
def teststep = testRunner.testCase.testSteps['JDBC Step']
def response = teststep.testRequest.response.contentAsXml
def holder = new XmlHolder(response)
def node = holder.getNodeValues( "//aa/b" )
Thanks,
/Aaron
@aaronpliu - thanks.
def teststep = testRunner.testCase.testSteps['JDBC Step']
Instead of doing that, how do I do this:
def teststep = testRunner.testCase["TestCase2"].testSteps['JDBC Step']
I saw some documentation, but its not quickly clear how I can do something like that.
https://www.soapui.org/docs/scripting-and-properties/tips-tricks/
@rajs2020 : you can do it by following way:
//if in same Test Case
def teststep = testRunner.getTestCaseByName("TestCase2").getTestStepByName('JDBC Step')
//if in different Test Case
def teststep = testRunner.testCase.testSuite.getTestCaseByName("TestCase2").getTestStepByName('JDBC Step')
Click "Accept as Solution" if my answer has helped,
Remember to give "Kudos" 🙂 ↓↓↓↓↓
@HimanshuTayal- Thanks. I tried it, but could not get the Xpath to work.
import com.eviware.soapui.support.XmlHolder;
def teststep = testRunner.testCase.testSuite.getTestCaseByName('GetDBData').getTestStepByName('GetData')
def response = teststep.testRequest.response.contentAsXml
def holder = new XmlHolder(response)
def xPathQuery = "//Results/ResultSet/Row[@rowNumber='2']"
def node = holder.getNodeValues(xPathQuery)
log.info(node.toString())
I have tested my xpath on http://xpather.com/ and it is correct. So, why am I getting an array with only one empty string?
Subject | Author | Latest Post |
---|---|---|