Forum Discussion
- SmartBear_SuppoSmartBear Alumni (Retired)Hello,
The easiest way to manage your endpoint via a Groovy script is probably by creating a TestCase Test Property for it and using a Property Expansion. For example, create a new Test Property in the TestCase named "endpoint" and set the actual endpoint of the request to ${#TestCase#endpoint} (if you will be using the same endpoint for other testcases you may wish to make it a property on TestSuite level or even Project level instead). To change this property in a Groovy TestStep use:
testRunner.testCase.properties['endpoint'].setValue('new endpoint')
Regards,
Dain
eviware.com- PramodYadavContributor
SmartBear_Suppo Wonder why no one gave Kudos to this reply yet. Here it goes :). Kudos !
As an additional note. if you want to use the endpoint url from a parameter defined at say TestSuite level, just change the TestCase to TestSuite in the endpoint url space. Something like this:
${#TestSuite#sGetTxsEndPointUrl}
Where, GetTxsEndPointUrl is a custom property i created at TestSuite level. If all your requests now have this formula at end point Url, there is no need to set, reset urls at test step level. Hope this helps to others.
Cheers, Pramod
- BuschfunkFrequent ContributorI'm using the following code to set the endpoint for a request:
testRunner.testCase.getTestStepByName(requestName).getHttpRequest().setEndpoint(ENDPOINT)
requestName:
The name of the test request which endpoint you'd like to change.
ENDPOINT:
A string representing the new endpoint, e.g. "http://localhost" - vikashNew ContributorThanks. That worked
Related Content
- 5 years ago
- 4 years ago
Recent Discussions
- 15 years ago