Contributions
- 5 years agoPlace ReadyAPI QuestionsReadyAPI Questions2.5KViews0likes2Comments
Re: How to have a failed step within a loop to be logged in transaction log
Thanks. But I did not get where exactly do I need to use it. I tried something like below and it gave an error. Also when it get the results , what does it basically get? The assertion status ? def loop = 1 log.info loop while (loop < 4 ){ //must match if loop log.info "Still Running " + loop //You have to explicitly list all steps to run between the loop script and the test step loop start testRunner.runTestStepByName("getUniqueExternalReferenceValues 2") sleep 700 testRunner.runTestStepByName("getTransitionPackages") sleep 700 testRunner.runTestStepByName("TransitionProps") sleep 700 testRunner.runTestStepByName("UpdateService_TransitionServiceItem") sleep 700 testRunner.runTestStepByName("getSoaTransactionsByExternalAccountReference 3") sleep 700 testRunner.runTestStepByName("checkTransitionStatus") sleep 700 testRunner.runTestStepByName("TransitionVariables") sleep 700 public TestStepResult runTestStepByName("checkTransitionStatus") loop = loop + 1 }5 years agoPlace ReadyAPI QuestionsReadyAPI Questions2.5KViews0likes3CommentsHow to have a failed step within a loop to be logged in transaction log
I have a groovy step in a testcase with code as below. This testcase has multiple requests which run based on a loop count. The issue I face : My teststep "checkTransitionStatus" which is REST operation has a script assertion. I notice that if an assertion fails during one of the loop runs, it doesnot get logged under 'Transaction log' tab. So basically after the 4 runs , if my second run has an assertion failure , I still get a pass for that step in transaction log . Also when I manually observe I see that different values are passed to the step as per my expectation on each loop run , but the transaction log doesnot show these loop runs separately. It just shows one run as pass but in actual, it runs the step multiple times based on the count. So how can I have the individual runs of the loop logged in transaction log so that I can see the status of the assertion for each run def loop = 1 while (loop < 4 ) { testRunner.runTestStepByName("getUniqueExternalReferenceValues 2") sleep 700 testRunner.runTestStepByName("getTransitionPackages") sleep 700 testRunner.runTestStepByName("TransitionProps") sleep 700 testRunner.runTestStepByName("UpdateService_TransitionServiceItem") sleep 700 testRunner.runTestStepByName("getSoaTransactionsByExternalAccountReference 3") sleep 700 testRunner.runTestStepByName("checkTransitionStatus") sleep 700 testRunner.runTestStepByName("TransitionVariables") sleep 700 loop = loop + 1 }Solved5 years agoPlace ReadyAPI QuestionsReadyAPI Questions2.5KViews0likes5CommentsEnumerations
I am trying to validate enumerations but getting an error(null value) though I have created a map 'kind'. How to resolve //reading the values from a response which has the output like 1,2,3 def Brep=slurpB.Message.ReturnRows.e.DocPrintBypassPrintSwitch.text() //created a map for enumeartions def kind=[ '1' : 'FormatReports', '2':'AllReports', '3': 'Error'] //logging the enumerated value Brept=kind.Brep log.info Brept Output :Null Expected : enumerated values What should be done to get the enumerated valueSolved6 years agoPlace ReadyAPI QuestionsReadyAPI Questions1.5KViews0likes2Comments- 6 years agoPlace ReadyAPI QuestionsReadyAPI Questions1.6KViews0likes1Comment
How to remove trailing zeroes
I have to match two responses. One gives response say A like 113.00 and the other say B as 113 . I want to remove the trailing zeroes from A. How do I do it I am reading the field value of A as below def gainLoss =slurpRest.getRealizedByAccountResponse.securityList.e[b].GainLossList.RealizedGainLoss.text() I tried using the below but get an error def gainlossbig = new BigDecimal(gainLoss).setScale(0) but get theerror as 'Error in assertion script :null' Please tell how do I remove the trailing zeroes in this case?6 years agoPlace ReadyAPI QuestionsReadyAPI Questions1.7KViews0likes5Comments- 6 years agoPlace ReadyAPI QuestionsReadyAPI Questions1.2KViews0likes1Comment
How to Store Json node values in an array
Say the two response names are REST response and BLS response. I want to store their node values in an array and compare them. How do I do it The main structure of REST response is something like this Security 1 Taxlist 1 Term =Short // I want to store this as RESTmatrix[0] Taxlist 2 Term =Long // I want to store this as RESTmatrix[1] Security 2 Taxlist 1 Term= Short // I want to store this as RESTmatrix[2] Taxlist 1 Term= Short // I want to store this as RESTmatrix[3] Taxlist 1 Term= Short // I want to store this as RESTmatrix[4] Security ... The structure of BLS response is like belw Security 1 TaxList 1 Term // I want to store this as Bls[0] Security 1 Taxlist 2 Term // I want to store this as Bls[1] Security 2 Taxlist 1 Term // I want to store this as Bls[2] And then compare RESTmatrix[0] to Bls[0] RESTmatrix[1] to Bls[1] and so on So I want to read the term of all taxlists and store them in an array say RESTmatrix The same thing I would like to do for BLS response and store it an array of list (say BLS matrix) And then I want to compare and see if they match The code I written so far can read the different term values for each security but I want to store them in a sequential array //Reading RESTresponse def RESTresponse = context.expand( '${REST_001#ResponseAsXml#declare namespace ns1=\'https://dev-svcgateway.betasys.com/v1/TaxLotGainLoss/GetRealizedByAccount\'; //ns1:Response[1]}' ) def slurpRest = new XmlSlurper().parseText(RESTresponse) //Reading the number of securities in REST response def seccount =slurpRest.getRealizedByAccountResponse.securityList.e.size() log.info ("Number of securities="+seccount) //Reading the term for each security taxlist for (b=0;b<seccount;b++) { def secname =slurpRest.getRealizedByAccountResponse.securityList.e[b].securityNumber log.info secname def taxlotcount =slurpRest.getRealizedByAccountResponse.securityList.e[b].taxLotList.e.size() log.info("Taxlotcount="+ taxlotcount) for (c=0;c<taxlotcount;c++) { def trys=slurpRest.getRealizedByAccountResponse.securityList.e[b].taxLotList.e[c].gainLossForTaxLot.term.text().toUpperCase() log.info ("term value" +trys) // This I want to store in an array with an index } }6 years agoPlace ReadyAPI QuestionsReadyAPI Questions1.2KViews0likes3Commentshow to store repeated elements in an array
I have 2 responses , one SOAP and one REST. I need to compare the two values and check if they match . I created an an array to store the SOAP taxlots but when I try to log it, it gives an error so SOAP response is something like this . Security 1 Taxlot Taxlot Security2 Taxlot Security3 Taxlot REST response is Security 1Taxlot Security 1Taxlot Security2 Taxlot Security3 Taxlot I have been able to read the taxlots for each security in SOAP. I want to store them in a matrix something like taxlot[1], taxlot[2]... The number of taxlots are dependent on another field called row count. So I want to use a for loop and store the values . I tried something like below secIndex is for security count taxlotids is the number of taxlot for each security j is to store the taxlots in an array def j=0 for (def secIndex=1;secIndex<val;secIndex++) { def securities=holder.getNodeValues( "//gl:SampleResponse/SecurityList/SecurityInformation[$secIndex]/SecurityNumber[1]") log.info securities.toString() // logs the security number def taxlotids =holder.getNodeValues( "//gl:SampleResponse/SecurityList/SecurityInformation[$secIndex]/TaxLotList[1]/TaxLotInformation").length log.info taxlotids // logs the number of taxlots for each security int taxlotidsi=taxlotids+1 def matrix= [] for (def ti=1;ti<taxlotidsi;ti++) { def termval= holder.getNodeValues( "//gl:SampleResponse/SecurityList/SecurityInformation[$secIndex]/TaxLotList[1]/TaxLotInformation[$ti]/GainLossForTaxLot[1]/Term[1]" ) // This gets the Taxlotfield matrix[j]=termval //Creating an array to store these taxlots. Not sure if its the right way log.info matrix[j].toString() j++ //incrementing the array counter log.info j } } log.info matrix[2] ------ I want to log the value of second taxlot but this gives an error7 years agoPlace ReadyAPI QuestionsReadyAPI Questions723Views0likes1Comment