ruby-on-rails - ChromeDriver/菠菜/ Selenium 错误 : Failed to read the 'localStorage' property from 'Window' : Storage is disabled inside 'data:' URLs

标签 ruby-on-rails selenium integration-testing selenium-chromedriver spinach

我的菠菜测试(Ruby on Rails)出现错误。每个测试失败的原因都是一样的:

<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)

来自 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

想法?

设置包括 RSpec、Capybara、Spinach、Chromedriver、Selenium。代码包括 Mongo、Node.js、Rails...

更新:
意识到在运行测试之前没有设置测试来运行应用程序,因此它试图在没有正确访问页面的情况下找到本地存储(“页面未找到”)。在单独的终端选项卡中手动运行应用程序解决了这个问题。把这个问题留给下一个需要帮助的 n00b。 ;-)

最佳答案

问题是您在实际导航到 URL 之前尝试删除本地存储数据。
您的浏览器页面实际上看起来像 screenshot here .

关于ruby-on-rails - ChromeDriver/菠菜/ Selenium 错误 : Failed to read the 'localStorage' property from 'Window' : Storage is disabled inside 'data:' URLs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33961660/

相关文章:

javascript - 如何从 Selenium Webdriver 获取异步 Javascript 响应

testing - Grails 测试 JMS 消息传递

ruby-on-rails - "first"在 Ruby 和 Rails 中有什么作用?

ruby-on-rails - 未定义方法 attr_accessible

css - 悬停时删除黑色背景

Java Selenium 等待元素超时

java - 无法使用 Java 在 Selenium Web-Driver 中执行拖放

java - 将 isElementPresent() 从 Selenium 1 迁移到 Selenium 2 时如何避免超时?

java - 在 Spring 应用程序中进行集成测试期间,您如何处理(或阻止)电子邮件的发送?

ruby-on-rails - ActionView::Template::Error (PG::UndefinedColumn: ERROR: column posts.user_id does not exist