我做端到端測試幻像和量角器的幫助,但每次 我做我的代碼(不是E2E測試代碼)的變化,似乎幻影是不是 採取的新變化或清潔的localStorage和sessionStorage的。我認爲這可能是緩存,但我不確定。如何清除幻像上的localstorage和sessionstorage?
我試圖在我的protractor.config文件中添加下一句以清理LocalStorage。
onPrepare: function() { browser.executeScript("return window.localStorage.clear();"); }
然而,它沒有工作,而不是我得到這個錯誤
var template = new Error(this.message);^UnknownError: {"errorMessage":"SecurityError: DOM Exception 18","request":{"headers":{"Accept-Encoding":"gzip,deflate","Connection":"Keep-Alive","Content-Length":"58","Content-Type":"application/json; charset=utf-8","Host":"localhost:9781","User-Agent":"Apac he-HttpClient/4.5.1 (Java/1.7.0_79)"},"httpVersion":"1.1","method":"POST","post":"{\"script\":\"return window.localStorage.clear();\",\"args\":[]}","url":"/execute","urlParsed":{"anchor":"","query":"","file":"execute","directory":"/","path":"/execute","relative ":"/execute","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/execute","queryKey":{},"chunks":["execute"]},"urlOriginal":"/session/dc9ce280-e15f-11e5-911a-4b92e3de49f0/execute"}} Build info: version: '2.51.0', revision: '1af067d', time: '2016-02-05 19:15:17' Driver info: driver.version: unknown