kazurayam / waitForElementNotPresentWorksOrNot

https://forum.katalon.com/t/katalon-studio-8-6-0-waitforelementnotpresent-bug-timeout/85476/
0 stars 0 forks source link

convert Test Suite Execution Report HTML into PDF using the headless Chrome --print-to-pdf #3

Open kazurayam opened 1 year ago

kazurayam commented 1 year ago

According to the Chroms doc

I can print any HTML into PDF in commandline.

$ /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --headless --disable-gpu --print-to-pdf https://www.chromestatus.com/
169676 bytes written to file output.pdf

This produced this: output.pdf

スクリーンショット 2023-08-29 15 55 39

This looks just great! Chrome supports this. Highly reliable.

kazurayam commented 1 year ago

How would the Katalon's Report HTML would look like in PDF?

:~/katalon-workspace/waitForElementNotPresentWorksOrNot/build/tmp/htmltopdf/Reports/20230828_201457/TS2/20230828_201457 (develop *)
$ /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --headless --disable-gpu --print-to-pdf 20230828_201457.html
58785 bytes written to file output.pdf

This produced this

スクリーンショット 2023-08-29 16 03 02

This looks fine.

But I need to "expandAllChildren('s') before printing the page into PDF.

Well, it's easy.

  1. Using ChromeDriver, open the source HTML in Chrome
  2. Using executeJavascript(), I would execute a javascript expandAllChildren('s1')
  3. Using executeJavascript(), I would get the DOM serialized into string, return the string back to the test script. The test script will save the string (a serialized DOM) into a file.html. In this DOM, all the collapsible <div> nodes will be open.
  4. I will execute a commandline chrome --print-to-pdf file and save the file into wherever I like.
kazurayam commented 1 year ago

Now I feel I can implement this idea successful. This idea deserves an independent project. The project will produce a new Katalon Studio keyword.