How to find SOAPUI application below details using Groovy script ?
Solved! Go to Solution.
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:
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 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.
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
Title is updated. Where can i find above details exactly ? (API docs / Forum ) ?
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
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:
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 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.
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
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.
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,
Subject | Author | Latest Post |
---|---|---|