Created
June 19, 2022 12:25
-
-
Save marios88/60746bb5c062e7d7c45c729c5888dd63 to your computer and use it in GitHub Desktop.
Puppeteer Opera open newPage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
operaNewPage = async function(browser) { | |
const browserPages = await browser.pages(); | |
//count pages | |
console.log((await browser.pages()).length); | |
const pageCount = (await browser.pages()).length; | |
const mainPage = (await browser.pages())[0]; | |
await mainPage.evaluate( function (){ | |
window.open('about:blank'); | |
}); | |
while((await browser.pages()).length === pageCount){ | |
//sleep | |
console.log((await browser.pages()).length); | |
//await exports.delay(1000); | |
} | |
//return last element of array | |
let page = (await browser.pages())[(await browser.pages()).length - 1]; | |
return new Promise((resolve) => { | |
resolve(page); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment