Keep the type of storage value unchanged and change array and object directly. Supports listening to the changes and setting expires.
Can you show me the screenshot?
I created a repository about web storage, which involves the StorageEvent of localStorage. I want to do e2e testing on it, but I don't know how to handle the StorageEvent. Can you give me some suggestions?
Yes, it works. Thanks for your answer.
@dgozman Yes, I tried it with the code below.
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch();
const page1 = await browser.newPage();
await page1.goto('https://playwright.dev/');
const page2 = await browser.newPage();
await page2.goto('https://playwright.dev/');
page2.on('console', msg => console.log('console ==> ', msg.text()));
await page2.evaluate(() => {
window.addEventListener('storage', (ev) => {
console.log(ev);
})
});
const localStorage = await page1.evaluate(() => {
window.localStorage.setItem('test', 'hello world!');
return JSON.stringify(window.localStorage);
});
console.log('localStorage ==> ', localStorage);
await browser.close();
})();
But it didn't work.
chrome DevTools 支持请求重发,方便后端再次调试请求。
如果觉得这个功能可以增加,我可以提交pr。