SFTP PUT to remote directory in ReadyAPI
I am trying to figure it out how to do SFTP PUT using Groovy scripts in ReadyAPI but to no avail haven't work for me yet. Have search thru community and found some examples but doesn't work. I am not expert in Groovy scripting nor any programming language. But just wanted to ask here if we have a sample SFTP PUT Groovy script where I can try, notice also that the remote doesn't accept password, it might be encrypted.12Views0likes1CommentUnable to parse multiple json received in kafka Eventhub
Hi All, I have a Eventhub to receive messages as and when they are published.I may receive multiple json messages.So i parse each of them using the Property-list-data field and try to assert certain fields in all the received jsons. But i am getting a error when i try to access a particular field in the received json. I am trying something like this. import groovy.json.* import groovy.util.* import groovy.json.JsonSlurper //Parse JSON content in the request def data = context.expand( '${Receive Message#data#$[*]}' ) def json=new JsonSlurper().parseText(data) assert json.eventID=='1234546' || '1234545'-----This works fine def i=1 while(i!=0) { def data2 = context.expand( '${Receive Message#data}' ) def json2=new JsonSlurper().parseText( data2) log.info json2[i] if (json6[i].eventID=='1234546')--------------This gives Error -Error is mentioned at the bottom of this post. { i=0; log.info "Test Success" }else{ i=i+1 } } Error : groovy.lang.MissingPropertyException: No such property: eventID for class: java.lang.String error at line: 20 Json that is received is as .I receive multiple such json in the same format. { "eventID" : "1234546", "eventTimeStamp" : "2017-07-21T17:32:28Z", "eventType" : "EVENT_PUB", "Identifier1" : "", "Identifier2" : "", "shipinfo" : { "InfoNumber" : "123456", "originLoc" : "IND", "destLoc" : "IND", }, } Please help .What am i missing here.27Views1like1CommentGroovy To Extract Comma Separated List Into Separate Properties
Hi, So this is on the end of one of my previous posts - nmrao spoonfed me until I got there (so all cred to him) - this is the next step. I have a string of comma separated values stored as a custom testSuite level property. I want to extract the individual values from the single property into multiple separate properties for later use. I've managed to do it - but it's shockingly bad groovy - so I'm wondering if anyone can guide me into a way of doing it more efficiently The testSuite level 'MY_SUBLIST' property has the value of: 3K684,3K686,3K688,3U3750 As stated above, I want to separate out each comma separated value into it's own testSuite level property. As stated above - I've managed it - but it's poor groovy. Please see as follows: //get the comma separated list in my testSuite level property entitled MY_SUBLIST and save it to the mySubListToString variable def mySubListToString = context.testCase.testSuite.getPropertyValue('MY_SUBLIST') log.info mySubListToString // log response was --> Thu May 23 00:20:30 BST 2024: INFO: 3K684,3K686,3K688,3U3750 //use split() to extract the first route_code value and save this value to the splitString1 property def splitString1 = mySubListToString.split(',')[0].toString() log.info(splitString1) //log response was --> Thu May 23 00:20:30 BST 2024: INFO: 3K684 //save splitString1 value to a new testSuite level property entitled splitString1 testRunner.testCase.testSuite.setPropertyValue( "splitString1", splitString1) //use split() to extract the second route_code value and save this value to the splitString2 property def splitString2 = mySubListToString.split(',')[1].toString() log.info(splitString2) //log response was --> Thu May 23 00:20:30 BST 2024: INFO: 3K686 //save splitString2 value to a new testSuite level property entitled splitString2 testRunner.testCase.testSuite.setPropertyValue( "splitString2", splitString2) //use split() to extract the third route_code value and save this value to the splitString3 property def splitString3 = mySubListToString.split(',')[2].toString() log.info(splitString3) //log response was --> Thu May 23 00:20:30 BST 2024: INFO: 3K688 //save splitString3 value to a new testSuite level property entitled splitString3 testRunner.testCase.testSuite.setPropertyValue( "splitString3", splitString3) //use split() to extract the fourth route_code value and save this value to the splitString4 property def splitString4 = mySubListToString.split(',')[3].toString() log.info(splitString4) //log response was --> Thu May 23 00:20:30 BST 2024: INFO: 3U3750 //save splitString4 value to a new testSuite level property entitled splitString4 testRunner.testCase.testSuite.setPropertyValue( "splitString4", splitString4) As you can see - I'm not going to win any awards with the code above. Can anyone advise on a more efficient/effective way of doing it? It's rubbish to have to explicitly define a variable and a new property for each comma separated value - so I'd welcome if anyone has a more efficient way I can do this. As you can see - what I've done gets the job done - but it's a shonky way of doing it! Cheers! rich119Views0likes2CommentsGroovyScript - Extract specific number of attribute values from variable content response
Hey! I've checked my groovy script notes which contains essentially all the groovy script snippets people have ever helped me with over the years - mostly from nmrao if I'm being honest - but I haven't got an example of what I need - sometimes I can expand the examples I already have to do what I need, but not this time. I have a GET response JSON payload that can have 1 or many records in the response. Each record in the response will have an 'id' attribute value (JSONPATH --> x.data[0].id) The 'data' array can have 1 or many records, so JSONPATH for the id attribute value for first record this would be x.data[0].id, but there could be 50 records or more (50 records, the JSONPATH of the id associated with the 50th record would be x.data[49].id) I won't need to save all 50, or 100, or however many records there will be. I'd like to be able to specify the number of id values I save for later. I want to save these 'id' values at TestSuite level for later. I'm not sure how many 'id' values I'll need - maybe only 5 or maybe 10 - I don't know yet, so I'd like to be able to specify how many 'id' values I extract and save on the TestSuite. This is the groovy script so far - as I say above - it's all courtesy of nmrao //Script Assertion def json = new groovy.json.JsonSlurper().parseText(context.response) //find all 'id' attribute values def id_list = json.data.'id'.findAll() //List the 'id' attribute item count log.info id_list.size //Iterate thru each id, then stick them in a map, then once they're in a map, grab X instances of the 'id' values and split the map out and save them at TestSuite level id_list.each { id -> And that's as far as I've got. I'm guessing I need to count the number of records so I don't try and grab more 'id' attribute values than actually exist causing the script to fail. I think I need a map and I've been googling - but it's beyond me - all the groovy script with maps I've got examples of, mix multiple methods together and I've never been able to read exactly what's occurring in those lines of the groovy. I know the groovy to save off a single property to TestSuite level for later use - but I don't know how to save off a variable sized number of attributes into separate properties for later use - especially as I'd like to grab a certain number of 'id' values from the total available - maybe from the first 10 records out of X returned. I've attached the response payload that includes just a single record Can anyone give me a steer please? As always - I genuinely appreciate all/any help anyone can give me! Cheers, RichSolved168Views0likes10CommentsHow to run specific test case in particular environment?
I have 2 environments setup : Dev & QA. There are certain test cases which are intended for Dev env only. How I avoid running those when I select QA environment? or when I select Dev env, only dev environment specific test cases run?608Views0likes5CommentsJDBC Request/Query for value located within data BLOB
I am attempting to execute the following query within a ReadyAPI JDBC request SELECT * FROM consumer WHERE consumer.payload LIKE '%name%' The issue is that ReadyAPI treats the '%' as part of the literal string which from what I understand is a sort of wildcard and used to match the given name exactly so instead of just using name it uses %name% and then returns null Within Oracle SQL Developer the query executes just fine and returns the expected corresponding row(s) but when attempting to execute it within ReadyAPI JDBC request i get null. How exactly do I go about writing the query in ReadyAPI to treat the '%' as a sort of wildcard and not actually part of the string/value?32Views0likes1CommentAssertion error log
Hi All, I need suggestion please on how to approach the following: I created a script to compare 2 very large tables before and after deployment. in the beginning I was looping thru each row and column to compare values and I was able to see the exact field that has a mismatch in the assertion log but the issue is the script was taking way too long. So I decided to to compare the whole resultSet received from both tables but and now I am facing a different issue, when there is a mismatch the assertion error log doesn't show where the exact discrepancy is but rather it shows the error mismatch between the full resultSet. is there a way to capture few lines in the error log around the mismatched string in the resultSet from the assertion instead of the whole thing ERROR: Assertion failed: assert beforeTable == afterTable | | | | | '<ResultSet ..... </ResultSet>' | false '<ResultSet ..... </ResultSet>'20Views0likes1CommentMulti Thread Groovy test step
Hello, I would really appreciate help with this. I create a test that compares data between 2 tables with large data return. the script does the job perfectly but it takes very long time to execute as it loops thru hundreds of thousands of records and verify value to value from each column. I was wondering if there is a way to run the test step groovy script in multi thread instead of doing one value at a time. thanks in advance!112Views0likes1Commentreadyapi 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,Solved74Views0likes4Comments