pcarlucci
12 years agoNew Contributor
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?
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?