Having an issue with the Page.evaluateHandle funct...
# javascript
n
Having an issue with the Page.evaluateHandle function not working. When the function is called it doesn't complete, instead a coroutine exception occurs.
Here is the error message from the coroutine:
Copy code
Coroutine failed: Error: Execution context was destroyed, most likely because of a navigation.
Here is the unit test that uses Puppeteer:
Copy code
@Test
fun testDomManipulation() {
    launch {
        val url = "<https://www.test.com>"
        val browser = Puppeteer.launch().await()
        val page = browser.newPage().await()
        val options = mapOf("timeout" to 10000)

        page.goto(url, options).await()
        println("Running page operation...")
        val resultHandle = page.evaluateHandle({
            // Do something here...
            """{ "msg": "Page operation complete"}"""
        }).await()
        println("Result: ${resultHandle.jsonValue().await()}")
        resultHandle.dispose().await()
        browser.close()
    }
}
There might be one issue which could occur when running the unit test: https://github.com/GoogleChrome/puppeteer/issues/979#issuecomment-335332220