Forum Discussion

groovyguy's avatar
groovyguy
Champion Level 1
2 years ago

ReadyAPI 3.30.0 - Intermittent issues with saving data to a properties step via groovy

Running into an issue and wanted to see if anyone else has experienced this. It's cropped up for myself and some of my team members in ReadyAPI 3.30.0. With some of the services we test, we have to save data out of the response and up until this version (we mostly used 2.3.0 until this upgrade), everything worked fine with a script like below. This works as a groovy script assertion, until it doesn't, and starts failing with "Error in assertion script of the [<TestStep Name>] test step: Index 4 out of bounds for length 4."

 

The reason I am asking this is because if I close and restart ReadyAPI, the script assertion works again. But given enough time, it or another like it will fail. Thoughts? Any help is much appreciated.

 

import com.eviware.soapui.support.XmlHolder
import groovy.util.*

def holder=groovyUtils.getXmlHolder(messageExchange.responseContentAsXml)

def currValue = holder["//xpath/to/value/to/save/Identifier"]

context.testCase.testSuite.testCases["Properties"].testSteps["Properties"].setPropertyValue("PropertyName", currValue)

 

4 Replies

  • KarelHusa's avatar
    KarelHusa
    Champion Level 3

    groovyguy ,

    which part of your code fails if you try to debug the script?

     

    I would be careful with handling the XPath expression without providing a namespace, e.g.

     

    holder.namespaces["ns"] = "http://learnwebservices.com/services/tempconverter"

    In some cases XPath without a namespace may work, in others not.

     

    Anyway, I would rather rely on the Property Transfer test step to save the value into a property. It's easier to find an issue later on.

     

    Best regards,

    Karel

     

    • groovyguy's avatar
      groovyguy
      Champion Level 1

      A property transfer does not work in this instance because I have many tests that require this and it is easier (and has always worked) to save via a groovy script. That way the assertion can be copied to all necessary steps.

      The xpath I am using has a namespace. I believe the issue is mostly a defect with ReadyAPI since it works fine until it does not. And yes, the same script will fail all of a sudden and will stop working until I either close and re-open the project, or restart ReadyAPI completely. 

  • nmrao's avatar
    nmrao
    Champion Level 3

    That is strange behaviour. Please check if there is any change in the underline library version used by ReadyAPI l which is specific to xpath  (compare both version lib directories)

    1. Does it run if the test is run using command line instead of UI? If so, is it consistent?

    2. Does the xpath have any static index?

     

     

    • groovyguy's avatar
      groovyguy
      Champion Level 1

      nmrao the problem is completely intermittent and I cannot duplicate it other than running tests and it'll pop up occasionally until I close/open the project or completely restart readyAPI. I can try via command line. And the xpath does have an index that is static, I was just using that as an example.

      I believe I likely need to open a support ticket since this is intermittent and is across many projects and fixes if ReadyAPI restarts. I don't think its a problem with the groovy script.