Contributions
Http error 403 forbidden via Eclipse
I receive a http/1.1 403 Forbidden error when i request : https://swapi.co/api/people/ via soapui plugin in eclipse. when i do same request with Soapui 5.4.0 i have no problem. it is a free rest api. can you help me please ? i think i have to configure eclipse to have authtorization to request api.806Views0likes1CommentRe: API script assertion not running when running from testcase although run from step is success
Hello. In soapui 5.4.0 version, i don't have "ReadyAPI Log". I put your script with "script log" and it runs well, in all cases. val = true case , val = false or model.size = 0 Tue Dec 11 13:09:06 CET 2018:INFO:Tue Dec 11 13:09:06 CET 2018:INFO:Connection refused: connect So witch version do you use ? take care on upper and lower case in "ReadyAPI Log" value..831Views0likes0CommentsRe: Capture request log via groovy script from a specific test step
hello, first doubt should beon"request log" which soapui version you use ? I use SoapUi 5.4.0 and this tab don't exist. I have Soapui Log, script log.. and perhaps you want to use"http log" I use REST requests, and detail log, in real time displays in "http log". So tell me your error please. If you have a "java.lang.NullPointerException" that is the explanation. second doubt in declaration of groovyUtils. I use GroovyUtils(context) syntax in all my scripts, and it works. I don't understand why you write it in your code but anyway :) at the end, i use ToString() function to log information , and try catch to get error if it occurs; this is more "safe code" to execute entirely without stop. So here is a complete example solution, to replace your code : try { def logArea = com.eviware.soapui.SoapUI.logMonitor.getLogArea( "http log" ); def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context) if( logArea !=null ) { def model = logArea.model // only continue of logArea not empty if( model.size > 0 ) { for( c in 0..(model.size-1) ) { log.info(model.getElementAt(c).toString() + "\r\n") } } } } catch (IOException ee) { ee.printStackTrace() }1.9KViews0likes0CommentsRe: Some of my test cases are failing with 504 and 502 errors when run them as a test suite
you must give us your test and your error.if you don't give precise information, we can't help you. Probably, you make a mistake in your conception. you modify a testsuite property in previous test cases, so your test case becomes false.1.7KViews0likes0CommentsRe: Parametize test data from JDBC into request
hi i got solution for you. example of groovy script which recover and test one database field value : before you have: testcase property with expected values, and a JDBC Step which give you database answer : <Results> <ResultSet fetchSize="0"> <Row rowNumber="1"> <databasename.datafield1>123</databasename.datafield1> ... <databasename.datafieldname>123</databasename.datafieldname> ... </Row> </ResultSet> </Results> import com.eviware.soapui.support.XmlHolder def reponse = context.expand( '${JDBCTestStep#ResponseAsXml#//*:Results/ResultSet/Row}' ) def egal = true if (reponse != "") { // log.info " answer recover : " + reponse // Test field in database def Slurp = new XmlSlurper().parseText(reponse) def FieldDB = Slurp."databasename.datafieldname" // log.info "FieldDB : " +FieldDB def FieldExpected = testRunner.testCase.getPropertyValue("FieldValueExpected") if (FieldDB==FieldExpected) { log.info " the field" +FieldDB+ " is correct in database."} else { egal = false; log.info "the field " +FieldDB+ " is not correct in database."} } else { egal = false; log.info " request sent is empty!"} assert egal2KViews0likes0CommentsRe: Add a check of non existence in a API response
i found solution this noon. i coudld not test key existence correctly. i try with Slurp[i].containsKey("Date de création"] and it dont works also :( So i convert my object into a string and use indexof method, and it is ok now. not perfect but it works. def Str = Slurp[i].toString() def DC = Str.indexOf("Date de création") if (DC == -1) { log.info "ATTENTION..." else { if Slurp[i]."Date de création" < tesdate) { ... }}1.4KViews0likes0CommentsRe: Add a check of non existence in a API response
hi. I try but it don't work. same error "groovy.lang.MissingPropertyException: No such property: Date de création for class: java.lang.String I try this just after : if (Slurp[i].("Date de création")) { if (Slurp[i]."Date de création" < testdate) {checkdate = false } assert checkdate i++} } but i got the same error :( i think i should use "contains" method rightly.1.4KViews0likes1CommentAdd a check of non existence in a API response
i have this kindof API response : {"response": {"responsesRecherche": { "1": { "consultation": { "Id": "16391821108191", "referenceFonctionnelle": "Dume OE US 78 - CTR016", "idTypeProcedure": "01", "idNatureMarket": "01", "idTypeMarket": "01" }, "lot": [{"numeroLot": "016"}], "Opérateur Economique": {"id": "38103128500491"}, "Dume OE": { "dumeOEId": "mybmttmy", "statutDume": "REMPLACE", "nouveauDume": { "dumeOEId": "uxudjs9s", "statutDume": "VALIDE", "accessible": true, "Date de création": "2018-09-11 04:57:22", "Date de modification": "2018-09-11 04:57:22" }, "accessible": true, "Date de création": "2018-09-11 04:57:00", "Date de modification": "2018-09-11 04:57:22" } }, "2": { "consultation": { "Id": "56559466095920", "referenceFonctionnelle": "Dume OE US 78 - CTR016", "idTypeProcedure": "01", "idNatureMarket": "01", "idTypeMarket": "01" }, "lot": [{"numeroLot": "03"}], "Opérateur Economique": 18, "Dume OE": { "dumeOEId": "qo92j8tt", "statutDume": "VALIDE", "accessible": true, "Date de création": "2018-09-11 04:12:02", "Date de modification": "2018-09-11 04:12:02" } }, ... ... "50": { "consultation": { "Id": "31739414944098", "referenceFonctionnelle": "Dume A - CTR021", "idTypeProcedure": "01", "idNatureMarket": "01", "idTypeMarket": "01" }, "lot": [{"numeroLot": "78"}], "Opérateur Economique": 18, "Dume OE": { "dumeOEId": "7bewwsrj", "statutDume": "VALIDE", "accessible": true, "Date de création": "2018-09-13 08:41:44", "Date de modification": "2018-09-13 08:41:44" } }, }}} I have to check creation dates of the Dume OE object. "Date de création" in french. So my following script works perfectly when all Dume OE objects are complete recorded. But we have new problem, API returns incomplete response for some Dume OE : "42": { "consultation": "16391821108191", "lot": [{"numeroLot": "03"}], "Opérateur Economique": 18, "Dume OE": "uxudjs9s" }, there is no information on Dume OE object. I have to add a IF which check "date de création" existence, before check his format and value.. I try "contains" method, but i have groovy error :( My script : import net.sf.* import net.sf.json.* import net.sf.json.groovy.* import com.eviware.soapui.support.XmlHolder def GU = new com.eviware.soapui.support.GroovyUtils( context ) def Response = context.expand ( '${CP_CTR006_DateDebutSansDateFin#Response}').toString() def Slurp = new JsonSlurper().parseText(Response) .response.responsesRecherche .collect {keyname, keyvalue -> keyvalue } // créé la liste de valeurs derrière le compteur .collect { it."Dume OE"} def cpt = Slurp.size() log.info " Dates trouvées = " + cpt def i=0 checkdate = true def testdate = testRunner.testCase.testSuite.getProperty("DateCreation").value testdate = testdate.substring(1,11) testdate = testdate + " 00.00.00" while (i<cpt && checkdate==true) { // TO DO : Add condition IF "Date de création" not exist in Slurp[i] object before check date if (Slurp[i]."Date de création" < testdate) {checkdate = false } assert checkdate i++ } if (checkdate) {log.info "Toutes les dates sont postérieures à " + testdate } It is not hard but i am weak with collection objects :(Solved1.4KViews0likes3CommentsRe: Property Transfer always sending strings to a JSON request
hello i think the problem with type properties is not clearly explained; need precision to answer. what type you have in source ? string ? what type you want in exit ? types are the same ? or need to convert one ?1.1KViews0likes0CommentsRe: record json response into an array
Hello thank you for your answers:smileyhappy: yesterday we didnt work in france. so i look this morning. I tried quick code with $i but it doesnt' work :( After, i try last code with collect function, and it runs very good. i can check all dates before or after a given date, i am very happy to that. thank you so much. jhunt, yes, this json is a little weak format json, but it is maken by a junior, so ok.in fact, your are a genius:smileywink:3.9KViews0likes0Comments