Skip to content

Implement Webdriver#88

Open
TheSyscall wants to merge 63 commits intomainfrom
webdriver
Open

Implement Webdriver#88
TheSyscall wants to merge 63 commits intomainfrom
webdriver

Conversation

@TheSyscall
Copy link
Copy Markdown

@TheSyscall TheSyscall commented Mar 13, 2026

Changes

  • Removed ReactPHP dependency
    The module no longer relies on ReactPHP, as such it no longer provides the asynchronous methods to generate PDFs that were never part of the Hook

  • Introduced backend abstraction
    A new backend concept allows different rendering strategies to be plugged in and extended more easily.

  • Added WebDriver support
    Implemented a WebDriver-based backend with support for Chrome and Firefox.

  • Automatic backend fallback
    If a backend fails or is unavailable, the system now automatically falls back to the next available option. (The order of this is currently hardcoded as Webdriver > Remote Chrome > Local Chrome)

  • New configuration form
    Replaced the existing configuration with a new ipl\Web\Compat\Form-based ConfigForm.

requires Icinga/icingaweb2#5480
requires Icinga/ipl-web#358
requires Icinga/icingaweb2#5491

related to Icinga/icingaweb2-module-reporting#275

WebDriver

This module can be configured to connect to a webdriver instance. (Backend)

When a PDF is requested, via the Print PDF button on any site or the one in the reporting module, it sends commands to the WebDriver server in a standardized format.

Each browser has its own driver (like ChromeDriver for Chrome or GeckoDriver for Firefox).
This driver acts as a bridge between your script and the browser.

Browser
The driver sends commands to the browser, which executes them just like a user interaction.

For this to work we require a working chromedriver or geckodriver (firefox) instance.

Adding this this to a docker compose file will spin up one for each of the supported webdrivers.

  selenium-chrome:
    image: selenium/standalone-chrome
    container_name: selenium-chrome
    ports:
      - "4444:4444"
    shm_size: '2gb'
    restart: always

  selenium-firefox:
    image: selenium/standalone-firefox
    container_name: selenium-firefox
    ports:
      - "4445:4444"
      - "7900:7900"
    shm_size: '2gb'
    restart: always

Currently supported features:

Backend Generate PDF Layout Plugins Merge PDF (Coverpage) Coverpage Layout Header/Footer
HeadlessChrome Remote (Legacy) Yes Yes Yes Yes Yes
HeadlessChrome Local (Legacy) Yes Yes Yes Yes Yes
Chromedriver Yes Yes Yes No Yes
Geckodriver Yes No No No No

Known issues

  • Firefox seems to generate compressed PDFs and the TCPDF library we use https://github.com/karriereat/pdf-merge seems to not handle the deflate process properly.
  • Chromedriver reports an error with the coverpage properties. Is actually related to a deprecated command.
(
x   [error] => invalid argument
   [message] => invalid argument: params not passed
   (Session info: chrome=145.0.7632.116)
   [stacktrace] => #0 0x55aaccc62b6a <unknown>
#1 0x55aacc675a32 <unknown>
#2 0x55aacc71fcee <unknown>
#3 0x55aacc713369 <unknown>
#4 0x55aacc6bcc0f <unknown>
#5 0x55aacc6bd9d1 <unknown>
#6 0x55aaccc276b9 <unknown>
#7 0x55aaccc2a5c1 <unknown>
#8 0x55aaccc13e29 <unknown>
#9 0x55aaccc2b17e <unknown>
#10 0x55aaccbfa4b0 <unknown>
#11 0x55aaccc4f578 <unknown>
#12 0x55aaccc4f74b <unknown>
#13 0x55aaccc611a3 <unknown>
#14 0x7fc8d9558aa4 <unknown>
#15 0x7fc8d95e5a64 __clone
)

@cla-bot cla-bot Bot added the cla/signed label Mar 13, 2026
@TheSyscall TheSyscall force-pushed the webdriver branch 2 times, most recently from cf3eb8d to 1a6156a Compare March 13, 2026 11:18
@TheSyscall TheSyscall self-assigned this Mar 19, 2026
@TheSyscall TheSyscall marked this pull request as ready for review March 19, 2026 08:26
@TheSyscall TheSyscall requested a review from Al2Klimov March 19, 2026 08:26
Al2Klimov

This comment was marked as resolved.

@TheSyscall
Copy link
Copy Markdown
Author

TheSyscall commented Mar 19, 2026

If you use docker you can just use the two services provided in the PR description.
The only other configuration apart from this is to go to the module's configuration page and add the host + port to the webdriver server.

To test the legacy chrome backend, just follow the existing documentation.

The PdfExport module allows you to create PDFs of any page in IW2, it is also used to create reports with a custom cover page in the reporting module.

Al2Klimov

This comment was marked as resolved.

@TheSyscall
Copy link
Copy Markdown
Author

The master is also affected, so this is not our problem, is it?

It is not. The connection to the user can time out before the PDF is done generating, that seems to be a problem that has always existed, and this PR doesn't change that.

@sukhwinder33445
Copy link
Copy Markdown
Contributor

Please have a look at this comment and the screenshot.

This is only done to provide backward compatibility and can be removed
after we decide to break compatability.
@TheSyscall
Copy link
Copy Markdown
Author

Please have a look at this comment and the screenshot.

This has been addressed in 6861696

'required' => true,
'placeholder' => 100,
'min' => 0,
'description' => $this->translate('The priority of the backend. A lower priority will be used first.'),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ordering seems counter-intuitive to me at first sight.

@flourish86 What do you think?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same order as menu items internally.

To be fair afaik. it is the first time that a user would have to interact with the number directly.

Comment thread library/Pdfexport/ProvidedHook/Pdfexport.php
$this->addContent($table);
}

public function backendAction(): void
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Being able to rename a backend would be nice. See https://github.com/Icinga/icinga-sso-web/pull/3

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would leave that up to Icinga/icingaweb2#5480

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't be necessary if you use random IDs as section keys like https://github.com/Icinga/icinga-sso-web/pull/3.

$this->addContent($table);
}

public function backendAction(): void
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Being able to deactivate a backend temporarily for testing would be nice, but I guess changing priorities will do it as well. You decide.

case 'local_chrome':
$this->addElement('text', 'binary', [
'label' => $this->translate('Binary'),
'placeholder' => '/usr/bin/google-chrome',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On my Fedora, it's sbin. While on it, I'd evaluate whether we can suggest Chromium instead.

Comment thread public/js/activate-scripts.js Outdated
Comment thread library/Pdfexport/ChromeDevTools/ChromeDevTools.php
) {
}

public function execute(Command $command): mixed
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like all variables here can be inlined.

Comment thread library/Pdfexport/WebDriver/ElementPresentCondition.php Outdated
Comment thread library/Pdfexport/Backend/Chromedriver.php Outdated
@Al2Klimov Al2Klimov self-requested a review April 15, 2026 16:03
@Al2Klimov Al2Klimov removed their request for review April 16, 2026 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants