Headless chrome window.print()
Reported by
uwiz...@gmail.com,
Jul 20 2017
|
|||||||||
Issue descriptionImagine js page with window.print() js code. If you try to open such page with headless chome, there is no way to accept or close the dialog caused py print() function. Calling .close() on chrome-remote-interface also does nothing
,
Jul 25 2017
The page with window.print(): http://www.galant-biz.ru/print.html node.js code: (async function() { const Koa = require('koa'); const chrome = require('chrome-remote-interface'); const app = new Koa(); app.listen('9223'); const target = await chrome.New(); const client = await chrome({ target: target.id }); const { DOM, Network, Page, Runtime } = client; await Promise.all([Page.enable(), Runtime.enable(), DOM.enable(), Network.enable()]); await Page.navigate({ url: 'http://www.galant-biz.ru/print.html' }); setTimeout(async () => { console.log('timeout') await client.close(); console.log('client closed') await chrome.Close(target); },10000) await Page.loadEventFired(); })(); Function loadEventFired() is never fired, client.close() is never finished.
,
Jul 28 2017
It seems chrome://print dialog doesn't get open in HeadlessChrome. You can check by calling GetWindowHandles() after navigating to 'http://www.galant-biz.ru/print.html' . 1) In normal Chrome, here is the output: [24.948][INFO]: COMMAND GetWindows { } [24.948][DEBUG]: DevTools request: http://localhost:12506/json [24.948][DEBUG]: DevTools response: [ { "description": "", "devtoolsFrontendUrl": "/devtools/inspector.html?ws=localhost:12506/devtools/page/65a1c866-629b-4085-9cc1-755c359dce29", "id": "65a1c866-629b-4085-9cc1-755c359dce29", "title": "Координаты «БЦ ГАЛАНТ» — версия для печати", "type": "other", "url": "chrome://print/", "webSocketDebuggerUrl": "ws://localhost:12506/devtools/page/65a1c866-629b-4085-9cc1-755c359dce29" }, { "description": "", "devtoolsFrontendUrl": "/devtools/inspector.html?ws=localhost:12506/devtools/page/1b9150e9-e965-46df-b0f2-5c5d108d15a1", "id": "1b9150e9-e965-46df-b0f2-5c5d108d15a1", "title": "Chrome Automation Extension", "type": "background_page", "url": "chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/_generated_background_page.html", "webSocketDebuggerUrl": "ws://localhost:12506/devtools/page/1b9150e9-e965-46df-b0f2-5c5d108d15a1" }, { "description": "", "id": "27f91d65-1118-47db-8431-451200a642ed", "title": "Координаты «БЦ ГАЛАНТ» — версия для печати", "type": "page", "url": "http://www.galant-biz.ru/print.html" } ] [24.948][INFO]: RESPONSE GetWindows [ "CDwindow-27f91d65-1118-47db-8431-451200a642ed", "CDwindow-65a1c866-629b-4085-9cc1-755c359dce29" ] 2) whereas, in Headless Chrome, the output is as follows: [13.102][INFO]: COMMAND GetWindows { } [13.102][DEBUG]: DevTools request: http://127.0.0.1:9222/json [13.102][DEBUG]: DevTools response: [ { "description": "", "id": "83577781-f7ad-4694-9006-03d31f141099", "title": "Координаты «БЦ ГАЛАНТ» — версия для печати", "type": "page", "url": "http://www.galant-biz.ru/print.html" } ] [13.102][INFO]: RESPONSE GetWindows [ "CDwindow-83577781-f7ad-4694-9006-03d31f141099" ] Notice that "chrome://print/" is missing in output of HeadlessChrome. Jianzhou: Is "chrome://print/" not supported on HeadlessChrome?
,
Jul 29 2017
"chrome://print/" is not supported in headless chrome. The window.print() wouldn't open the printing dialog and the command is just ignored. In headless chrome, the print settings are set via Page.printToPDF devtools command, instead of the printing dialog, which is a UI. Maybe we can add the print to pdf feature into chromedriver so that users can print the page?
,
Jul 29 2017
Oh, I just notice you are using chrome-remote-interface instead of chromedriver. So you can just use the Page.printToPDF command to print the page.
,
Jul 29 2017
I will take a look at why loadEventFired is never fired.
,
Aug 11 2017
,
Aug 14 2017
Any update? The main question is actually why loadEventFired is never fired. I do not need to print this page, just want to ignore window.print() somehow. But it seems to hang the loadEventFired.
,
Aug 31 2017
Anybody is working on this?
,
Oct 16 2017
jzfeng@: Could you please provide an update to this issue? Thanks!
,
Nov 1 2017
,
Apr 18 2018
Any updates on Chrome Headless Driver's ability to support printToPDF via API ?
,
Apr 18 2018
Hi Eric, I think Jianzhou is no longer working on headless Chrome. Could you please take a look at this bug? Thanks.
,
Apr 18 2018
Off to caseq@. Might also be a good starter bug for Johannes? Sounds like the problem here is that the load event is not fired. Printing works as expected.
,
Apr 18 2018
,
Apr 18 2018
,
Apr 27 2018
,
Jan 11
Setting defect without priority to Pri-2. |
|||||||||
►
Sign in to add a comment |
|||||||||
Comment 1 by gmanikpure@chromium.org
, Jul 20 2017