• [SoapUI] 获取Cookie,并循环遍历当前Project下所有的Test Suite,Test Case,Test Step,将Cookie传递给这些Test Step


    import com.eviware.soapui.support.types.StringToStringMap
    
     //Get all th cookies in the response , here the test step name is provided
    def cookiesList = testRunner.testCase.getTestStepByName("Login").testRequest.response.responseHeaders["Set-Cookie"]
    log.info cookiesList
    
    //Get the second cookie, only this one is must for PA API testing
    String cookieNew = cookiesList.get(1)
    log.info "cookie : "+cookieNew
    
    // Set the project level property : cookie , its value will updated with cookieNew
    testRunner.testCase.testSuite.project.setPropertyValue( "cookie", cookieNew )
    
    //Put cookie to a StringMap
    def cookieMap = new StringToStringMap()
    cookieMap.put("Cookie",cookieNew)
    
    def testSuiteList =  testRunner.testCase.testSuite.project.getTestSuiteList()
    def testCaseList
    def testStepList
    for(testSuite in testSuiteList){
    	log.info "Test suite number : "+testSuiteList.size()
    	testCaseList =  testSuite.getTestCaseList()
    	for(testCase in testCaseList){
    		log.info "Test case number : "+testCaseList.size()
    		testStepList = testCase.getTestStepsOfType(com.eviware.soapui.impl.wsdl.teststeps.RestTestRequestStep.class)
    		log.info "Test step number : "+testStepList.size()
    		for (testStep in testStepList){
    			log.info "Pass cookie to  test step : "+testStep.name
    			testStep.testRequest.setRequestHeaders(cookieMap)
    		}
    	}
    }
    

    执行结果:

  • 相关阅读:
    [C4] 前馈神经网络(Feedforward Neural Network)
    [C3] 正则化(Regularization)
    [C2] 逻辑回归(Logistic Regression)
    [C1] 线性回归(Linear Regression)
    Python基础学习
    装饰器
    完全理解Python迭代对象、迭代器、生成器
    django自己搭建的博客
    git学习,哇瑟说实话我想要的
    类继承和多态,子类重写构造函数,多重继承学习
  • 原文地址:https://www.cnblogs.com/MasterMonkInTemple/p/4623550.html
Copyright © 2020-2023  润新知