Forum Discussion

2446541820's avatar
2446541820
New Contributor
2 years ago

set request url a params

I senf a request to the server with an IP , But When I send  the request to my computer , I have to change the IP address.

It is too much unconvience , It is a way better way?

4 Replies

  • ChrisAdams's avatar
    ChrisAdams
    Champion Level 2

    The licensed version has this functionality.  It allows you to define several environments, e.g. Dev, Test, Pre-Prod and Production.  The enviornment functionality allows you to define the IP/URL to call for each environment.  Then in ReadyAPI, there is a dropdown that allows you to select the environment to use and it just works.  No editing.

     

    However, in SoapUI this functionality is not there, but it's not the end of the world.  richie has answered the same question and I think his solution is something along the lines of editing the XML SoapUI project file.  Something like replace all occurrences of 128.0.0.1 with 128.0.0.4.

     

     

     

     

  • jkrolczy's avatar
    jkrolczy
    Regular Contributor

    You could add a Groovy script step prior to your Request step to recognize the user or computer, 

    or even obtain the IP of the machine being run on store that to a test case custom variable.

    You can do a a lot in a Groovy script to look for and capture information to store for later use into variables,  

    In your Request step, replace you IP value with the variable from the test case level.

     

     

    • 2446541820's avatar
      2446541820
      New Contributor

      How Can I add a Groovy script step prior? Can I set a gloabal variables that can work everywhere?

  • ChrisAdams's avatar
    ChrisAdams
    Champion Level 2

    Hi,

     

    Re "Can I set a gloabal variables that can work everywhere?".  Yes, kind of.  The "highest" level you can set a global variable (Custom Properties in SoapUI speak) is at the Project.  Create a custom property there.  Something like "urlToTest" that contains the 'root' URL to want to call.  E.g. "localhost:8080" or "https:\\myDevServer".

    The in the test step, you can change the URL to include the customer property.  E.g. ${#Project#urlToTest}\getCustomers.

    When the step runs, SoapUI will substitute ${#Project#urlToTest} with the actual value.