量角器-空的本地存储 [英] Protractor - empty local storage

查看:106
本文介绍了量角器-空的本地存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Protractor(与Jasmine一起)来测试我的AngulaJs应用程序.

I'm using Protractor (with Jasmine) to test my AngulaJs application.

作为我某些操作的结果,我将一些数据保存在localStorage中.现在我需要测试其他情况,所以我需要清空存储空间(或者最好只删除一些项目),但是如果我尝试运行:

As result of some of my action I get some data saved in the localStorage. Now I need to test other case, so I need to empty my storage (or better delete only some items) but If I try to run:

browser.executeScript('localStorage.removeItem("config");');

我收到以下错误:

UnknownError: <unknown>: Failed to read the 'localStorage' property from 'Window': Storage is disabled inside 'data:' URLs.
  (Session info: chrome=35.0.1916.153)
  (Driver info: chromedriver=2.10.267517,platform=Mac OS X 10.9.2 x86_64)

关于如何解决的任何想法?

Any idea on how to solve?

预先感谢

推荐答案

另一种可能的解决方案是将任何状态清除都放在afterEach中,该状态将在运行任何测试后运行:(请参阅https://github.com/angular/protractor/issues/188 )

Another potential solution is to put any state clearing in an afterEach, which will run after any test is run: (see https://github.com/angular/protractor/issues/188)

afterEach(function() {
    browser.executeScript('window.sessionStorage.clear();');
    browser.executeScript('window.localStorage.clear();');
});

这篇关于量角器-空的本地存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆