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. this的面面观

    http://www.cnblogs.com/Wayou/p/all-this.html <JavaScript语言精粹> 全局this 浏览器宿主的全局环境中, function f(x ...

  2. [attribute^=value] 匹配给定的属性是以某些值开始的元素

    描述: 查找所有 name 以 'news' 开始的 input 元素 HTML 代码: <input name="newsletter" /> <input n ...

  3. openDatabase() chrome vivaldi Stylish

    located at /Users/ruili/Library/Application Support/Vivaldi/Default/databases/ Databases.db contains ...

  4. Hadoop之hive的drop table恢复

    一.引言: 快下班的时候我开发同事问能不能将hive中drop掉的数据恢复过来,我记得是有开回收站的,当时我回答说可以恢复的. 二.恢复过程: 在之前我有对hadoop的回收站有过了解,就是将hdfs ...

  5. Java通过继承thread类与实现Runnable接口实现多线程的区别

    Java中线程的创建有两种方式: 1.  通过继承Thread类,重写Thread的run()方法,将线程运行的逻辑放在其中 2.  通过实现Runnable接口,实例化Thread类 一.通过继承T ...

  6. 【转】运行java -version命令时出现错误及解决

    转载地址:http://blog.sina.com.cn/s/blog_50f21fed01012sf2.html     按照上一篇的步骤配置JAVA_HOME.CLASSPATH和Path三个变量 ...

  7. JAVA基础知识之JDBC——JDBC事务处理及批量更新

    JDBC事务 JDBC的事务由Connection提供,默认是打开的. 要开启事务,则要关闭自动提交, conn.setAutoCommit(false); 提交事务使用 conn.commit(); ...

  8. HDU Coprime

    Coprime Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total S ...

  9. 【Python】我的Python学习笔记【1】【using Python 2】

    1.模块格式 #!/usr/bin/env python # -*- coding: utf-8 -*- ... ...def main(): ...... ... if __name__=='__m ...

  10. 嵌入资源的方式让Winform使用系统没有的字体,无需安装字体

    原文: How to embed a True Type font http://bobpowell.net/embedfonts.aspx 测试项目下载: http://files.cnblogs. ...