如果我设置了localStorage
项目,StorageEvent
则为除当前之外的所有同域窗口触发。
如果我以StorageEvent
编程方式引发,则StorageEvent
仅针对目标窗口触发。
代码示例:
var evt = document.createEvent('StorageEvent');
evt.initStorageEvent('storage',false,false,'key','oldValue','newValue',
'http://example.com',window.localStorage);
window.dispatchEvent(evt);
Run Code Online (Sandbox Code Playgroud)
我可以修改代码示例以模拟来自 window.setItem
我使用testcafe
测试框架-https: //devexpress.github.io/testcafe。
我写了以下代码:
const table = Selector('#table');
for(let i = 0; i < table.rows.length; i++){
for(let j = 0; j < table.columns.length; j++) {
let tdText = await table.rows[i].cells[j].textContent;
//another actions
}
}
Run Code Online (Sandbox Code Playgroud)
如何使用testcafe获取表中所有单元格的文本?
javascript automated-tests web-testing functional-testing testcafe