afterAll 中抛出了一个错误 build 05-Jun-2018 14:32:03 [INFO] AfterAll Failed:将目标移出边界:无法从“Window”读取“localStorage”属性:拒绝访问此文档。 build 05-Jun-2018 14:32:03 [INFO]( session 信息:headless chrome=66.0.3359.139) build 05-Jun-2018 14:32:03 [INFO](驱动程序信息:chromedriver=2.36.540471(9c759b81a907e70363c6312294d30b6ccccc2752),平台=Linux 3.10.0-693.21.1.el7.x86_64 x86>_64)
最佳答案
添加try catch。
function lsTest(){
var test = 'test';
try {
localStorage.setItem(test, test);
localStorage.removeItem(test);
return true;
} catch(e) {
return false;
}
}
if(lsTest() === true){
console.log('presente');
}else{
console.log('assente');
}
这将解决问题。
关于protractor - 将目标移出边界 : Failed to read the 'localStorage' property from 'Window' : Access is denied for this document. build,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50702835/