Forum Discussion

raja2's avatar
raja2
Contributor
5 years ago
Solved

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

How to find SOAPUI application below details using Groovy script ?   Project Type. The EndPoint URL. WSDL URL List of Request Methods in the WSDL Number of TestSuites TesCaseName ...
  • Radford's avatar
    Radford
    5 years ago

    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
    
    log.info(testRunner.getClass()) 

     

     

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

     

    https://support.smartbear.com/readyapi/apidocs/soapui/com/eviware/soapui/impl/wsdl/testcase/WsdlTestCaseRunner.html

     

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

     

    https://support.smartbear.com/readyapi/apidocs/soapui/com/eviware/soapui/impl/wsdl/testcase/WsdlTestCase.html

     

    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
    
    log.info(testRunner.getTestCase().getName())

     

     

    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
    
    log.info(testRunner.getTestCase().getTestStepList().size())

    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.