Get document.cookie field value in html response body

Untitled

API response is a html body. it contains document.cookies in script tag. I want to get document.cookie.value of the field “gt=”. how can i get this field value using test scripts ?

Hi @u9119

Sounds like a RegEx would help… have a look at this post…

This works.

function getCookie(name) { 
    var re = new RegExp(name + "=([^;]+)"); 
    var value = re.exec(pm.response.text()); 
    return (value != null) ? decodeURI(value[1]) : null; 
}

console.log(parseInt(getCookie('gt')));

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.