5

I have seen many examples for fetching the already stored data but didn't get any example for fetching the stored values.

halfer
  • 19,824
  • 17
  • 99
  • 186
Shravan Jain
  • 720
  • 1
  • 11
  • 32
  • check below answers. http://stackoverflow.com/questions/21960598/accessing-localstorage-in-protractor-test-for-angularjs-application – Irfan Ali Apr 06 '17 at 11:12
  • Thanks for your quick reply. I already go through to this link but there is no content regarding the storing of the values using protractor. – Shravan Jain Apr 06 '17 at 11:19

1 Answers1

8

You can access localStorage through browser.executeScript() this way:

Get value

var value = browser.executeScript("return window.localStorage.getItem('myKey');");

Set value

browser.executeScript("window.localStorage.setItem('myKey', 'myValue');");
Stephane Janicaud
  • 3,531
  • 1
  • 12
  • 18