How to use Puppeteer

First, you need to add "puppeteer" in config.capabilities of your template:

class Template implements OpenSubmitterTemplateProtocol {
  config: TemplateConfig = {
    // Based on this setting, OpenSubmitter will inject Puppeteer's page object into this template
    capabilities: ['puppeteer'],
    // other settings here
  const page = null; // dummy property for your IDE

OpenSubmitter replaces page property in your template with Puppeteer's Page object. It does that by inheriting your template and overriding your template's properties. Just for your information, this is the exact code how it does that:

this.browser = await this.puppeteer.launch(this.getPuppeteerOptions()); = await this.browser.newPage();
Full source code for reference is here.

Note that for launch option it uses result of getPuppeteerOptions function. This function checks if your template class has getPuppeteerArguments method and uses them if it does. If not, OpenSubmitter's default Puppeteer arguments are used. This method is useful if you want, for example, use a proxy:

getPuppeteerArguments(): string[] {
    return [

If you do use a proxy and it requires authorization, don't forget to provide login and password before navigating:

    username: "login",
    password: "password",

So right in the runTask method you may use Page object as you'd do in your usual Puppeteer script:

async runTask(task: TemplateTask) {

    // Navigate to a website:
    await"", {
    waitUntil: "networkidle0",
    timeout: 30000 //value in milliseconds

    // Get focus to a text input and type in text there:
    const someInput = await$('#css-selector-here')
    await someInput.focus();
    await'#css-selector-here', "my text")

    // Click on a link and wait for navigation to complete
    await Promise.all(["a-link-css-here"),{ waitUntil: 'networkidle0' }),

    // Set a Recaptcha V2 token to its textarea
    await (recaptchaResponse) => {
            document.getElementsByName('g-captcha-response')[0].value = recaptchaResponse;
    }, recaptchaResponse);

    // Intercept requests and extract or manipulate headers:
    await;'request', (request) => {
        //abort to replace with out version of this file
        if (request.url().indexOf('some/address') !== -1) {

            // extracting headers
            const headers = request.headers();

            // adding new header
            headers['New-header'] = 'New header value';

            // continue with new header
            request.continue({ headers });

            // or abort the request at all


Things you may want to do before navigating to a website:

async runTask(task: TemplateTask) {
    // Set an User-Agent
    await"----Custom user agent here----");

    // Remove webdriver flag
    await => {
        delete navigator.__proto__.webdriver;

    // Navigate
    // await"")


If you didn't find a Chromium page manipulation method here, just google it at Stackoverflow or use ChatGPT for help. A possible query to ChatGPT may look like this:

I'm writing a script in TypeScript which uses Puppeteer for browser automation. How do I [write your query here]?