在soapui groovy脚本中从xml获取文本值
发布时间:2020-12-14 16:23:43 所属栏目:大数据 来源:网络整理
导读:我的任务是从soapui中的xml获取值,以便在序列中创建下一个测试. 我使用groovy脚本 我的目标是在标签内获取文字.它很容易识别,因为它是base64编码的字符串. def project = testRunner.testCase.testSuite.project ;def tcase = project.testSuites["ChangeRet
我的任务是从soapui中的xml获取值,以便在序列中创建下一个测试.
我使用groovy脚本 我的目标是在标签内获取文字.它很容易识别,因为它是base64编码的字符串. def project = testRunner.testCase.testSuite.project ; def tcase = project.testSuites["ChangeRetentionByCopyDemoSuite"].testCases["Milestone2"] ; def tstep = tcase.getTestStepByName("getDocuments - GetContentURLRequest"); def responseTestSuite1 = tstep.getPropertyValue("response"); log.info(responseTestSuite1.toString()); def gutils = new com.eviware.soapui.support.GroovyUtils( context ); def holder = gutils.getXmlHolder("$responseTestSuite1"); def byteResponse = holder.getNodeValue("/S:Envelope/S:Body/g:getDocumentsResponse/text()"); log.info(byteResponse); xml在getDocuments – GetContentURLRequest中进行响应
不幸的是,在运行最后一行代码时我遇到了异常 解决方法
如果要在标记“messageText”中提取文本,则可以指定父节点和子节点,即将最后一行修改为
def byteResponse = holder.getNodeValue("//*:operationStatus//*:messageText") // since there is only one tag named "messageText" in the entire response,you could use this also def byteResponse = holder.getNodeValue("//*:messageText") (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |