WebPagetest Forums
Setting localstorage values - Printable Version

+- WebPagetest Forums (https://www.webpagetest.org/forums)
+-- Forum: WebPagetest (/forumdisplay.php?fid=7)
+--- Forum: General Discussion (/forumdisplay.php?fid=25)
+--- Thread: Setting localstorage values (/showthread.php?tid=15840)

Setting localstorage values - avaidhy - 07-18-2019 10:04 AM

Hello all
I am a novice to the WPT and I would like to know if there is a way to set localstorage in the browser session that loads the page
Right now I have the script like this but it is not taking any effect

setCookie xxx.xxx.com split_tcv=200
setCookie xxx.xxx.com __vst=d991880c-d603-41cb-b4ff-d6d11c8fd8b5
exec localStorage.setItem('recently_viewed', '1130217481,2267432533,1497137951,2441643263,1581060853,2267909440');
navigate https://XXX.XXX.com

I also tried
setCookie xxx.xxx.com split_tcv=200
setCookie xxx.xxx.com __vst=d991880c-d603-41cb-b4ff-d6d11c8fd8b5
exec window.localStorage.setItem('recently_viewed', '1130217481,2267432533,1497137951,2441643263,1581060853,2267909440');
navigate https://XXX.XXX.com

RE: Setting localstorage values - pmeenan - 07-19-2019 12:00 AM

You have to be on a page on the domain your are trying to write localstorage to before it will work. If you have a blank page you can host on the domain that would be best. There is no way to pre-populate the local storage before running a first-view test.

RE: Setting localstorage values - avaidhy - 07-19-2019 10:01 AM

Thanks @pmeenan.
After I added another domain page navigation it is setting up local storage with intended values.