Python + Selenium + PhantomJS render to PDF

前端 未结 4 603
-上瘾入骨i
-上瘾入骨i 2020-12-08 10:52

Is it possible to use PhantomJS\'s rendering to PDF capabilities when PhantomJS is being used in combination with Selenium and Python? (ie. mimic page.ren

4条回答
  •  猫巷女王i
    2020-12-08 11:34

    @rejected, I know you mentioned not wanting to use subprocesses, but...

    You may actually be able to leverage subprocess communication more than you anticipated. Theoretically, you could take Ariya's stdin/stdout example and extend it to be a relatively generic wrapper script. It might first accept a page to load, then listen for (& execute) your test actions on that page. Eventually, you could kick off the .render or even make a generic capture for error handling:

    try {
      // load page & execute stdin commands
    } catch (e) {
      page.render(page + '-error-state.pdf');
    }
    

提交回复
热议问题