mercredi 16 décembre 2020

Working with a not-stringified object logged to the browser console in testcafe

I have been given a page wich logs some object to the console. I want to access this object using getBrowserConsoleMessages(), but unfortunately it appears there as the String "[object Object]" with no way for me to parse it and access its properties. Or at least no way that is obvious to me. What am I missing?

<!DOCTYPE html>
<html>
<body>
    <script>console.log({message: 'Hello, world!'});</script>
</body>
</html>
fixture.page("http://127.0.0.1:5500/test.html")("Check page");

test("Console accessible", async t => {
    const { log } = await t.getBrowserConsoleMessages()
    console.log(JSON.parse(log[0]).message)
})```

Aucun commentaire:

Enregistrer un commentaire