# Get element value from HTML response

**URL:** <https://community.postman.com/t/get-element-value-from-html-response/33289>\
**Category:** Help Hub\
**Tags:** tests, cheerio\
**Created:** [March 8, 2022, 2:09pm UTC](https://community.postman.com/t/get-element-value-from-html-response/33289 "2022-03-08T14:09:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![koshmariel](https://avatars.discourse-cdn.com/v4/letter/k/47e85d/32.png) [@koshmariel](https://community.postman.com/u/koshmariel)\
**Post date:** [March 8, 2022, 2:09pm UTC](https://community.postman.com/t/get-element-value-from-html-response/33289/1 "2022-03-08T14:09:55Z")

</div>

Somewhere in the HTML response there is an element:

`<input name="__RequestVerificationToken" type="hidden" value="I_NEED_THIS" />`

How can I get it’s value using Postman?

This is my code but I’m not happy with what it returns

```auto
const $ = cheerio.load(pm.response.text());
console.log($("title").text()); // get title to check if it works
console.log($("__RequestVerificationToken").attr('value')); //returns undefined
console.log($("__RequestVerificationToken").text()); //returns null

```

---

<div class="post-metadata">

**Author:** ![sahuvikramp](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/sahuvikramp/32/10828_2.png) [@sahuvikramp](https://community.postman.com/u/sahuvikramp)\
**Post date:** [March 8, 2022, 2:42pm UTC](https://community.postman.com/t/get-element-value-from-html-response/33289/2 "2022-03-08T14:42:43Z")

</div>

Hello @koshmariel,

Try using the below code.

```auto
console.log($('[name=__RequestVerificationToken]').val());

```

Cheers 😃

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [December 12, 2024, 12:54pm UTC](https://community.postman.com/t/get-element-value-from-html-response/33289/3 "2024-12-12T12:54:15Z")

</div>

Closed on December 12, 2024, 12:54pm UTC

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