I have 2 function to wait in my script
// Wait for message to show up page.waitForFunction("document.querySelector('div#message').textContent.includes('string inside message')") .then(() => { return res.status(404).json({ success: true, data: null, message: 'Message' }); }); // Wait for result to show up after clicking some button page.waitForSelector('.result', { timeout: 180000, visible: true, }) .then(() => {});
Somehow the function waitForFunction
never run the return res.status(404)
, even I saw the message shown up and check for the function in the browser console. It returned true
.
The result won't appear if the message appear.The message won't appear if the result appear.
How can I achieve this?