How to compare values from response of two different requests in SOAP UI using groovy?

久未见 提交于 2019-12-06 14:39:00

You can access the properties you want to compare and perform and assert checking your required condition in groovy script.

You comment in your question that you're using a Property transfer step however you didn't tell where you're storing your results due I suppose for example that you're storing the values in TestCase properties:

// you've to use the name of the property you set in the property transfer step
def fn = testRunner.testCase.getPropertyValue('firstName_firstResponse')
def fn2 = testRunner.testCase.getPropertyValue('firstName_secondResponse')
assert fn == fn2, "THE FIRST NAME AREN'T EQUALS"

In the groovy script testStep context you've a testRunner object which you can use to access testCase, testSuite... and then get the desired property.

Another possible approach is to do the same but getting the properties directly from the response of your testStep and performing XPath, to do so you can use the follow groovy script:

def fn = context.expand('${TestStepName_1#response#*://firstName}')
def fn2 = context.expand('${TestStepName_2#response#*://firstName}')
assert fn == fn2, "THE FIRST NAME AREN'T EQUALS"

Like testRunner the context object is already on the context of groovy testStep. The notation used in context.expand is ${Test Step Name#response#XPath}.

Hope it helps,

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!