kazurayam / waitForElementNotPresentWorksOrNot

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

want to expandAllChildren('s') by modifying the HTML source of the report #2

Open kazurayam opened 1 year ago

kazurayam commented 1 year ago

https://github.com/kazurayam/waitForElementNotPresentWorksOrNot/blob/expandAllChidlren/Keywords/com/kazurayam/ks/reporting/TestSuiteReportConverter.groovy

I want to expand all closed div nodes in the Report html. I thought I would be able to execute javascript and call expandAllChildren('s1') via wkhtmltopdf, as follows

        Subprocess.CompletedProcess cp;
        cp = new Subprocess().cwd(reportFolder.toFile())
                .run(Arrays.asList(
                "/usr/local/bin/wkhtmltopdf",
                "--debug-javascript",
                "--run-script", "console.log('starting')",
                "--run-script", "document.querySelector('h1').textContent = 'Hello'",
                "--run-script", "expandAllChildren('s1')",
                "--run-script", "console.log('finished')",
                "--javascript-delay", "1000",
                htmlFileName, pdfFileName));

The wkhtmltopdf command passed with RTN=0. But the div nodes remains closed. As the resulting PDF shows.

スクリーンショット 2023-08-29 12 26 52
kazurayam commented 1 year ago

The --run-script option of the wkhtmltopdf is hard to use. It is difficult to debug. It is difficult to diagnoze what's going on.

kazurayam commented 1 year ago

I have an alternative idea. I can scan the HTML source and edit it while I would turn <div> nodes from "closed" to "opened".

kazurayam commented 1 year ago

How do I want to edit the HTML source?

Input

<div id="s1" class="suite">
  <div class="element-header closed" onclick=...
    ...
  </div>
<div class="children populated" style="display: none;">
  ...

Output

<div id="s1" class="suite">
  <div class="element-header" onclick=...
    ...
  </div>
<div class="children populated" style="display: block;">
  ...

Change

I need to perform 2 patterns of code change:

  1. class="xxxx closed" -> class="xxxx"
  2. style="display: none;" -> style="display: block;"
kazurayam commented 1 year ago

I tried a bit of editing HTML source.

No, it's very bad approach. Too fragile.