简体   繁体   English

groovy.lang.MissingPropertyException:没有此类属性:类文件:第5行的Script7错误

[英]groovy.lang.MissingPropertyException: No such property: file for class: Script7 error at line 5

I am writing groovy script to save raw soap request & response and i get this error: 我正在编写groovy脚本以保存原始肥皂请求和响应,但出现此错误:

groovy.lang.MissingPropertyException: No such property: file for class: Script7 error at line 5 groovy.lang.MissingPropertyException:没有此类属性:类文件:第5行的Script7错误

Here is the Script: 这是脚本:

def myOutFile = context.expand( '${#TestSuite#fileName}' )+"_PostPaid-Success_Payment_BillInqReq.xml" 
def response = context.expand( '${BillInq#Request}' ) 
def f = new File(myOutFile) 
f.write(response, "UTF-8") 
file.write(context.rawRequest,'utf-8')

测试套件属性

测试用例

Please follow the steps below: 请按照以下步骤操作:

  • Go to Test Suite PostPaid 转到PostPaid Test Suite
  • Add a custom property say DATA_STORE_PATH and its value to a directory name where you like to save the requests and responses 在要保存请求和响应的目录名称中添加一个自定义属性,例如DATA_STORE_PATH及其值
  • Go to test case PostPaid_Success_Payment 转到测试用例PostPaid_Success_Payment
  • Disable the Step 2 & Step 3 ie, SaveInquiryReq and SaveInquiryResponse steps. 禁用步骤2和步骤3,即SaveInquiryReqSaveInquiryResponse步骤。 or you may remove altoger as well if no other work is done apart from save the request & response respectively. 或者,如果除了保存请求和响应以外没有其他工作,也可以删除altoger。
  • Click on step1 BillInq , click on assertions, Choose Script Assertion , see here for more details how to add script assertion 单击step1 BillInq ,单击断言,选择Script Assertion ,有关更多详细信息,请参见此处, 如何添加脚本断言
  • Have below script and click ok 有以下脚本,然后单击确定
  • Now you run the step1, you should be able to see the request and responses saved in the above mentioned directory 现在运行步骤1,您应该能够看到保存在上述目录中的请求和响应
/**
 * This script logs both request and response
 */

assert context.response, "Response is empty or null"
assert context.request, "Request is empty or null"

//Save the contents to a file
 def saveToFile(file, content) {
    if (!file.parentFile.exists()) {
         file.parentFile.mkdirs()
         log.info "Directory did not exist, created"
    }
    file.write(content) 
    assert file.exists(), "${file.name} not created"
 }
 def dirToStore = context.expand('${#TestSuite#DATA_STORE_PATH}')
 def currentStepName = context.currentStep.name
 def requestFileName = "${dirToStore}/${currentStepName}_request.xml"
 def responseFileName = "${dirToStore}/${currentStepName}_response.xml"
 //Save request & response to directory
 saveToFile(new File(requestFileName), context.rawRequest)
 saveToFile(new File(responseFileName), context.response)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:groovy.lang.MissingPropertyException没有这样的属性:sql对于类:Script9 - error: groovy.lang.MissingPropertyException No such property: sql for class: Script9 Jenkins groovy.lang.MissingPropertyException:没有这样的属性:对于类:Script1 - Jenkins groovy.lang.MissingPropertyException: No such property: for class: Script1 groovy.lang.MissingPropertyException:没有这样的属性:类的getTestCaseByName: - groovy.lang.MissingPropertyException: No such property: getTestCaseByName for class: groovy.lang.MissingPropertyException:没有这样的属性:类的列数:Script1 - groovy.lang.MissingPropertyException: No such property: Cols for class: Script1 groovy.lang.MissingPropertyException:没有这样的属性:类经理:Script1 - groovy.lang.MissingPropertyException: No such property: manager for class: Script1 groovy.lang.MissingPropertyException:没有这样的属性:类的脚本:groovy.lang.Binding - groovy.lang.MissingPropertyException: No such property: script for class: groovy.lang.Binding groovy.lang.MissingPropertyException:没有此类属性: - groovy.lang.MissingPropertyException: No such property: groovy.lang.MissingPropertyException:没有此类属性:class 的 ERROR_MESSAGE:groovy.lang.Binding - groovy.lang.MissingPropertyException: No such property: ERROR_MESSAGE for class: groovy.lang.Binding groovy.lang.MissingPropertyException:没有这样的属性:类的工具包:custom.SampleKeyword - groovy.lang.MissingPropertyException: No such property: Toolkit for class: custom.SampleKeyword groovy.lang.MissingPropertyException:没有这样的属性:任何类:WorkflowScript - groovy.lang.MissingPropertyException: No such property: any for class: WorkflowScript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM