Forum Discussion
jsreesoap
12 years agoContributor
This is resolved. Thanks again to Jeshtha.
I want to share the resolution here, just in case any one is trying to get the dynamic value from response from the same node like I mentioned above.
In each iteration it should pick up a new input value and feed it to the URL, get the the node value from response and write to the newly created property. If you need to pick up more values from the nodes then you need to experiment, and pls let me know how it is done.
--
We used data source grid to create iterations and input values.
In test case right click and add data source
In data source window click on + sign and add a property/parameter and name it 'rows' something like that
Follow the same step and create one more parameter and name it appropriately. Mine is 'ActNumber. This parameter will be used in URL as well. So pick a name that is not confusing later
In rows parameter type 1 to 4 for example to create 4 rows
In each row for the second parameter add the values. The value could be hard coded or using get data method retrieve a value from project or test suite level parameter value.
In the URL if you have to pass the account number like in my case. Use 'ActNumber' instead of the actual account number.
For example: https:// accounts/${DataSource#ActNumber}/restrictions
Add groovy script below the test step which retrieves the restrictions
=================
Def rows = context.expand( '${DataSource#rows}' )
def indAcct = context.expand( '${DataSource#ActNumber}' )
testRunner.testCase.setPropertyValue("AccountId" +[rows],ActNumber)
def responseAsXml = context.expand( '${test step name here#ResponseAsXml#//Response[1]/e[1]/ActResId[1]}' )
testRunner.testCase.setPropertyValue("ResID" +[rows],responseAsXml)
===============
Note: It creates dynamic properties, there is no need to add them in advance.
For example ResID1 and then the value for ResID1 is 123
Add data source loop at the end and make sure the target step is set properly covering the needed steps.
Run the test case
Thats it. Hope this is helpful
I want to share the resolution here, just in case any one is trying to get the dynamic value from response from the same node like I mentioned above.
In each iteration it should pick up a new input value and feed it to the URL, get the the node value from response and write to the newly created property. If you need to pick up more values from the nodes then you need to experiment, and pls let me know how it is done.
--
We used data source grid to create iterations and input values.
In test case right click and add data source
In data source window click on + sign and add a property/parameter and name it 'rows' something like that
Follow the same step and create one more parameter and name it appropriately. Mine is 'ActNumber. This parameter will be used in URL as well. So pick a name that is not confusing later
In rows parameter type 1 to 4 for example to create 4 rows
In each row for the second parameter add the values. The value could be hard coded or using get data method retrieve a value from project or test suite level parameter value.
In the URL if you have to pass the account number like in my case. Use 'ActNumber' instead of the actual account number.
For example: https:// accounts/${DataSource#ActNumber}/restrictions
Add groovy script below the test step which retrieves the restrictions
=================
Def rows = context.expand( '${DataSource#rows}' )
def indAcct = context.expand( '${DataSource#ActNumber}' )
testRunner.testCase.setPropertyValue("AccountId" +[rows],ActNumber)
def responseAsXml = context.expand( '${test step name here#ResponseAsXml#//Response[1]/e[1]/ActResId[1]}' )
testRunner.testCase.setPropertyValue("ResID" +[rows],responseAsXml)
===============
Note: It creates dynamic properties, there is no need to add them in advance.
For example ResID1 and then the value for ResID1 is 123
Add data source loop at the end and make sure the target step is set properly covering the needed steps.
Run the test case
Thats it. Hope this is helpful