18

I am getting an error with my spinach tests (Ruby on Rails). Every test fails for the same reason:

<unknown>: Failed to read the 'localStorage' property from 'Window': Storage is disabled inside 'data:' URLs.
      (Session info: chrome=46.0.2490.86)
      (Driver info: chromedriver=2.20.353124 (035346203162d32c80f1dce587c8154a1efa0c3b),platform=Mac OS X 10.10.5 x86_64)

Example failing test step from Spinach:

step 'I visit the site' do
  visit "/top?DEBUG_USER=#{$spinach_test_userid}"
  page.execute_script('localStorage.clear()') # clear localStorage and reload to act as fresh login
  visit "/top?DEBUG_USER=#{$spinach_test_userid}"
end

Ideas?

Set-up includes RSpec, Capybara, Spinach, Chromedriver, Selenium. Code includes Mongo, Node.js, Rails...

UPDATE: Realized that the tests were not set up to run the app before running the test, so it was trying to find local storage without having correctly visited the page first ('page not found'). Running app manually in a separate terminal tab solved the problem. Leaving this question up for next n00b who needs help. ;-)

mandysimon88
  • 211
  • 1
  • 2
  • 7
  • take a look at http://stackoverflow.com/a/25678498/1033737 or http://stackoverflow.com/a/25678488/1033737 – fabdurso Nov 27 '15 at 16:58
  • 3
    Had looked at both of those but they don't seem relevant as they suggest clearing storage between tests... but this fails upon the first storage clear. – mandysimon88 Nov 27 '15 at 17:10

1 Answers1

8

The problem is that you're trying to delete the local storage data before you're actually navigating to a URL.

Your browser page actually looks like in the screenshot here.

Cosmin
  • 2,354
  • 2
  • 22
  • 39