@warnyin/n8n-nodes-code-playwright
v0.7.0
Published
n8n community node for browser automation using Playwright
Readme
@warnyin/n8n-nodes-code-playwright
n8n community node for browser automation using Playwright.
Package: @warnyin/n8n-nodes-code-playwright
Table of Contents
About
This n8n community node provides browser automation capabilities using Playwright. It allows you to automate web browsers (Chromium, Firefox, WebKit) directly within your n8n workflows.
Key Features
- Multi-browser support: Chromium, Firefox, and WebKit
- Headless or headful mode: Run browsers visibly or in the background
- Screenshot capture: Take full-page or element screenshots
- Form automation: Fill forms and click elements
- Text extraction: Get text content from web pages
- JavaScript evaluation: Execute custom JS code in page context
- Wait for elements: Wait for selectors before proceeding
Installation
Option 1: Community Nodes (Recommended)
- Open n8n and go to
Settings → Community Nodes - Click
Install - Enter:
@warnyin/n8n-nodes-code-playwright - Accept the risks and install
Option 2: Manual Installation
cd ~/.n8n/nodes
npm install @warnyin/n8n-nodes-code-playwright
# Restart n8nOption 3: Docker Installation
For Docker environments, ensure your n8n container has Chrome installed:
# Add this to your n8n Dockerfile
FROM node:18-alpine
RUN apk add --no-cache chromium
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browserOr use the official n8n image with Chrome:
FROM n8nio/n8n
USER root
RUN apt-get update && apt-get install -y \
google-chrome-stable \
&& rm -rf /var/lib/apt/lists/*
USER nodeThen install the node:
docker exec -it <n8n-container> npm install @warnyin/n8n-nodes-code-playwrightOption 4: Local Development & Linking
# Clone, install, and build
git clone https://github.com/warnyin/n8n-nodes-code-playwright.git
cd n8n-nodes-code-playwright
pnpm install
pnpm build
# Link to n8n
npm link
cd ~/.n8n
npm link @warnyin/n8n-nodes-code-playwright
# Restart n8nUsage
Basic Parameters
| Parameter | Description | |-----------|-------------| | Operation | The browser action to perform | | URL | The webpage URL to navigate to | | Browser | Browser engine: Chromium, Firefox, or WebKit | | Browser Options | Headless mode, slow motion settings |
Operations
Navigate
Navigate to a URL and return the page content.
Take Screenshot
Capture a screenshot of the webpage.
- Full Page: Capture entire scrollable page
- Property Name: Binary property name for the screenshot
Get Text
Extract text content from an element using CSS selector.
Click Element
Click on an element specified by CSS selector.
Fill Form
Fill a form field with a specified value.
Wait for Selector
Wait for an element to appear on the page.
Examples
Example 1: Take a Screenshot
{
"operation": "takeScreenshot",
"url": "https://example.com",
"browser": "chromium",
"screenshotOptions": {
"fullPage": true
},
"dataPropertyName": "screenshot"
}Example 2: Fill and Submit a Form
{
"operation": "fillForm",
"url": "https://example.com/login",
"selector": "#username",
"value": "myuser",
"browser": "chromium"
}Example 3: Extract Text
{
"operation": "getText",
"url": "https://example.com",
"selector": "h1",
"browser": "chromium"
}Notes & Limitations
- Browser Installation: Browsers are automatically installed during package installation
- Docker Support: For Linux/Docker environments, the node will automatically fallback to system Chrome if Playwright Chromium fails
- Resource Usage: Running browsers consumes significant memory
- Headless Recommended: Use headless mode in production environments
- Timeout: Default timeout for operations is 30 seconds
- Network: Requires network access for navigation
Troubleshooting
Browser not found error
If you encounter "Browser not found" errors, try running the setup script manually:
cd ~/.n8n/nodes/node_modules/@warnyin/n8n-nodes-code-playwright
npm run setupLinux/Docker GTK/GLib errors
If you see errors like Error relocating chrome: g_object_notify: symbol not found, this means Playwright Chromium requires system dependencies. The node will automatically:
- Try to detect and use system Chrome/Chromium
- Fall back to Playwright Chromium with alternative arguments
- If all fails, you need to install Chrome in your Docker container:
# For Debian/Ubuntu based images
apt-get update && apt-get install -y google-chrome-stable
# For Alpine images
apk add --no-cache chromiumPermission issues on Linux
On Linux systems, you may need to install additional dependencies:
npx playwright install-depsMemory issues
If n8n crashes due to memory issues when using Playwright:
- Ensure
headless: trueis enabled - Close browser contexts properly
- Consider increasing n8n's memory allocation
Development
# Install dependencies
pnpm install
# Build
pnpm build
# Watch mode
pnpm dev
# Setup browsers manually
pnpm setup
# Lint code
pnpm lint
# Fix lint issues
pnpm lintfix
# Format code
pnpm formatChangelog
See CHANGELOG.md for release notes.
License
MIT License — see LICENSE.md.
Author
warnyin - GitHub
References
- Playwright Documentation
- n8n Community Nodes
- @warnyin/n8n-nodes-code-plus
- @warnyin/n8n-nodes-swagger-api
Made with ❤️ for the n8n community
