Forum Discussion

andrew_laser's avatar
andrew_laser
Occasional Contributor
14 years ago

selectFromCurrent() method doesn't work in "TearDown Script"

Method com.eviware.soapui.impl.wsdl.teststeps.assertions.basic.XPathContainsAssertion.selectFromCurrent() doesn't do anything when executed in TearDown Script.
Though it works correctly when executed in Script assertion.

Not working code from TearDown script:
testCase.getTestStepByName("test").getAssertionByName('Response').selectFromCurrent()

Working code from script assertion (in a test step)
context.getCurrentStep().getAssertionByName('Response').selectFromCurrent()

Does anybody know how to
1) make the method selectFromCurrent() work in TearDown script
or
2) in TearDown script get the current result produced by XPath expression (so I can set it as expected myself)

5 Replies

  • deepesh_jain's avatar
    deepesh_jain
    Frequent Contributor
    See if this works:

    testRunner.testCase.getTestStepByName("test").getAssertionByName('Response').selectFromCurrent()

    However I am not sure if the WSDLTestStep here has any method that you are using above : getAssertionByName

    Regards,
    Deeepsh Jain
  • andrew_laser's avatar
    andrew_laser
    Occasional Contributor
    deepesh.jain wrote:

    testRunner.testCase.getTestStepByName("test").getAssertionByName('Response').selectFromCurrent()
    However I am not sure if the WSDLTestStep here has any method that you are using above : getAssertionByName

    Thanks for a suggestion, but it doesn't work.

    BTW, getAssertionByName(xxx) returns assertion (not TestStep). In my case it returns XPath assertion i.e. XPathContainsAssertion (not WSDLTestStep )
  • deepesh_jain's avatar
    deepesh_jain
    Frequent Contributor
    Agreed, but the assertion would be on a test step itself.

    If you are using thsi code AFTER the soap/rest step, and the code do work in script assertion, why not pass all the details of the test step in context from the script assertion and see if you are able to access it later in groovy script, its kinda redundant, but if it works why not.

    Try:

    context.step_name = context.getCurrentStep().getAssertionByName('Response')
    OR
    context.step_name = context.getCurrentStep()
    from script assertion

    Then in the groovy later on, access it as:

    def abc = context.step_name
    def xyz = abc.getAssertionByName('Response').selectFromCurrent();
  • andrew_laser's avatar
    andrew_laser
    Occasional Contributor
    Sorry to tell you, but it didn't work either.
    It's weird, but all other setters work correctly and change the assertion
    e.g. setAllowWildcards(boolean allowWildcards), setExpectedContent(java.lang.String expectedContent) worked correctly and updated the XPathContainsAssertion assertion.

    I was also trying the following
    1) get current response XML
    2) process it using XPath (use getPath() to get it)
    3) set the result from 2) as expected by means of method setExpectedContent(java.lang.String expectedContent)

    The problem was - unable to 2) process received response using XPath the same way as soapUI does.