I'm trying to extract a value from a response to a GET HTTP and storing this value in an environment variable using POSTMAN, then i would use this value for the next HTTP request. This is is an extract of the body response:
<p style="display:none;"><input type="hidden" name="sessionid" id="sessionid" value="e8e63af56d146f42e80f6cd8602cd304708efa58d60e9a43f91cb12e8a2064f4"/><input type="hidden" name="submitbutton" id="submitbutton" value=""/></p>
I need to extract the "value" and then storing it inside an environment variable. how can i accomplish this using Test scripting in POSTMAN?
thanks
Update: After receiving help from this community and this link: https://community.getpostman.com/t/how-to-extract-a-value-attribute-from-an-input-tag-where-the-body-is-a-web-page/1535/2
I was able to do all the stuff, here my code:
var responseHTML = cheerio(pm.response.text());
var variabile = responseHTML.find('[name="sessionid"]').val();
console.log(variabile);
pm.globals.set("session", variabile);
now i can see the sessionid value saved inside the global variable.