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)
		}
	}
}

执行结果:

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

相关文章:

  • 2022-12-23
  • 2021-08-12
  • 2022-12-23
  • 2021-07-16
  • 2021-11-03
  • 2021-12-13
  • 2021-09-14
  • 2021-04-10
猜你喜欢
  • 2022-01-29
  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
  • 2022-12-23
  • 2021-12-02
相关资源
相似解决方案