Sharing cookie values between thread groups in JMeter

前端 未结 8 2151
暗喜
暗喜 2020-12-08 11:32

I have the following setup:

Thread A
  - Http Cookie Manager
  - Login Page
Thread B
  - Http Cookie Manager
  - Page to hit
  - Another page to hit
         


        
8条回答
  •  甜味超标
    2020-12-08 11:52

    for more than one field in cookie i tried this n its works

       BeanShell Post Processor 
       props.put("MyCookie","${COOKIE_}");
       props.put("MyCookie1","${COOKIE_}");
    
      BeanShell Pre Processor
    
      import org.apache.jmeter.protocol.http.control.CookieManager;
      import org.apache.jmeter.protocol.http.control.Cookie;
      CookieManager manager = sampler.getCookieManager();
      Cookie cookie = new Cookie("",props.get("MyCookie"),"DOMAIN","/",false,0);
      manager.add(cookie);
      Cookie cookie1 = new Cookie("",props.get("MyCookie1"),"DOMAIN NAME","/",false,0);
      manager.add(cookie1);
    

提交回复
热议问题