Contributions
How to generate a random Number, String, AlphaNumeric string
Question How to generate a random Number, String, AlphaNumeric string Answer This below function will generate random Number, String, alphaNumeric string as what you pass in parameters. Refer below code and help yourself in generating random numbers. def num = generateRndString(10, "numeric"); log.info num def str = generateRndString(10, "string"); log.info str def alphaNum = generateRndString(10, "alphanumeric"); log.info alphaNum testRunner.testCase.getTestStepByName("Properties").setPropertyValue("RndNum", num) testRunner.testCase.getTestStepByName("Properties").setPropertyValue("RndString", str) testRunner.testCase.getTestStepByName("Properties").setPropertyValue("RndAlpha", alphaNum) def generateRndString(int num, String type){ def randValue = ""; if( type.equalsIgnoreCase("numeric") ){ def alphaNumeric = ('0'..'9').join() randValue = RandomStringUtils.random(num, alphaNumeric) while (randValue.size()!=num) { randValue = RandomStringUtils.random(num, alphaNumeric) } } else if( type.equalsIgnoreCase("string") ){ def alphaNumeric = (('a'..'z')+('A'..'Z')).join() randValue = RandomStringUtils.random(num, alphaNumeric) while (randValue.size()!=num) { randValue = RandomStringUtils.random(num, alphaNumeric) } } else if( type.equalsIgnoreCase("alphanumeric") ){ def alphaNumeric = (('0'..'9')+('a'..'z')+('A'..'Z')).join() randValue = RandomStringUtils.random(num, alphaNumeric) while (randValue.size()!=num) { randValue = RandomStringUtils.random(num, alphaNumeric) } } return randValue }528Views0likes0CommentsHow to generate a random Number, String, AlphaNumeric string
This below function will generate random Number, String, alphaNumeric string as what you pass in parameters. Refer below code and help yourself in generating random numbers def num = generateRndString(10, "numeric"); log.info num def str = generateRndString(10, "string"); log.info str def alphaNum = generateRndString(10, "alphanumeric"); log.info alphaNum testRunner.testCase.getTestStepByName("Properties").setPropertyValue("RndNum", num) testRunner.testCase.getTestStepByName("Properties").setPropertyValue("RndString", str) testRunner.testCase.getTestStepByName("Properties").setPropertyValue("RndAlpha", alphaNum) def generateRndString(int num, String type){ def randValue = ""; if( type.equalsIgnoreCase("numeric") ){ def alphaNumeric = ('0'..'9').join() randValue = RandomStringUtils.random(num, alphaNumeric) while (randValue.size()!=num) { randValue = RandomStringUtils.random(num, alphaNumeric) } } else if( type.equalsIgnoreCase("string") ){ def alphaNumeric = (('a'..'z')+('A'..'Z')).join() randValue = RandomStringUtils.random(num, alphaNumeric) while (randValue.size()!=num) { randValue = RandomStringUtils.random(num, alphaNumeric) } } else if( type.equalsIgnoreCase("alphanumeric") ){ def alphaNumeric = (('0'..'9')+('a'..'z')+('A'..'Z')).join() randValue = RandomStringUtils.random(num, alphaNumeric) while (randValue.size()!=num) { randValue = RandomStringUtils.random(num, alphaNumeric) } } return randValue }2.7KViews1like2CommentsScript challenge for Groovy DataSource - API Summer 2018
HiOlga_T I have developed a code for Groovy DataSource, hope this will meets the need of Question. import jxl.* def groovyUtils1 = new com.eviware.soapui.support.GroovyUtils(context) def projectPath = groovyUtils1.projectPath projectPath = projectPath.replace("\\","/") def dataFile = projectPath + "/DataFile.xls" def f = new File(dataFile) def wk = Workbook.getWorkbook(f) def s1 = wk.getSheet(0) def rows = s1.getRows() def cols = s1.getColumns() def flag = 0 for(def i=1;i<rows;i++) { for(def j=0;j<cols;j++) { //For placing null for(def k = 0; k < 5; k++) { //Get Header Row Column Cell def c1 = s1.getCell(k, 0) //Get Value Row Column Cell def c2 = s1.getCell(k, i) testRunner.testCase.getTestStepByName("Properties").setPropertyValue(c1.getContents().toString(), "null") } //for placing value in front on particular iteration if(flag == j) { def c3 = s1.getCell(j, 0) def c4 = s1.getCell(j, 1) testRunner.testCase.getTestStepByName("Properties").setPropertyValue(c3.getContents().toString(),c4.getContents().toString()) } flag = flag + 1 } testRunner.testCase.getTestStepByName("Properties").setPropertyValue("Counter",i.toString()) } Do Like and Accept if you find it as Solution. Thanks, Himanshu Tayal1.7KViews1like2CommentsRe: How to pass authtoken dynamically from Post request's response to other post requests in ReadyAPITes
ramaG: Property transfer should work to transfer the auth code, could you please send any error screenshot 1 more thing you can do is write custom groovy code and add it either in new groovy Test Step or add it in script assertion. Let me know if you need help in writing that stuff 🙂3 years agoPlace ReadyAPI QuestionsReadyAPI Questions1.7KViews0likes2CommentsRe: ReadyAPI saving/closing/starting the program takes very, very long time
4nes-team: What helped me related to project is: 1. Usage of Document : Suppose we have functionality with doc upload, generally we are attaching the doc with API. I would suggest not to do that, instead pass the file path. 2. Divide the project : After doing 1st point still Project size is that big, i would suggest you to split the project into parts like create different project according to similar functionality.3 years agoPlace ReadyAPI QuestionsReadyAPI Questions1.5KViews1like0CommentsRe: Groovy script to run a Teststep doesn't fail when the test Step fails
nemowbray: In order to achieve this you need to assert it in the groovy script which is calling that common Test Step: def result = testRunner.testCase.testSteps["TEST_STEP_NAME"].run(testRunner, context).getStatus().toString() if ( result == "OK") testRunner.pass("Test Script passed.") else testRunner.fail("Test Script failed.")3 years agoPlace ReadyAPI QuestionsReadyAPI Questions2.4KViews2likes4Comments