Forum Discussion
Hi,
If you just have one TestCase and want to use 'result' to set the endpoint for all TestSteps in that TestCase, then you could:
1) Add a Groovy TestStep before all the Request TestSteps. In the Groovy TestStep:
//Set and store your result property / variable in the context object (available to all TestSteps in that TestCase)
context["result"] = UISupport.prompt("Please select the enviornment", "Environment", ['SIT', 'UAT'])
2) In your Test Request TestStep:
//Use a property expansion to set the endpoint to use the result property from the context object. The following syntax can be used to reference the result property from the context, replace the hardcoded edpoint URL text with this:
${result}
To set the endpoint at TestSuite level e.g. so that all TestCases can see the result property. You need to set the result property against either the TestSuite or higher object e.g. Project or Global level. To do this for a TestSuite property
In the Groovy TestStep, to set the TestSuite property with your captured endpoint, try something like:
def endpoint = UISupport.prompt("Please select the enviornment", "Environment", ['SIT', 'UAT'])
testRunner.testCase.testSuite.setPropertyValue( "result", endpoint )
And replace endpoint URLs in Request TestSteps with
${#TestSuite#result}
For more examples on setting properties etc see http://www.soapui.org/scripting---properties/tips---tricks.html
See also
http://www.soapui.org/scripting---properties/working-with-properties.html
http://www.soapui.org/scripting---properties/property-expansion.html
Hope this helps,
Cheers,
Rup
- garlapati9910 years agoOccasional Contributor
Hi,
Thanks for the reply, but what i am trying to do is, on the Test Case level
I have set two properties
SIT - https://10.91.35.41:37093/Services
UAT - https://10.91.37.160:37093/Services
Now on the Setup Script i am trying this
UISupport.prompt("Please select the enviornment", "Environment", ['SIT', 'UAT'])
Now when i select the SIT in the drop down it has to take the SIT properties and run all the test steps.
Thanks,
Kalyan
- rupert_anderson10 years agoValued Contributor
Hi Kalyan,
Ok, no problem.
So if I am understanding you right:
- you have a TestCase with two properties (SIT=... & UAT=...)
- The TestCase contains multiple Test Request TestSteps
- Depending on the prompt you want to set the endpoint URL of the Request TestSteps to the URL contained in either SIT pr UAT.
So, in a Groovy TestStep how about:
import com.eviware.soapui.support.UISupport
//Conditionally set endpointURL based on result
def result = UISupport.prompt("Please select the enviornment", "Environment", ['SIT', 'UAT'])
if (result=='SIT') context["endpointURL"]=testRunner.testCase.getPropertyValue("SIT")
else context["endpointURL"]=testRunner.testCase.getPropertyValue("UAT")//Just to check, print it out
log.info context["endpointURL"]
Then in the Request TestSteps, use a property expansion to insert the value of context["endpointURL"] into the endpoint URL box e.g. ${endpointURL}
Is this what you wanted?
Cheers,
Rup
- garlapati9910 years agoOccasional Contributor
Thanks for the help, it works now.
Related Content
- 6 years ago
- 2 years ago
- 2 years ago
- 2 years ago
Recent Discussions
- 2 days ago
- 2 days ago
- 2 days ago
- 2 days ago