How would I get the value of a sessionStorage variable in protractor? I tried:
browser.executeScript('sessionStorage.getItem("login");');
but that returns null. Using sessionStorage.getItem() without browser.executeScript() returns an undefined for sessionStorage.
sessionStorage is similar to localStorage ; the difference is that while data in localStorage doesn't expire, data in sessionStorage is cleared when the page session ends.
Session storage is a popular choice when it comes to storing data on a browser. It enables developers to save and retrieve different values. Unlike local storage, session storage only keeps data for a particular session. The data is cleared once the user closes the browser window.
figured it out.
browser.executeScript("return window.sessionStorage.getItem('login');");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With