0

My app uses the localStorage event to "communicate" across browser windows. But it seems that testcafe does not pulish the storage event to other browser instances.

Example:

<button onClick="setData()">Set</button>

<div id="test"></div>
<script>
window.addEventListener('storage', function(e) {  
 console.log('storage event');
 document.querySelector("#test").textContent = "received";
});

function setData(){
  console.log('SET');
  localStorage.setItem('superpower', 'heatvision');
  
 document.querySelector("#test").textContent = "clicked";
}

</script>

Test:

const { Selector } = require("testcafe");

fixture `Test`
    .page `http://localhost:8081`;

test("test", async t => {
    await t.openWindow("http://localhost:8081")
    await t.click("button")
    await t.expect(Selector("div").innerText).eql("clicked")
    await t.switchToPreviousWindow();
    await t.expect(Selector("div").innerText).eql("received")
})

Does anyone know if this is possible using testcafe?

Alex Skorkin
  • 4,264
  • 3
  • 25
  • 47
Josef Biehler
  • 952
  • 4
  • 16
  • This behavior sounds like a bug. Please [create an issue](https://github.com/DevExpress/testcafe/issues/new?assignees=&labels=&template=bug-report.md) in the TestCafe GitHub repository and share an example where this problem is reproducible. – aleks-pro Mar 01 '21 at 12:40
  • @aleks-pro thanks. I have opened an issue – Josef Biehler Mar 01 '21 at 17:55

0 Answers0