kazurayam / waitForElementNotPresentWorksOrNot

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

convert HTML report to PDF using wkhtmltopdf command #1

Open kazurayam opened 1 year ago

kazurayam commented 1 year ago

There was a post

Katalon produces a report in PDF report, but the report is something broken.

I searched Google how to convert a HTML to PDF. I found

It looks promissing. Why not using wkhtmltopdf?

In this waitForElementNotPresentWorksOrNot project, I will evaluate the wkhtmltopdf command so that I can generate a PDF file which is derived from the Katalon Test Suite execution report as HTML.

I will do

  1. install wkhtmltopdf command into my Mac, just execute it with a sample Report HTML to generate a PDF.
  2. write a TestListener code, which will automate executing wkhtmltopdf at the end of a TestSuite execution
  3. work out miscellaneous things to make the PDF useful.
kazurayam commented 1 year ago

I installed wkhtmltopdf by

$ brew install wkhtmltopdf

This just worked.

kazurayam commented 1 year ago
$ cd ~/katalon-workspace/waitForElementNotPresentWorksOrNot/Reports/20230827_101110/TS1/20230827_101110
$ wkhtmltopdf 20230827_101110.html 20230827_101110.pdf
Loading pages (1/6)
Counting pages (2/6)                                               
Resolving links (4/6)                                                       
Loading headers and footers (5/6)                                           
Printing pages (6/6)
Done  

I got this PDF file.

20230827_101110.pdf

This looks just nice.

But regretfully enough, the divs are collapsed. I need to find out a way to show all the collapsed divs before converting the page into PDF. Possibly I can find a way to inject a javascript to do the job. The html may accept an URL parameter to show the divs.

kazurayam commented 1 year ago

The HTML report has the following anchor

<a class="expand" title="Expand this suite fully" href="javascript:expandAllChildren('s1')" onclick="stopPropagation(event)">Expand All</a>

By clicking this, you can expand all divs. or by executing expandAllChildren('s1') as well.