javascriptangularjsprotractorgulp-protractor

How to store local storage data using Protractor?


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


Solution

  • 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');");