Forum Discussion

pcarlucci's avatar
pcarlucci
New Contributor
12 years ago

Set Property Value via SubmitListener.afterSubmit Event

I have set an event handler for a SubmitListener.afterSubmit event, and am trying to set a property at the TestSuite level with a value I've obtained from an http response, so that I can refer to that property and its value during subsequent test case runs.

I see that Script is invoked with context, submit, and log, but it does not include messageExchange, which I would normally use (with a script assertion at the TestStep level) to set a property value.

Using what is available to me in the event handler - context - and in conjunction with the following code, I receive an error that modelItem is null.

context.modelItem.testStep.testCase.testSuite.setPropertyValue("ResourceId", resourceId)

As an alternative, I can do this...

context.testCase.testSuite.setPropertyValue("ResourceId", resourceId)

...which will not error, but also does not set any property. First, is it possible to set a property value from this event handler script? If so, what am I missing about how to implement it?
  • Hi,

    context.testCase.testSuite.setPropertyValue("Currency", "ABZ")
    log.info context.testCase.testSuite.getProperty("Currency")

    Works for me in the SubmitListener.afterSubmit Event, keep in mind the property is created after the request has been submitted for this event.


    Regards,
    Marcus
    SmartBear Support
  • pcarlucci's avatar
    pcarlucci
    New Contributor
    Yes, something like this: context.testCase.testSuite.setPropertyValue("Currency", "ABZ") does not give me an error, but I also don't see the property and it's value populated in the test suite properties tab after this code executes. When I used the messageExchange interface for a test case assertion, previously, and set a property value the same way, it would appear in the suite's properties tab.

    What is the difference between using context, and using messageExchange? Is the behavior different because of the level that each are run?

    If it helps, I'm using SoapUI Pro 4.6.1.
  • Hi,

    I am able to see the property in the Custom Properties tab for the test suite after running the test case with that event and code given using SoapUI Pro 4.6.1. Can you check that you don't have the event disabled by accident?
  • pcarlucci's avatar
    pcarlucci
    New Contributor
    I do not have the event disabled. I know this because the Disabled check box is unchecked, and I have other code in this script before the line in question that asserts response headers and grabs data from the response, which executes and works fine (see attachment). The setPropertValue method is simply not setting the property and value in my test suite.

    Is there another avenue of support for this issue that I can follow? My company owns licenses for SoapUI Pro and this particular issue is impeding progress. I can send a video of the test run, structure of the project, flow, everything that will confirm this issue, if necessary.
  • Hi,

    Since you are using SoapUI Pro you should post in the SoapUI Pro forum, this post is in the open source forum.
    Another option is you can open a Support ticket at http://www.soapui.org/Support/support-overview.html since you are a Pro user. As I stated above creating a property in SubmitListener.afterSubmit event handler works for me, I see you are using assert and that could be the reason why it's never getting to the setPropertyValue depending on what assert evaluates to.