# Is there a way to get the JWT Token inside the LocalStorage of the Browser using Robot Framework?

**URL:** <https://forum.robotframework.org/t/is-there-a-way-to-get-the-jwt-token-inside-the-localstorage-of-the-browser-using-robot-framework/4789>\
**Category:** Robot Framework\
**Created:** [6 October 2022 04:18 UTC](https://forum.robotframework.org/t/is-there-a-way-to-get-the-jwt-token-inside-the-localstorage-of-the-browser-using-robot-framework/4789 "2022-10-06T04:18:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nyxalexa](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/nyxalexa/32/1726_2.png) [@nyxalexa](https://forum.robotframework.org/u/nyxalexa)\
**Post date:** [6 October 2022 04:18 UTC](https://forum.robotframework.org/t/is-there-a-way-to-get-the-jwt-token-inside-the-localstorage-of-the-browser-using-robot-framework/4789/1 "2022-10-06T04:18:13Z")

</div>

![image](https://europe1.discourse-cdn.com/flex005/uploads/robotframework1/original/2X/7/70b7efa3b8bd666e683b02c451539768995aa8de.png)

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [7 October 2022 02:13 UTC](https://forum.robotframework.org/t/is-there-a-way-to-get-the-jwt-token-inside-the-localstorage-of-the-browser-using-robot-framework/4789/2 "2022-10-07T02:13:09Z")

</div>

Hi Nyx,

1. If your lucky the JWT is passed by a cookie in which case [Get Cookie](https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html#Get%20Cookie) or [Get Cookies](https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html#Get%20Cookies) will get you what you need.

2. another option if the JWT is passed as a http header then you will probably need to work with some javascript to extract it, [Execute Javascript](https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html#Execute%20Javascript) will be useful to do this.  
Here is some Javascript that I modified from some examples I found regarding getting headers from a page, it basically triggers the browser to send a HTTP HEAD request for the current page and then extracts the headers from that HEAD request

```javascript
var req = new XMLHttpRequest();
req.open('HEAD', document.location, false);
req.send(null);
var headrs = req.getAllResponseHeaders().split("\n");

```

1. yet another option is to use the javascript functions for accessing the storage locations, i’ve never done this myself, but I found some documentation on it here [JavaScript localStorage - GeeksforGeeks](https://www.geeksforgeeks.org/javascript-localstorage/), combine that with [Execute Javascript](https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html#Execute%20Javascript) and you might be able to query that storage location directly

Hope this helps,

Dave.

---

<div class="post-metadata">

**Author:** ![nyxalexa](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/nyxalexa/32/1726_2.png) [@nyxalexa](https://forum.robotframework.org/u/nyxalexa)\
**Post date:** [7 October 2022 05:14 UTC](https://forum.robotframework.org/t/is-there-a-way-to-get-the-jwt-token-inside-the-localstorage-of-the-browser-using-robot-framework/4789/3 "2022-10-07T05:14:25Z")

</div>

Thank you so much highly appreciated, i’ll get look into your suggestions @damies13

---

<div class="post-metadata">

**Author:** ![nyxalexa](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/nyxalexa/32/1726_2.png) [@nyxalexa](https://forum.robotframework.org/u/nyxalexa)\
**Post date:** [14 October 2022 07:51 UTC](https://forum.robotframework.org/t/is-there-a-way-to-get-the-jwt-token-inside-the-localstorage-of-the-browser-using-robot-framework/4789/4 "2022-10-14T07:51:55Z")

</div>

Hello @damies13 I’ve found a library where you can easily get an item on the localStorage or sessionStorage

- [https://marketsquare.github.io/robotframework-seleniumtestability/index.html?tag=plugin](https://marketsquare.github.io/robotframework-seleniumtestability/index.html?tag=plugin)
- [GitHub - MarketSquare/robotframework-seleniumtestability: Extension for SeleniumLibrary that provides manual and automatic waiting for asyncronous events like fetch, xhr, etc.](https://github.com/MarketSquare/robotframework-seleniumtestability)

![Screenshot from 2022-10-14 15-50-05](https://europe1.discourse-cdn.com/flex005/uploads/robotframework1/original/2X/c/c62c5a68cf316243325470b59ceafaa213cfa222.png)

* * *

 ![Screenshot from 2022-10-14 15-50-18](https://europe1.discourse-cdn.com/flex005/uploads/robotframework1/original/2X/4/48a149605fe40ba77c3d68b20dd6f35b7c738b9d.png)
