import com.eviware.soapui.support.types.StringToStringMap

 //Get all the cookies in the response
def cookiesList = testRunner.testCase.getTestStepByName("Login").testRequest.response.responseHeaders["Set-Cookie"]
def cookieNew= cookiesList.get(2).split(";")[0];
log.info "cookie : "+cookieNew // Set the project level property : cookie , its value will be updated with cookieNew
testRunner.testCase.testSuite.project.setPropertyValue("cookie", cookieNew) cookieNew = '${#Project#cookie}' //Put cookie to a StringMap
def cookieMap = new StringToStringMap()
cookieMap.put("Cookie",cookieNew) //Pass cookie to all testSteps of the project
def testSuiteList = testRunner.testCase.testSuite.project.getTestSuiteList()
def testCaseList
def testStepList
for(testSuite in testSuiteList){
testCaseList = testSuite.getTestCaseList()
for(testCase in testCaseList){
testStepList = testCase.getTestStepsOfType(com.eviware.soapui.impl.wsdl.teststeps.RestTestRequestStep.class)
for (testStep in testStepList){
testStep.testRequest.setRequestHeaders(cookieMap)
}
}
} //Pass cookie to testStep "AA_BB" of testSuite "AA"
def testSuiteList = testRunner.testCase.testSuite.project.getTestSuiteList()
def testCaseList
def testStepList
for(testSuite in testSuiteList){
if(testSuite.name == "AA"){
testCaseList = testSuite.getTestCaseList()
for(testCase in testCaseList){
testStepList = testCase.getTestStepsOfType(com.eviware.soapui.impl.wsdl.teststeps.RestTestRequestStep.class)
for(testStep in testStepList){
if(testStep.name == "AA_BB"){
testStep.testRequest.setRequestHeaders(cookieMap)
}
}
}
}
}

SoapUI中如何传递cookie的更多相关文章

  1. 跨域cors中如何传递cookie(前端为什么无法向后端传递cookie?)

    没有跨域 后端server只要在回应头部‘set-cookie’,那么就会有cookie产生并保存在客户端client. 等到client再次向后端server发送请求时浏览器的机制就会自动携带coo ...

  2. Jmeter中传递cookie值

    场景:用户登陆后会本地会保存cookie,cookie是用来跟服务端验证此用户已经登陆过的重要信息,但是如何获取并在其他请求时将此cookie传递给服务器呢? 在线程组下面之直接添加HTTP Cook ...

  3. 使用curl传递cookie错误的问题

    工作中发现一个问题, 通过curl调用接口传递cookie操作用户的数据, 接口的程序解析不了cookie中的数据. 经过排查发现curl发送的cookie数据为 TZ+Gn+rEk+6G4d 而接口 ...

  4. 【ASP.NET Web API教程】5.5 ASP.NET Web API中的HTTP Cookie

    原文:[ASP.NET Web API教程]5.5 ASP.NET Web API中的HTTP Cookie 5.5 HTTP Cookies in ASP.NET Web API 5.5 ASP.N ...

  5. 关于PHP中浏览器禁止Cookie后,Session能使用吗?

    sessionid是存储在cookie中的,解决方案如下: Session URL重写,保证在客户端禁用或不支持COOKIE时,仍然可以使用Session session机制.session机制是一种 ...

  6. ASP.NET Core2.1 中如何使用 Cookie和Session

    https://blog.csdn.net/canduecho/article/details/80651853 ASP.NET Core2.1的官方项目模板在创建的Razor Pages和MVC项目 ...

  7. Jmeter跨线程组传递cookie,以禅道系统为例;BeanShell的存取数据的使用

    先看下脚本结构: 思路:将登陆请求放在setUp Thread Group中:把登陆后的cookie通过正则提取出来,然后存为全局变量,传递到下一个线程组中: 第一步:添加setUp Thread G ...

  8. php中如何传递Session ID

    一般通过在各个页面之间传递的唯一的 Session ID,并通过 Session ID 提取这个用户在服务器中保存的 Session 变量,来跟踪一个用户.常见的 Session ID 传送方法主要有 ...

  9. vertx使用过程中浏览器端Cookie重复问题

    [问题描述] 背景: 使用vertx提供的服务,使用Dispatcher做路由转发,内部通过routingcontext做请求传递及响应. 现象: 在谷歌浏览器的Network中,看到Cookie中有 ...

随机推荐

  1. xcode编译错误

    1.xcode无效文件的编译错误. 问题: clang: error: no such file or directory: '/Users/admin/client/trunk/sengoku_sc ...

  2. 33、mybatis(二)

    第十六章回顾SQL99中的连接查询 1)内连接 2)外连接 3)自连接 第十七章回顾hibernate多表开发 1)一对一 2)一对多 3)多对多 第十八章 mybatis一对一映射[学生与身份证] ...

  3. quick cocos2dx lua 内存释放

    前言 对于内存的优化,网上有很多例子和教程.总体来说,就那么几种解决方案,在最后我会简单提下,这里先说下在quick中,对于图片的处理. 1.查看内存调试信息 对于quick框架的了解,我们可以参考\ ...

  4. 【转】 MySQL与PostgreSQL:该选择哪个开源数据库?哪一个更好?

    转载地址:http://www.infoq.com/cn/news/2013/12/mysql-vs-postgresql 如果打算为项目选择一款免费.开源的数据库,那么你可能会在MySQL与Post ...

  5. BooleanToVisibilityConverter.cs

    //---------------------------------------------------------------------------- // // Copyright (C) M ...

  6. Linux phpwind论坛的安装

    1:新建文件夹phpwind

  7. 【Spring】Spring的定时任务

    > 参考的优秀文章 Task Execution and Scheduling > 版本说明 <dependencies> <dependency> <gro ...

  8. python ConfigParser配置读写

    一.ConfigParser简介 ConfigParser 是用来读取配置文件的包.配置文件的格式如下:中括号"[ ]"内包含的为section.section 下面为类似于key ...

  9. Web API开发实例——对产品Product进行增删改查

    1.WebApi是什么 ASP.NET Web API 是一种框架,用于轻松构建可以由多种客户端(包括浏览器和移动设备)访问的 HTTP 服务.ASP.NET Web API 是一种用于在 .NET ...

  10. [Java基础]循环结构3

    [Java基础]循环结构3 break 与 continue 中断循环... /** 文件路径:G:\JavaByHands\循环语句\ 文件名称:BreakTest.java 编写时间:2016/6 ...