Forum Discussion

raja2's avatar
5 years ago

How to find SOAPUI / REST Project Type, EndPoint URL, etc. details using Groovy script ?

How to find SOAPUI application below details using Groovy script ?


  1. Project Type.
  2. The EndPoint URL.
  4. List of Request Methods in the WSDL
  5. Number of TestSuites
  6. TesCaseName and Number of TestCases
  7. TestStep Names and Number of TestSteps
  8. Property Names

  • I also agree, learning to navigate the Java API docs is a little daunting, but it's worth the effort. When I was starting out I made extensive use of the getClass() method to help me use the API docs.


    For example you wanted to get the test case name and number of test steps. Start out by logging the class of the testRunner:


    // Example Groovy run from "Groovy Script" test step 



    This will log the Class of the testRunner - WsdlTestCaseRunner - that you can then look up in the API Docs:



    There under the method summary you'll see a method getTestCase() Which returns the object WsdlTestCase:



    You'll see (inherited from AbstractWsdlModelItem) there is a method getName() Thus to get the test case name:


    // Example Groovy run from "Groovy Script" test step



    Staying with the WsdlTestCase object, you will also see it has the method, getTestStepList() Which returns a standard Groovy List of test steps, thus the following code will get the number of test steps for a given test case:


    // Example Groovy run from "Groovy Script" test step

    To start with, for me, it was a lot of trial and error, but you soon start to learn the structure of the objects and start to be able to anticipate things. You can always log the class of any object to help you out.


    Also the code completion also helps a lot, but remember, the code completion doesn't always show all of the available methods.










10 Replies

  • nmrao's avatar
    Champion Level 3
    Many of the question can be found if you search in the forum in the existing scripts. Do you expect some one to compile them for you?
    You may go thru API java doc.

    What do you mean by Project type?
      • richie's avatar
        Community Hero
        Hi raja2,

        You stated your project is REST or SOAP UI.....but that doesn't make sense. Im not picking holes, but the answer does make a difference in what youre asking for.
        In your original post you mentioned .wsdl....but that is peculiar to SOAP, not REST.
        I think your original post mentioned the endpoint URL, but REST supports URI parameters whereas SOAP does not.

        Im trying to highlight that you need to know exactly what you have and what you need before wasting your time trying to work all this out.