I want to download a screenshot of the contents of a Chrome browser window from another Chrome browser window.
I will have full control over both pages and they will be hosted on the same domain.
I have already figured out cross-window communication using postMessage
. I am NOT trying to answer the question "how do I call a function in Window B from Window A?"
I am familiar with Puppeteer. This question is related, but I can not use puppeteer because this is running in the browser (and has to run there). I don't need any answers for how to do this server side.
html2canvas is interesting, but too limited. I am looking to capture a screenshot that has perfect fidelity to what chrome displays on screen.
I know Chrome Debugging Protocol exposes a Page.captureScreenshot()
method. But I don't know how (or whether it's possible) to communicate with it from within a browser.
Can anyone give me any advice about how to accomplish this?