Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Puppeteer waitForBackboneEvent()
const puppeteer = require('puppeteer');
(async() => {
const browser = await puppeteer.launch({
ignoreHTTPSErrors: true,
slowMo: 100,
headless: false,
args: ["--disable-notifications", "--ash-host-window-bounds 100+200-300x400"]
});
page.on('console', msg => {
console.log(msg.text)
});
await page.goto("https://www.datememe.com", {
waitUntil: "networkidle2"
}).catch(function(err) {
console.log("reject", err);
})
var waitForEvent = async function(event_name) {
await page.evaluate(event_name => {
return new Promise((resolve, reject) => {
if (!window.vents) reject("no events found");
console.log("waiting for event", event_name);
window.vents.on(event_name, function(msg) {
window.vents.off(event_name);
resolve();
});
});
}, event_name);
}
await waitForEvent("something");
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment