Changing the Endpoints Dynamically using Groovy
Hi Team,
I need to change the endpoint hostname dynamically when I am passing the environment.
For Example:
val1111313:8090/postpage
I have to change the host, When I am passing the INT or Staging. it has to change to va154871:8091
Regards,
Karthik
Please note: It's been a while since I have done this (I switched to using environments a while ago), and I haven't had time to test, but try something like this:
log.info(testRunner.getTestCase().getTestStepByName("TestStep Name").getHttpRequest().getEndpoint()) testRunner.getTestCase().getTestStepByName("TestStep Name").getHttpRequest().setEndpoint("New Endpoint")
The getHttpRequest() returns a WsdlTestRequest object, this gets the endpoint methods from the inherited class AbstractHttpRequest.
I would recommend looking again at the Environment functionality, it applies at all levels, suite, case, etc, you don't have to run at project level to use it. Personally it made my life a lot easier.
Edit: The above script is run from a Groovy test step within a test case, you may need to adjust to get the test step if running from a different location.