playwright-automation

Community Playwright integration for n8n. Run reliable headless browser automations (scraping, form filling, login flows, PDF/screenshots, E2E checks) powered by Playwright — directly inside n8n workflows.

Package Information

Downloads: 22 weekly / 37 monthly
Latest Version: 0.5.1
Author: Shhadi Masarwa

Documentation

n8n-nodes-playwright-automation Logo

n8n-nodes-playwright-automation

Community Playwright integration for n8n.
Run reliable headless browser automations (scraping, form filling, login flows, PDF/screenshots, E2E checks) powered by Playwright — directly inside n8n workflows.

npm version Build Status License


🚀 Features

This node allows you to control a headless browser to automate complex web tasks.

Session

Operation Description
Create Start a new browser session (Chromium/Firefox/WebKit)
Close Close an active session
Get Storage State Retrieve cookies and storage state (e.g., to save and reuse login sessions)

Page Interaction

Operation Description
Navigate Go to a specific URL
Click Click elements using smart selectors
Type/Fill Fill forms and input fields
Wait Wait for a specific duration or for elements to appear
Get Text/HTML/Attribute Extract data from the page
Count Elements Count occurrences of an element
Upload File Upload files to input fields

Capture

Operation Description
Screenshot Capture visible page or full page screenshots
PDF Generate a PDF of the current page

Script (Advanced)

Operation Description
Run Script Execute custom JavaScript code with full Playwright API access

📜 Custom Script Feature

For advanced automation scenarios where predefined operations aren't sufficient, you can run custom Playwright scripts.

How It Works

The Script → Run Script operation allows you to write JavaScript code that has direct access to:

Example Usage

// Get page information
const title = await page.title();
const url = page.url();

// Interact with elements
await page.click('button.submit');
await page.fill('#email', 'user@example.com');

// Wait for network requests
await page.waitForResponse(resp => resp.url().includes('/api/'));

// Extract data
const items = await page.$$eval('.product', els => 
  els.map(el => ({
    name: el.querySelector('.name').textContent,
    price: el.querySelector('.price').textContent
  }))
);

// Return data to the n8n workflow
return { title, url, items };

Output

The script's return value is included in the node output:

{
  "success": true,
  "action": "runScript",
  "returnValue": {
    "title": "Example Shop",
    "url": "https://example.com/products",
    "items": [ ]
  },
  "executionTimeMs": 142
}

[!TIP]
Use custom scripts for complex scenarios like multi-step login flows, infinite scroll handling, or interacting with dynamic SPAs.


📦 Installation

n8n Community Nodes

  1. Go to SettingsCommunity Nodes
  2. Select Install
  3. Enter n8n-nodes-playwright-automation
  4. Agree to the risks and select Install

The node will automatically download the required browser binaries the first time you execute it.

[!IMPORTANT]
Linux Users (Docker/Self-hosted):

We strongly recommend using our Docker setup to avoid any issues.
It uses the official Playwright image which comes pre-loaded with all required system libraries and browsers.

If you choose to use a different or custom n8n image, you MUST ensure your environment has all Playwright system dependencies installed (e.g., libnspr4, libnss3, libgbm1). The node will not work without these libraries.

Using custom Docker image?
We strongly recommend basing your image on the official Playwright image:

FROM mcr.microsoft.com/playwright:v1.58.0-noble

Manual Installation

If you prefer to install manually:

cd ~/.n8n/nodes
npm install n8n-nodes-playwright-automation

🐳 Docker Support

[!TIP]
Why use our Docker setup?

Our Docker image is pre-configured with all the necessary system dependencies and libraries required for Playwright to run correctly.

If you use a different n8n image, you will likely run into issues unless you manually install all the required libraries for headless browsers.

To run this node in Docker, we provide a docker-compose.yml file that:

  1. Installs all required Playwright browser dependencies
  2. Mounts the built node code into n8n
  3. Persists n8n data

Quick Start (Development Mode)

This project includes a Docker setup optimized for development, running npm run dev inside a Node.js container with all Playwright dependencies pre-installed.

  1. Start the Development Container:
    Using Docker directly:

    docker compose up -d --build
    

    Alternative (Shorthand):

    npm run dev:docker
    

    This will build the image, install dependencies, and start n8n in development watch mode.

  2. Access n8n:
    Open http://localhost:5678 in your browser.

  3. Development:
    The source code is mounted into the container. Changes to the code will automatically trigger a rebuild/restart of the node (handled by n8n-node dev).

Configuration

The provided docker-compose.yml uses a custom Dockerfile based on the official Playwright Docker image (mcr.microsoft.com/playwright:v1.58.0-noble).
This ensures Node.js 22, all system dependencies, and required browsers are pre-installed and optimized.


🛠️ Development

Prerequisites

Getting Started

# Clone the repository
git clone https://github.com/shhadi/n8n-nodes-playwright-automation.git
cd n8n-nodes-playwright-automation

# Install dependencies
npm install

# Start development server
npm run dev

Available Scripts

Script Description
npm run dev Start n8n with your node and watch for changes
npm run build Compile TypeScript to JavaScript for production
npm run lint Check your code for errors and style issues
npm run lint:fix Automatically fix linting issues when possible

🤝 Contributing

Contributions are welcome! We'd love to have you help improve this project.

Please read our Contributing Guidelines to get started. This guide includes:

  • Development setup instructions
  • How to submit pull requests
  • Coding standards and best practices
  • Reporting issues

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.


✨ Contributors

Contributors

👨‍💻 Maintainer

Shhadi Masarwa

A human who’s a dad and an engineer who loves making things work better.

Email LinkedIn GitHub


Discussion