npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

n8n-nodes-playwright-enhanced

v1.3.9

Published

n8n-community-node-package for browser automation using Playwright with persistent browser session support

Readme

n8n-nodes-playwright-enhanced

An n8n community node for browser automation using Playwright — with persistent browser session support. Create named browser profiles, log in to services once, and reuse the authenticated session across any workflow.

Installation What's Different Operations Persistent Browser Workflow Custom Scripts Compatibility Troubleshooting


Installation

In your n8n instance go to Settings → Community Nodes → Install and enter:

n8n-nodes-playwright-enhanced

The package will automatically download and set up the required browser binaries during installation (~1GB disk space required).


What's Different

This package adds persistent named browser profiles on top of standard Playwright automation. The key problem it solves: logging in to a service once and reusing that session across multiple workflows, without re-authenticating every time.

New Operations

  • Create Persistent Browser — Launch a named browser server that stays running between workflow executions
  • List Persistent Browsers — View all named browsers and their status (online/offline)
  • Destroy Persistent Browser — Shut down a named browser and remove it from the registry

Session Persistence

When using Run Custom Script in Persistent mode:

  • On first run: the browser context is fresh
  • After the script completes: cookies, localStorage, and session data are automatically saved to the browser's profile directory (~/.n8n/browser-profiles/<name>/storage-state.json)
  • On every subsequent run: the saved session is automatically restored — no login required

Auto-Recovery

If a persistent browser server crashes or the EC2 instance restarts, it will automatically relaunch the next time a workflow tries to connect to it, restoring the same profile and session.

New Script Variable

Custom scripts now have access to $context (the Playwright BrowserContext) in addition to the existing $page, $browser, and $playwright variables.


Operations

Standard Operations

  • Navigate — Go to a URL and return page content
  • Take Screenshot — Capture a screenshot (full page or viewport)
  • Get Text — Extract text from an element using CSS selector or XPath
  • Click Element — Click an element using CSS selector or XPath
  • Fill Form — Fill a form field using CSS selector or XPath
  • Run Custom Script — Execute custom JavaScript with full Playwright API access

Browser Options

  • Chromium, Firefox, or WebKit
  • Headless mode toggle
  • Slow motion (ms delay between operations)

Selector Options

  • CSS Selector — e.g. #submit-button, .my-class, button[type="submit"]
  • XPath — e.g. //button[@id="submit"], //div[contains(@class, "content")]

Persistent Browser Workflow

Step 1 — Create a named browser (once)

Add a Playwright node and set:

  • OperationCreate Persistent Browser
  • Browser Namemy-session (any name you choose)
  • BrowserChromium
  • Port0 (auto-assign)

Run it once. The browser server starts and is registered.

Step 2 — Log in (once)

Add another Playwright node:

  • OperationRun Custom Script
  • Browser ModePersistent — Connect to Named Browser
  • Persistent Browser → select my-session
await $page.goto('https://your-service.com/login');
await $page.fill('#email', '[email protected]');
await $page.fill('#password', 'yourpassword');
await $page.click('button[type="submit"]');
await $page.waitForURL('**/dashboard');

// Session state (cookies, localStorage) is automatically saved after this script exits
return [{ json: { status: 'logged in' } }];

Run it once. The session is saved to the browser profile.

Step 3 — Use the session in any workflow

// No login needed — session is automatically restored from the profile
await $page.goto('https://your-service.com/protected-page');

const data = await $page.textContent('.some-element');
return [{ json: { data } }];

Multiple Profiles

You can create as many named browsers as you need, each with its own isolated session:

| Browser Name | Purpose | |---|---| | shopify-prod | Shopify production account | | shopify-staging | Shopify staging account | | google-workspace | Google account |


Custom Scripts

Available Variables

| Variable | Description | |---|---| | $page | Current Playwright Page instance | | $browser | Browser instance | | $context | BrowserContext instance (persistent mode only) | | $playwright | Playwright library | | $helpers | n8n helpers including prepareBinaryData | | $json | Current item's JSON data | | $input | Input data from previous nodes |

Script Examples

Take a Screenshot

await $page.goto('https://example.com');
const screenshot = await $page.screenshot({ type: 'png', fullPage: true });

return [{
    json: { url: $page.url() },
    binary: {
        screenshot: await $helpers.prepareBinaryData(
            Buffer.from(screenshot), 'screenshot.png', 'image/png'
        )
    }
}];

Scrape Data

await $page.goto('https://example.com/products');
await $page.waitForSelector('.product-item');

const products = await $page.$$eval('.product-item', items =>
    items.map(item => ({
        name: item.querySelector('.product-name')?.textContent,
        price: item.querySelector('.product-price')?.textContent,
    }))
);

return products.map(p => ({ json: p }));

Generate a PDF

await $page.goto('https://example.com/report');
const pdf = await $page.pdf({ format: 'A4', printBackground: true });

return [{
    json: { url: $page.url() },
    binary: {
        pdf: await $helpers.prepareBinaryData(Buffer.from(pdf), 'report.pdf', 'application/pdf')
    }
}];

Wait for Dynamic Content

await $page.goto('https://example.com');
await $page.waitForLoadState('networkidle');
await $page.waitForSelector('.dynamic-content', { timeout: 10000 });

const content = await $page.textContent('.dynamic-content');
return [{ json: { content } }];

Script Tips

  1. Always return an arrayreturn [{ json: {...} }];
  2. Use console.log() — output appears in the n8n UI during manual execution
  3. Always use await — all Playwright operations are async
  4. In persistent mode$browser.close() disconnects without killing the server

Compatibility

  • Requires n8n 1.0.0 or later
  • Playwright 1.49.0
  • Node.js 18.10 or later
  • Supports Linux, macOS, and Windows
  • ~1GB disk space for browser binaries

Troubleshooting

Browsers Not Installed

node node_modules/n8n-nodes-playwright-persistent/dist/nodes/scripts/setup-browsers.js

Script Errors

  1. Ensure your script returns an array: return [{ json: {...} }];
  2. Use console.log() to debug
  3. Wrap code in try/catch for better error messages
  4. Verify all Playwright operations use await

Element Not Found

  1. Try XPath instead of CSS (or vice versa)
  2. Wait for the element: await $page.waitForSelector('.my-element')
  3. Check for iframes: await $page.frameLocator('iframe').locator('.element')
  4. Wait for page load: await $page.waitForLoadState('networkidle')

Session Not Persisting

  • Make sure you are using Persistent browser mode in Run Custom Script
  • The session saves automatically after the script exits — no extra code needed
  • Check that ~/.n8n/browser-profiles/<name>/storage-state.json exists after the first login run

License

MIT