Set item from localStorage in protractor test

describe('The feature', function() { beforeEach(function () { browser.executeScript('localStorage.setItem("key","value");'); }); it('should do this', function() { }); }); 

but I get this error when the test runs against selenium with chrome topography 2.10 and chrome 37

 Executing: [execute script: window.localStorage.setItem("key","value");, []]) 15:31:29.747 WARN - Exception thrown org.openqa.selenium.WebDriverException: <unknown>: Failed to read the 'localStorage' property from 'Window': Storage is disabled inside 'data:' URLs. (Session info: chrome=37.0.2062.120) (Driver info: chromedriver=2.10.267518,platform=Linux 3.11.0-26-generic x86_64) (WARNING: The server did not provide any stacktrace information) 

Any idea where the problem is with the camera?

+6
source share
1 answer

According to one of the answers Remove an item from localStorage in the protractor test , this happens when you try to access localStorage without hitting the browser (say browser.get ) when you use the Chrome driver. It looks like the solution hit the browser first (possibly your root page) to load the page in Chrome so you can manipulate the local storage. This is at least what I did for our project. Hope this helps!

+5
source

Source: https://habr.com/ru/post/976552/


All Articles