Using set_attribute("LocalStorageEnabled", true). An integration test has been added to spec/integration/session_spec.rb.
Some code/inspiration was taken from a pull request by niklasb: #171
Support for enabling/disabling localStorage
I'm curious... Does localStorage actually store things with this patch? I made a similar change, and the localStorage API was available but not actually functioning.
It has been working for the project I'm using it for, although obviously all of the data disappears along with the webkit session, i.e., at the end of a test.
I had mis-read the spec the first time... I thought 'count' was a part of the localStorage API, but I see now that it isn't and that the test demonstrates that localStorage is working. I'm not sure what I did wrong in my attempt to get localStorage to work.
Thanks for the pull request.
I think it would be better to just have local storage enabled all the time. Is there a reason to ever disable it?
Also, we've been using the integration directory to run the specs from capybara itself. A better place for a test like this would be driver_spec.rb.
No, I don't see any good reason why it should be possible to disable it.
I'll take some time to retool the localStorage support so that it's always enabled and move the test to a better spot.
Will this be merged anytime soon?
@chrisfarber Are you still planning to change this so that localStorage is always enabled?
I need the localStorage support ASAP!!
LocalStorage support is no longer optional.
This should do the trick. Sorry for the delay.
Thank you @chrisfarber
Awesome, thanks very much!
+1 localStorage would be useful for me too... is there a reason that this pull request isn't being merged into master?
@gerad we're crunched for time. I'm hoping to take a look at pull requests soon.
@jferris cool, thanks for the update!
@chrisfarber merged this into master
Is it possible to add in the functionality to disable localStorage. As I am trying to write a cucumber test for cases where users have disabled cookies. In most newer browsers when someone disables cookies it also disables local storage.