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. phpcms V9 添加模块

    为phpcms创建一个模块的开发流程 [1]创建模块目录 通过前面的学习,我们已经知道phpcms V9框架中的模块位于phcms/modules目录中,每一个目录称之为一个模块. 如果要创建一个模块 ...

  2. JQuery基础一

    1.在浏览器点击F12,调出源码设置端点F11进行调试 2.要操作DOM对象,首先要把DOM对象封装成juery对象: jQuery(document).ready(function () { ale ...

  3. mysql复制表结构及检查表、存储过程是否存在

    mysql命令行复制表结构的方法: 1.只复制表结构到新表 CREATE TABLE 新表 SELECT * FROM 旧表 WHERE 1=2  或者 CREATE TABLE 新表 LIKE 旧表 ...

  4. iOS禁用第三方键盘

    - (BOOL)application:(UIApplication *)application shouldAllowExtensionPointIdentifier:(NSString *)ext ...

  5. 相似性度量(Similarity Measurement)与“距离”(Distance)

    在做分类时常常需要估算不同样本之间的相似性度量(Similarity Measurement),这时通常采用的方法就是计算样本间的“距离”(Distance).采用什么样的方法计算距离是很讲究,甚至关 ...

  6. epoll实现压测工具

    代码: /* * g++ -o stress_test ./stress_test.cpp */ #include <stdlib.h> #include <stdio.h> ...

  7. 20161106PM-Fiddler

    1. 设置Fidder使之支持HTTPS协议 Tools->Fiddler Options->HTTPS->勾上Decrypt HTTPS traffic->OK 2. 断点 ...

  8. Apache Solr 访问权限控制

    Current state of affairs SSL support was added in version 4.2 (SolrCloud v4.7). Protection of Zookee ...

  9. 让下拉框中同时显示Key与Value

    声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...

  10. Redis - 作为 LRU 缓存

    一.简介 LRU 实际上是被唯一支持的数据移除方法,同时也是 memcached 默认支持的缓存算法. 二.配置内存大小 在 redis.conf 文件中使用 maxmemory 指令能够配置内存大小 ...