readyapi groovy script library
I am using readyapi 3.51.0 and using readyapi groovy script for customization. Where can I get info about the readyapi groovy script libraries, for example; project.getContext().report.getTestSuiteResultList() any help with where the documentation is located? Thank you,Solved43Views0likes4Commentsmultiple groovy files
in my readyapi, I am using FrameworkUtils.groovy which located in C:\Program Files\SmartBear\ReadyAPI-3.2.0\bin\scripts\test and I don't want to add all my code inside of FrameworkUtils.groovy so I created different groovy classes in the same directory. But the problem is that even though I use import statement it is not importing file. Here is my class how I import it, in here FrameworkUtils, Common and DBUtils are in the same directory C:\Program Files\SmartBear\ReadyAPI-3.2.0\bin\scripts\tes: import com.eviware.soapui.model.support.MessageExchangeUtil import groovy.json.JsonSlurper import Common import DBUtils public class FrameworkUtils implements Common{ } Thanks in advance for your help,24Views0likes2Commentsusing groovy script in readyapi
I have maven project for my readyapi, have java and groovy script in it, and placed jar into C:\Program Files\SmartBear\ReadyAPI-3.51.0\lib my groovy script directory is in src/main/groovy directory. So I am able to use java classes but when I try to use groovy script in readyapi step it doesn't work, not able to find groovy class. I can add my groovy script to C:\Program Files\SmartBear\ReadyAPI-3.51.0\bin\scripts and that works as expected, but how can I use groovy script in my maven project from jar file I added it to C:\Program Files\SmartBear\ReadyAPI-3.51.0\lib ? Here is the groovy script I use in my readyapi to call groovy script in maven project: import src.main.groovy.Utilities def utilities = new Utilities(context, context.testCase.testSuite, log) utilities.loadConfigurations() Thanks in advance,68Views0likes6Commentsreadyapi can't find custom groovy script
I added my custom groovy script Utilities.groovy file to C:\Program Files\SmartBear\ReadyAPI-3.49.0\bin\scripts but when I add following to groovy script step it is giving error; import Utilities error: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script8.groovy: 1: unable to resolve class Utilities @ line 1, column 1. import Utilities ^ org.codehaus.groovy.syntax.SyntaxException: unable to resolve class Utilities @ line 1, column 1. at org.codehaus.groovy.ast.ClassCodeVisitorSupport.addError(ClassCodeVisitorSupport.java:262) at org.codehaus.groovy.control.ResolveVisitor.visitClass(ResolveVisitor.java:1434) at org.codehaus.groovy.control.ResolveVisitor.startResolving(ResolveVisitor.java:262) at org.codehaus.groovy.control.CompilationUnit.lambda$new$16(CompilationUnit.java:739) at org.codehaus.groovy.control.CompilationUnit$ISourceUnitOperation.doPhaseOperation(CompilationUnit.java:902) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:628) at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:389) at groovy.lang.GroovyClassLoader.lambda$parseClass$3(GroovyClassLoader.java:332) at org.codehaus.groovy.runtime.memoize.StampedCommonCache.compute(StampedCommonCache.java:163) at org.codehaus.groovy.runtime.memoize.StampedCommonCache.getAndPut(StampedCommonCache.java:154) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:330) at groovy.lang.GroovyShell.parseClass(GroovyShell.java:526) at groovy.lang.GroovyShell.parse(GroovyShell.java:538) at groovy.lang.GroovyShell.parse(GroovyShell.java:570) at groovy.lang.GroovyShell.parse(GroovyShell.java:565) at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.recompileWithNewName(SoapUIGroovyScriptEngine.java:167) at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.compile(SoapUIGroovyScriptEngine.java:155) at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:98) at com.eviware.soapui.support.scripting.groovy.SoapUIProGroovyScriptEngineFactory$SoapUIProGroovyScriptEngine.run(SoapUIProGroovyScriptEngineFactory.java:98) at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:159) at com.eviware.soapui.impl.wsdl.panels.teststeps.GroovyScriptStepDesktopPanel$RunAction$1.run(GroovyScriptStepDesktopPanel.java:344) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base/java.lang.Thread.run(Thread.java:833) 1 error See Error Log for details. the followings groovy jars I have in C:\Program Files\SmartBear\ReadyAPI-3.49.0\lib not sure what is missing? thanks in advanceSolved21Views0likes3CommentsString.replaceAll not working in Groovy script
I am using a file as a template in order to create new files. The template file contains "placeholders" in the form of[plc]placeholderName[plc]. I want to replace the placeholder at runtime with values as shown in the groovy script. However the String.replaceAll() method seems not to work (placeholders don't get replaced) Am I missing something? The contents of the Template.xml are: My groovy script is: ThanksSolved158Views1like16CommentsHow to change Test Case Status using Groovy
Hi! There is some integration and timing uncertainty within the product under test that has required me to utilize some Groovy code to retry a test step (a REST GET call) x number of times, with y amount of time between each try. As soon as RAPI encounters a test step failure, it sets the entire test case to FAIL. But in my case, subsequent runs of the above noted test step may pass. This leaves a test case with all passing test cases, but a failed test. I want to be able to set the test case to PASS if this scenario occurs. I've tried multiple things and done a bunch of web searches, but am stuck. Any help would be MUCH appreciated! Here the code I'm using in my teardown step: def testCase = testRunner.testCase def testSteps = testCase.getTestStepList() def testStatus = "PASS" for( runner in testSteps ) { if ( runner instanceof com.eviware.soapui.impl.wsdl.teststeps.RestTestRequestStep ) { if ( runner.getAssertionStatus().toString() == "FAIL" ) { testStatus = "FAIL" break } } } if ( testStatus == "PASS" ) { <<set test CASE status to PASS>> } NOTES: 1) is there a good resource that would help me better understand all the RAPI functions available using Groovy in RAPI? My scripting language of choice (and experience) is python. I'm just now learning the Groovy/Java world. 2) Things I've tried that haven't worked (thrown a java error): a) import com.eviware.soapui.model.testsuite.TestRunner.Status testCase.setStatus(Status.FINISHED) b) testRunner.testCase.setStatus(com.eviware.soapui.model.testsuite.TestRunContext.ResultStatus.PASSED) c) testCase.setPropertyValue("Status", "PASSED") d) import com.eviware.soapui.model.testsuite.TestRunContext.ResultStatus testCase.setStatus(ResultStatus.PASSED)Solved153Views0likes28CommentsPassing comma separated values for a property in Data driven test case
Hi, I am creating a grid data driven test case using Ready API. For one of the properties, I have to pass multiple comma separated values for a particular property in my REST request. I am not getting how to split the property value in request editor into multiple strings as otherwise the value is being passed to request as single value. Please guide if there is any direct support for processing such data or I need to use groovy script? The grid data looks like: The request snippet is as below:Solved250Views0likes10CommentsHow to check for the existence of a value in Groovy script
I have an existing Groovy script (for an assertion) that I need to change to check whether a variable exists, but not caring about the actual value. The script is using results from the test step. def expectedMsgs = [""" {"msgType":"Message","message":{"variable1":"<value>","variable2":[{"variable2a":"<value>","variable2b":"<value>","variable2c":"<value>","variable2d":"<value>"}]}} def msg = context.receivedMessage def isMatch = expectedMsgs.stream().any { em -> org.skyscreamer.jsonassert.JSONCompare.compareJSON(em, msg, org.skyscreamer.jsonassert.JSONCompareMode.LENIENT).passed()} log.info ("Websocket message #${context.messagetCount} ${isMatch ? "matched" : "did not match"} the list of expected string") assert(isMatch) Some of these values I do want to check an exact response is received and that's easy enough. But some of them, I just want to make sure the variable itself is present and value isn't null. Can't sort out how to handle that part. Thanks! Jonathan329Views0likes5CommentsGroovy - Save off hashmapped split() values to a Property
Hey, I'm back working with ReadyAPI! and I've forgotten loads in the last 2 years....I'm going through my groovy notes and I'm struggling. I have a full URL with 2 query parms - token and value and I'm using the split method to write out the values to the logging window. - the script is below: //code originally provided by nmrao as an answer to another question I posted def str = 'https://whatevs.azurewebsites.net/path?token=eyJ0eXAiOiJKV1Qi&value=123456789' def map = new URL(str).query?.split('&').collectEntries{ [(it.split('=').first()): it.split('=').last()]} log.info map.token log.info map.value log.info map so the logging window writes Sat Dec 16 21:46:36 GMT 2023: INFO: eyJ0eXAiOiJKV1Qi Sat Dec 16 21:46:36 GMT 2023: INFO: 123456789 Sat Dec 16 21:46:36 GMT 2023: INFO: {token=eyJ0eXAiOiJKV1Qi, value=123456789} However - I want to use the query parm values - I don't want to just log them 'token' and 'value' aren't actually properties/variables - so I can't write the associated property values out to a Properties step - cos those token and value values are just part of the value that makes up the whole string of '{token=eyJ0eXAiOiJKV1Qi, value=123456789}' I was thinking about passing the whole 'map' variable to the Properties step and try using some substring method like split() or something else - but I have a couple of problems: firstly - the map variable is a hashmap right? It's not like a normal property that I can pass to a properties step and then use groovyscript to manipulate - when I tried the following def str = 'https://whatevs.azurewebsites.net/path?token=eyJ0eXAiOiJKV1Qi&value=123456789' def map = new URL(str).query?.split('&').collectEntries{ [(it.split('=').first()): it.split('=').last()]} log.info map.token log.info map.value log.info map def propertiesStep = context.testCase.testSteps["Properties"] propertiesStep.setPropertyValue("map", map) I got an error warning of a problem - also - I noticed that in the logging - log.info map returns a whole string within curly braces - unlike when property values are normally written to the logging. Ok - that's it - could anyone advise how I can extract the two query parm values please? If your answers could add a bit of explaining (or just good commenting maybe?) so I can then read up - I'm reading up on hashmaps and the split() method at the moment - cos I don't really understand what the 'def map' line in the script is actually doing - I can see the result - I just don't understand how it;s getting there. Anyway -that's it - as always - I appreciate all and any help that anyone is kind enough to provide! Cheers, richSolved57Views1like6Comments