Skip to content
This repository was archived by the owner on Dec 16, 2023. It is now read-only.

Why zombie does not work with localstorage? #1149

Closed
DmitryPacificAtion opened this issue Jan 18, 2018 · 3 comments
Closed

Why zombie does not work with localstorage? #1149

DmitryPacificAtion opened this issue Jan 18, 2018 · 3 comments

Comments

@DmitryPacificAtion
Copy link

DmitryPacificAtion commented Jan 18, 2018

I see that Zombie has functions to work with local storage, but i can not set, or get, or remove items, like in plain browser (Chrome or Firefox). How does it works?
When i wrote browser.localStorage.setItem('token', '123'); i see TypeError: browser.localStorage.setItem is not a function

@momocow
Copy link

momocow commented Jun 11, 2018

I found a doc for you. FYI

Though it's a very old repository, the doc for localStorage is still effective.

And I've tested myself with zombie.js 6.1.2.

Your problem is that you misuse the browser.localStorage since it's actually a function.
The localStorage of browser object is based on the document origin.
Check these codes.

console.log(typeof browser.localStorage) // [Function: localStorage]

browser.localStorage('localhost').setItem('item1', { useful: true })

const result1 = browser.localStorage('localhost').getItem('item1')
console.log(result1) // { useful: true }

@DmitryPacificAtion
Copy link
Author

Thanks!

@xurei
Copy link

xurei commented Jul 3, 2018

Just went through this problem as well. Any reason why it's not in the docs ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants