Hi @Frazze I tried adding a code step and added chromium as an npm package and ran a simple code using it and it worked, maybe this problem with the many updates we have rolled out since this post, apologies for the delayed response.
import * as c from 'chromium'
import {execFile} from 'child_process';
export const code = async (inputs) => {
execFile(c.path, ['https://google.com'], err => {
console.log('Hello Google!');
});
return c;
};
import * as c from 'chromium';
import puppeteer from 'puppeteer';
export const code = async (inputs) => {
const browserTest3 = await puppeteer.launch({ executablePath: c.path });
}
This results in the following response:
"Failed to launch the browser process!
(…) Error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory.
I was playing around this but got it somehow get past the previous issue you’re having but it’s complaining about error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory;
Here’s the relevant code when I launch using Playwright.
I haven’t updated the ticket here. We spent a great time figuring this out, but the issue is that Chrome/Firefox requires certain permissions that are dangerous to give. also we have two sand-boxing modes to make it easy to be self hostable, we need a specific configuration for each environment.
TL;DR: We are still looking for a way to introduce it without breaking security best practices. So, we postponed it a little, as this is not straightforward.
For anyone landing here now: you no longer need Chromium inside a Code step. Activepieces has a Browserless piece that does what yann120 described without writing the connect code yourself.
Run Puppeteer Function takes an ES module whose default export receives { page, context } and returns { data, type }, so most existing Puppeteer code moves over with small changes. For the common jobs there are ready actions: Capture Screenshot (PNG, JPEG or WebP, full page, viewport size, wait for a selector, delay) and Generate PDF (from a URL or from a raw HTML string, with paper format, margins and print background).
The connection has a region dropdown for the hosted service plus a Custom Endpoint option, so a self hosted Browserless container like the one on a small droplet works too. Put its base URL there and keep your token.
Each call is a fresh browser session, so pass any values your test needs (login, target URL) through Context rather than expecting state to carry over between steps.