1. 程式人生 > 其它 >jmeter只調用一次登入介面方法

jmeter只調用一次登入介面方法

可以把登入介面單獨放在一個執行緒組裡面,然後向下傳參

 

實現思路:
1.新增setup執行緒組,新增登入介面

 

 

 

登入介面下面:

-》新增邊界提取器

-》新增資訊頭管理器

-》新增Beanshell 後置處理程式即BeanShell PostProcessor,使用setProperty的函式,然後在下個執行緒裡的header裡增加這個sessionid:
${__setProperty(new_sessionid,${sessionid},false)}

-》新增除錯後置處理即debug PostProcessor,用來看登入介面是否取值成功

 

 

 

 

2. 新增執行緒組,放獲取產品列表的介面

產品列表介面下面:
-》新增資訊頭

 

 

Cookie  SESSIONID=${__P(new_sessionid)}

 

 

 

 

 

 

 

 

 

 

 

 

 

另外
-》新增Beanshell 後置處理程式即BeanShell PostProcessor,使用setProperty的函式,然後在下個執行緒裡的header裡增加這個sessionid:
${__setProperty(new_sessionid,${sessionid},false)}

BeanShell PostProcessor也可以用beanshell 斷言來做,即新增benshell斷言將正則擷取token和使用者userid儲存下,,效果是一樣的!

${__setProperty(new_token,${token},false)}
${__setProperty(new_uid,${uid},false)}

 

 

 

 ${__P(new_token)}

 ${__P(new_sessionid)}

cookie引數放在訊息頭裡面