cancel
Showing results for 
Search instead for 
Did you mean: 

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

SOLVED
Contributor

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.
  3. WSDL 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

1 ACCEPTED SOLUTION

Accepted Solutions
Super Contributor

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

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/WsdlTest...

 

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/WsdlTest...

 

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.

 

 

 

 

 

 

 

 

 

View solution in original post

10 REPLIES 10
Community Hero

Re: How to find SOAPUI application Project Type, EndPoint URL, etc. details using Groovy script ?

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?


Regards,
Rao.
Contributor

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

I could not find exactly details from API java document. so I have posted this query. No need to compile all of them. It would be helpful for me if you share exact link. 

 

Project type is REST or SOAP UI type.

 

Link : https://www.soapui.org/apidocs/overview-summary.html

 

Community Hero

Re: How to find SOAPUI application Project Type, EndPoint URL, etc. details using Groovy script ?

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.

Cheers!

rich
if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
Contributor

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

Title is updated. Where can i find above details exactly ? (API docs / Forum ) ?

Community Hero

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

Hi @raja2 

 

if you cant understand API docs (and I can't so I know exactly how you feel) I would google each of the points you are trying to find - you are looking for the groovy for about 6 different things?

 

yeah I would just use google for each option - e.g. 'groovy script to find out project name soapui'

 

That's how I would find out this stuff - this should retrieve stuff from a number of blogs, forums and sites (stackoverflow) -and I'd go from there - some of the topics you should be able to find straight away - others might take a bit of reading/searching - but it looking at your list I'm pretty sure you should be able to find it all without too much hassle!

 

cheers,

 

rich

 

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
Super Contributor

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

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/WsdlTest...

 

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/WsdlTest...

 

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.

 

 

 

 

 

 

 

 

 

View solution in original post

Community Hero

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

Hey @Radford 

 

I've had a quick flick through this (spare 5mins) and that is way more than I ever knew before - so cheers for that - I think that'll give me the start I need to use these docs.

 

Q. in your last line you mention "code completion" - i.e. "code completion also helps a lot..." - what is code completion?  I don't know what that means relative to the context of your post....

 

Thanks man,

 

rich

 

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
Highlighted
Super Contributor

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

Hi @richie,

 

When i say code completion I mean the script editor functionality that displays the appropriate methods and parameters as you type.

 

Just to expand on when I mentioned that it doesn't show all the available methods, if you look at the WsdlTestCase method .getTestStepByName() you will see in the JavaDocs it returns a WsdlTestStep and the code completion will display the methods for this object. But if you added a SOAP test step and ran the code:

 

log.info(testRunner.getTestCase().getTestStepByName("SOAP Request").getClass())

It would return a WsdlTestRequestStep object, which you will see inherits from WsdlTestStep.

 

I started out before code completion was introduced in Ready API version 1.0 and while crude and laborious, using the .getClass() method really helped me out.

 

Last thing I mention is that when I started out learning the fact that the docs are split across the base and pro pages confused me a lot, but after a while you get used to the split and it becomes more intuitive where you need to look.

 

Moderator

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

Thanks everyone for your participation!

 

@raja2 did any of the replies help? If so, please click the Accept as Solution button below the reply that helped you.
Otherwise, could you please update us on your progress?

Thanks in advance,


Olga Terentieva
SmartBear Assistant Community Manager