Jmeter JSON Extractor在响应中获取标记值

时间:2018-01-30 18:00:16

标签: javascript json regex jmeter

所以这是我得到的回复,我无法提取“webToken”,应该是JSON路径表达式...我已经尝试过$..webToken$.webToken。 我试图在JMeter中使用它,所以我可以传递值

<script>
       function insertInSessionStorage(key, value){
                window.sessionStorage.setItem(key,value);
                //JSON.parse(window.sessionStorage.getItem("userJSON")).firstName
       }
       insertInSessionStorage("userJSON",'{"userId":"123456","firstName":"John","middleInitial":"","lastName":"Smith","email":"JOhnsmith@johnsmith.com","ldapLob":"Corporate ","countryCd":"US","webToken":"5085c443-f05e-42bf-90de-1a7ad4beb6f2","userRoleList":["contact_maintenance","contact_admin"]}');
       insertInSessionStorage("logoutSmUrl",'https://smlogin-qa.testnet.net/siteminderagent/ssologout/Logout.html');
        window.history.pushState({page: 1}, "", "https://smlogin-qa.testnet.net/siteminderagent/ssologout/Logout.html");
        window.onpopstate = function(event) {
          if(event){
            window.location='https://smlogin-qa.testnet.net/siteminderagent/ssologout/Logout.html';
          }
        }
</script>

1 个答案:

答案 0 :(得分:0)

您的回复不是JSON,因此您的表达式无效。

您可以使用此正则表达式:

  

“webToken”: “([^”?] +)“

以这种方式配置Regular_Expression_Extractor

enter image description here