@warnyin/n8n-nodes-code-playwright 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/README.md +239 -0
- package/dist/nodes/index.d.ts +1 -0
- package/dist/nodes/index.js +6 -0
- package/dist/nodes/index.js.map +1 -0
- package/dist/nodes/playwright/Playwright.node.d.ts +5 -0
- package/dist/nodes/playwright/Playwright.node.js +284 -0
- package/dist/nodes/playwright/Playwright.node.js.map +1 -0
- package/dist/nodes/playwright/Playwright.node.json +16 -0
- package/dist/nodes/playwright/config.d.ts +9 -0
- package/dist/nodes/playwright/config.js +14 -0
- package/dist/nodes/playwright/config.js.map +1 -0
- package/dist/nodes/playwright/operations.d.ts +3 -0
- package/dist/nodes/playwright/operations.js +60 -0
- package/dist/nodes/playwright/operations.js.map +1 -0
- package/dist/nodes/playwright/playwright.svg +8 -0
- package/dist/nodes/playwright/types.d.ts +27 -0
- package/dist/nodes/playwright/types.js +3 -0
- package/dist/nodes/playwright/types.js.map +1 -0
- package/dist/nodes/playwright/utils.d.ts +21 -0
- package/dist/nodes/playwright/utils.js +48 -0
- package/dist/nodes/playwright/utils.js.map +1 -0
- package/dist/nodes/scripts/setup-browsers.d.ts +2 -0
- package/dist/nodes/scripts/setup-browsers.js +86 -0
- package/dist/nodes/scripts/setup-browsers.js.map +1 -0
- package/dist/nodes/scripts/test-setup.d.ts +1 -0
- package/dist/nodes/scripts/test-setup.js +20 -0
- package/dist/nodes/scripts/test-setup.js.map +1 -0
- package/dist/package.json +76 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +76 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 warnyin
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
# @warnyin/n8n-nodes-code-playwright
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@warnyin/n8n-nodes-code-playwright)
|
|
4
|
+
[](https://www.npmjs.com/package/@warnyin/n8n-nodes-code-playwright)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
|
|
7
|
+
> n8n community node for browser automation using Playwright.
|
|
8
|
+
|
|
9
|
+
**Package:** `@warnyin/n8n-nodes-code-playwright`
|
|
10
|
+
|
|
11
|
+

|
|
12
|
+
|
|
13
|
+
## Table of Contents
|
|
14
|
+
|
|
15
|
+
- [About](#about)
|
|
16
|
+
- [Key Features](#key-features)
|
|
17
|
+
- [Installation](#installation)
|
|
18
|
+
- [Usage](#usage)
|
|
19
|
+
- [Operations](#operations)
|
|
20
|
+
- [Examples](#examples)
|
|
21
|
+
- [Notes & Limitations](#notes--limitations)
|
|
22
|
+
- [Development](#development)
|
|
23
|
+
- [License](#license)
|
|
24
|
+
|
|
25
|
+
## About
|
|
26
|
+
|
|
27
|
+
This n8n community node provides browser automation capabilities using [Playwright](https://playwright.dev/). It allows you to automate web browsers (Chromium, Firefox, WebKit) directly within your n8n workflows.
|
|
28
|
+
|
|
29
|
+
## Key Features
|
|
30
|
+
|
|
31
|
+
- **Multi-browser support**: Chromium, Firefox, and WebKit
|
|
32
|
+
- **Headless or headful mode**: Run browsers visibly or in the background
|
|
33
|
+
- **Screenshot capture**: Take full-page or element screenshots
|
|
34
|
+
- **Form automation**: Fill forms and click elements
|
|
35
|
+
- **Text extraction**: Get text content from web pages
|
|
36
|
+
- **JavaScript evaluation**: Execute custom JS code in page context
|
|
37
|
+
- **Wait for elements**: Wait for selectors before proceeding
|
|
38
|
+
|
|
39
|
+
## Installation
|
|
40
|
+
|
|
41
|
+
### Option 1: Community Nodes (Recommended)
|
|
42
|
+
|
|
43
|
+
1. Open n8n and go to `Settings → Community Nodes`
|
|
44
|
+
2. Click `Install`
|
|
45
|
+
3. Enter: `@warnyin/n8n-nodes-code-playwright`
|
|
46
|
+
4. Accept the risks and install
|
|
47
|
+
|
|
48
|
+
### Option 2: Manual Installation
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
cd ~/.n8n/nodes
|
|
52
|
+
npm install @warnyin/n8n-nodes-code-playwright
|
|
53
|
+
# Restart n8n
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Option 3: Local Development & Linking
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# Clone, install, and build
|
|
60
|
+
git clone https://github.com/warnyin/n8n-nodes-code-playwright.git
|
|
61
|
+
cd n8n-nodes-code-playwright
|
|
62
|
+
pnpm install
|
|
63
|
+
pnpm build
|
|
64
|
+
|
|
65
|
+
# Link to n8n
|
|
66
|
+
npm link
|
|
67
|
+
cd ~/.n8n
|
|
68
|
+
npm link @warnyin/n8n-nodes-code-playwright
|
|
69
|
+
# Restart n8n
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Usage
|
|
73
|
+
|
|
74
|
+
### Basic Parameters
|
|
75
|
+
|
|
76
|
+
| Parameter | Description |
|
|
77
|
+
|-----------|-------------|
|
|
78
|
+
| **Operation** | The browser action to perform |
|
|
79
|
+
| **URL** | The webpage URL to navigate to |
|
|
80
|
+
| **Browser** | Browser engine: Chromium, Firefox, or WebKit |
|
|
81
|
+
| **Browser Options** | Headless mode, slow motion settings |
|
|
82
|
+
|
|
83
|
+
### Operations
|
|
84
|
+
|
|
85
|
+
#### Navigate
|
|
86
|
+
Navigate to a URL and return the page content.
|
|
87
|
+
|
|
88
|
+
#### Take Screenshot
|
|
89
|
+
Capture a screenshot of the webpage.
|
|
90
|
+
- **Full Page**: Capture entire scrollable page
|
|
91
|
+
- **Property Name**: Binary property name for the screenshot
|
|
92
|
+
|
|
93
|
+
#### Get Text
|
|
94
|
+
Extract text content from an element using CSS selector.
|
|
95
|
+
|
|
96
|
+
#### Click Element
|
|
97
|
+
Click on an element specified by CSS selector.
|
|
98
|
+
|
|
99
|
+
#### Fill Form
|
|
100
|
+
Fill a form field with a specified value.
|
|
101
|
+
|
|
102
|
+
#### Wait for Selector
|
|
103
|
+
Wait for an element to appear on the page.
|
|
104
|
+
|
|
105
|
+
#### Evaluate Code
|
|
106
|
+
Execute custom JavaScript code in the page context.
|
|
107
|
+
|
|
108
|
+
## Examples
|
|
109
|
+
|
|
110
|
+
### Example 1: Take a Screenshot
|
|
111
|
+
|
|
112
|
+
```json
|
|
113
|
+
{
|
|
114
|
+
"operation": "takeScreenshot",
|
|
115
|
+
"url": "https://example.com",
|
|
116
|
+
"browser": "chromium",
|
|
117
|
+
"screenshotOptions": {
|
|
118
|
+
"fullPage": true
|
|
119
|
+
},
|
|
120
|
+
"dataPropertyName": "screenshot"
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Example 2: Fill and Submit a Form
|
|
125
|
+
|
|
126
|
+
```json
|
|
127
|
+
{
|
|
128
|
+
"operation": "fillForm",
|
|
129
|
+
"url": "https://example.com/login",
|
|
130
|
+
"selector": "#username",
|
|
131
|
+
"value": "myuser",
|
|
132
|
+
"browser": "chromium"
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Example 3: Extract Text
|
|
137
|
+
|
|
138
|
+
```json
|
|
139
|
+
{
|
|
140
|
+
"operation": "getText",
|
|
141
|
+
"url": "https://example.com",
|
|
142
|
+
"selector": "h1",
|
|
143
|
+
"browser": "chromium"
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Example 4: Execute JavaScript
|
|
148
|
+
|
|
149
|
+
```json
|
|
150
|
+
{
|
|
151
|
+
"operation": "evaluate",
|
|
152
|
+
"url": "https://example.com",
|
|
153
|
+
"code": "return document.title;",
|
|
154
|
+
"browser": "chromium"
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Notes & Limitations
|
|
159
|
+
|
|
160
|
+
- **Browser Installation**: Browsers are automatically installed during package installation
|
|
161
|
+
- **Resource Usage**: Running browsers consumes significant memory
|
|
162
|
+
- **Headless Recommended**: Use headless mode in production environments
|
|
163
|
+
- **Timeout**: Default timeout for operations is 30 seconds
|
|
164
|
+
- **Network**: Requires network access for navigation
|
|
165
|
+
|
|
166
|
+
## Troubleshooting
|
|
167
|
+
|
|
168
|
+
### Browser not found error
|
|
169
|
+
|
|
170
|
+
If you encounter "Browser not found" errors, try running the setup script manually:
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
cd ~/.n8n/nodes/node_modules/@warnyin/n8n-nodes-code-playwright
|
|
174
|
+
npm run setup
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Permission issues on Linux
|
|
178
|
+
|
|
179
|
+
On Linux systems, you may need to install additional dependencies:
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
npx playwright install-deps
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Memory issues
|
|
186
|
+
|
|
187
|
+
If n8n crashes due to memory issues when using Playwright:
|
|
188
|
+
|
|
189
|
+
1. Ensure `headless: true` is enabled
|
|
190
|
+
2. Close browser contexts properly
|
|
191
|
+
3. Consider increasing n8n's memory allocation
|
|
192
|
+
|
|
193
|
+
## Development
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
# Install dependencies
|
|
197
|
+
pnpm install
|
|
198
|
+
|
|
199
|
+
# Build
|
|
200
|
+
pnpm build
|
|
201
|
+
|
|
202
|
+
# Watch mode
|
|
203
|
+
pnpm dev
|
|
204
|
+
|
|
205
|
+
# Setup browsers manually
|
|
206
|
+
pnpm setup
|
|
207
|
+
|
|
208
|
+
# Lint code
|
|
209
|
+
pnpm lint
|
|
210
|
+
|
|
211
|
+
# Fix lint issues
|
|
212
|
+
pnpm lintfix
|
|
213
|
+
|
|
214
|
+
# Format code
|
|
215
|
+
pnpm format
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## Changelog
|
|
219
|
+
|
|
220
|
+
See [CHANGELOG.md](CHANGELOG.md) for release notes.
|
|
221
|
+
|
|
222
|
+
## License
|
|
223
|
+
|
|
224
|
+
MIT License — see [LICENSE.md](LICENSE.md).
|
|
225
|
+
|
|
226
|
+
## Author
|
|
227
|
+
|
|
228
|
+
**warnyin** - [GitHub](https://github.com/warnyin)
|
|
229
|
+
|
|
230
|
+
## References
|
|
231
|
+
|
|
232
|
+
- [Playwright Documentation](https://playwright.dev/docs/intro)
|
|
233
|
+
- [n8n Community Nodes](https://docs.n8n.io/integrations/community-nodes/)
|
|
234
|
+
- [@warnyin/n8n-nodes-code-plus](https://www.npmjs.com/package/@warnyin/n8n-nodes-code-plus)
|
|
235
|
+
- [@warnyin/n8n-nodes-swagger-api](https://www.npmjs.com/package/@warnyin/n8n-nodes-swagger-api)
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
Made with ❤️ for the n8n community
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Playwright } from './playwright/Playwright.node';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Playwright = void 0;
|
|
4
|
+
var Playwright_node_1 = require("./playwright/Playwright.node");
|
|
5
|
+
Object.defineProperty(exports, "Playwright", { enumerable: true, get: function () { return Playwright_node_1.Playwright; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../nodes/index.ts"],"names":[],"mappings":";;;AAAA,gEAA0D;AAAjD,6GAAA,UAAU,OAAA"}
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Playwright = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const os_1 = require("os");
|
|
6
|
+
const utils_1 = require("./utils");
|
|
7
|
+
const operations_1 = require("./operations");
|
|
8
|
+
const setup_browsers_1 = require("../scripts/setup-browsers");
|
|
9
|
+
class Playwright {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.description = {
|
|
12
|
+
displayName: 'Playwright',
|
|
13
|
+
name: 'playwright',
|
|
14
|
+
icon: 'file:playwright.svg',
|
|
15
|
+
group: ['transform'],
|
|
16
|
+
version: 1,
|
|
17
|
+
subtitle: '={{$parameter["operation"]}}',
|
|
18
|
+
description: 'Automate browser actions using Playwright',
|
|
19
|
+
defaults: {
|
|
20
|
+
name: 'Playwright',
|
|
21
|
+
},
|
|
22
|
+
inputs: ['main'],
|
|
23
|
+
outputs: ['main'],
|
|
24
|
+
properties: [
|
|
25
|
+
{
|
|
26
|
+
displayName: 'Operation',
|
|
27
|
+
name: 'operation',
|
|
28
|
+
type: 'options',
|
|
29
|
+
noDataExpression: true,
|
|
30
|
+
options: [
|
|
31
|
+
{
|
|
32
|
+
name: 'Navigate',
|
|
33
|
+
value: 'navigate',
|
|
34
|
+
description: 'Navigate to a URL',
|
|
35
|
+
action: 'Navigate to a URL',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: 'Take Screenshot',
|
|
39
|
+
value: 'takeScreenshot',
|
|
40
|
+
description: 'Take a screenshot of a webpage',
|
|
41
|
+
action: 'Take a screenshot of a webpage',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'Get Text',
|
|
45
|
+
value: 'getText',
|
|
46
|
+
description: 'Get text from an element',
|
|
47
|
+
action: 'Get text from an element',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: 'Click Element',
|
|
51
|
+
value: 'clickElement',
|
|
52
|
+
description: 'Click on an element',
|
|
53
|
+
action: 'Click on an element',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: 'Fill Form',
|
|
57
|
+
value: 'fillForm',
|
|
58
|
+
description: 'Fill a form field',
|
|
59
|
+
action: 'Fill a form field',
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: 'Wait for Selector',
|
|
63
|
+
value: 'waitForSelector',
|
|
64
|
+
description: 'Wait for an element to appear',
|
|
65
|
+
action: 'Wait for an element to appear',
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: 'Evaluate Code',
|
|
69
|
+
value: 'evaluate',
|
|
70
|
+
description: 'Execute JavaScript code in the page context',
|
|
71
|
+
action: 'Execute JavaScript code in the page context',
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
default: 'navigate',
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
displayName: 'URL',
|
|
78
|
+
name: 'url',
|
|
79
|
+
type: 'string',
|
|
80
|
+
default: '',
|
|
81
|
+
placeholder: 'https://example.com',
|
|
82
|
+
description: 'The URL to navigate to',
|
|
83
|
+
displayOptions: {
|
|
84
|
+
show: {
|
|
85
|
+
operation: ['navigate', 'takeScreenshot', 'getText', 'clickElement', 'fillForm', 'waitForSelector', 'evaluate'],
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
required: true,
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
displayName: 'Property Name',
|
|
92
|
+
name: 'dataPropertyName',
|
|
93
|
+
type: 'string',
|
|
94
|
+
required: true,
|
|
95
|
+
default: 'screenshot',
|
|
96
|
+
description: 'Name of the binary property in which to store the screenshot data',
|
|
97
|
+
displayOptions: {
|
|
98
|
+
show: {
|
|
99
|
+
operation: ['takeScreenshot'],
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
displayName: 'Selector',
|
|
105
|
+
name: 'selector',
|
|
106
|
+
type: 'string',
|
|
107
|
+
default: '',
|
|
108
|
+
placeholder: '#submit-button',
|
|
109
|
+
description: 'CSS selector for the element',
|
|
110
|
+
displayOptions: {
|
|
111
|
+
show: {
|
|
112
|
+
operation: ['getText', 'clickElement', 'fillForm', 'waitForSelector'],
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
required: true,
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
displayName: 'Value',
|
|
119
|
+
name: 'value',
|
|
120
|
+
type: 'string',
|
|
121
|
+
default: '',
|
|
122
|
+
description: 'Value to fill in the form field',
|
|
123
|
+
displayOptions: {
|
|
124
|
+
show: {
|
|
125
|
+
operation: ['fillForm'],
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
required: true,
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
displayName: 'JavaScript Code',
|
|
132
|
+
name: 'code',
|
|
133
|
+
type: 'string',
|
|
134
|
+
typeOptions: {
|
|
135
|
+
rows: 5,
|
|
136
|
+
},
|
|
137
|
+
default: 'return document.title;',
|
|
138
|
+
description: 'JavaScript code to execute in the page context',
|
|
139
|
+
displayOptions: {
|
|
140
|
+
show: {
|
|
141
|
+
operation: ['evaluate'],
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
required: true,
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
displayName: 'Timeout',
|
|
148
|
+
name: 'timeout',
|
|
149
|
+
type: 'number',
|
|
150
|
+
default: 30000,
|
|
151
|
+
description: 'Maximum time in milliseconds to wait for the selector',
|
|
152
|
+
displayOptions: {
|
|
153
|
+
show: {
|
|
154
|
+
operation: ['waitForSelector'],
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
displayName: 'Browser',
|
|
160
|
+
name: 'browser',
|
|
161
|
+
type: 'options',
|
|
162
|
+
options: [
|
|
163
|
+
{
|
|
164
|
+
name: 'Chromium',
|
|
165
|
+
value: 'chromium',
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
name: 'Firefox',
|
|
169
|
+
value: 'firefox',
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
name: 'Webkit',
|
|
173
|
+
value: 'webkit',
|
|
174
|
+
},
|
|
175
|
+
],
|
|
176
|
+
default: 'chromium',
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
displayName: 'Browser Launch Options',
|
|
180
|
+
name: 'browserOptions',
|
|
181
|
+
type: 'collection',
|
|
182
|
+
placeholder: 'Add Option',
|
|
183
|
+
default: {},
|
|
184
|
+
options: [
|
|
185
|
+
{
|
|
186
|
+
displayName: 'Headless',
|
|
187
|
+
name: 'headless',
|
|
188
|
+
type: 'boolean',
|
|
189
|
+
default: true,
|
|
190
|
+
description: 'Whether to run browser in headless mode',
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
displayName: 'Slow Motion',
|
|
194
|
+
name: 'slowMo',
|
|
195
|
+
type: 'number',
|
|
196
|
+
default: 0,
|
|
197
|
+
description: 'Slows down operations by the specified amount of milliseconds',
|
|
198
|
+
},
|
|
199
|
+
],
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
displayName: 'Screenshot Options',
|
|
203
|
+
name: 'screenshotOptions',
|
|
204
|
+
type: 'collection',
|
|
205
|
+
placeholder: 'Add Option',
|
|
206
|
+
default: {},
|
|
207
|
+
displayOptions: {
|
|
208
|
+
show: {
|
|
209
|
+
operation: ['takeScreenshot'],
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
options: [
|
|
213
|
+
{
|
|
214
|
+
displayName: 'Full Page',
|
|
215
|
+
name: 'fullPage',
|
|
216
|
+
type: 'boolean',
|
|
217
|
+
default: false,
|
|
218
|
+
description: 'Whether to take a screenshot of the full scrollable page',
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
displayName: 'Path',
|
|
222
|
+
name: 'path',
|
|
223
|
+
type: 'string',
|
|
224
|
+
default: '',
|
|
225
|
+
description: 'The file path to save the screenshot to',
|
|
226
|
+
},
|
|
227
|
+
],
|
|
228
|
+
},
|
|
229
|
+
],
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
async execute() {
|
|
233
|
+
const items = this.getInputData();
|
|
234
|
+
const returnData = [];
|
|
235
|
+
for (let i = 0; i < items.length; i++) {
|
|
236
|
+
const operation = this.getNodeParameter('operation', i);
|
|
237
|
+
const url = this.getNodeParameter('url', i);
|
|
238
|
+
const browserType = this.getNodeParameter('browser', i);
|
|
239
|
+
const browserOptions = this.getNodeParameter('browserOptions', i);
|
|
240
|
+
try {
|
|
241
|
+
const playwright = require('playwright');
|
|
242
|
+
const browsersPath = (0, path_1.join)(__dirname, '..', 'browsers');
|
|
243
|
+
let executablePath;
|
|
244
|
+
try {
|
|
245
|
+
executablePath = (0, utils_1.getBrowserExecutablePath)(browserType, browsersPath);
|
|
246
|
+
}
|
|
247
|
+
catch (error) {
|
|
248
|
+
console.error(`Browser path error: ${error.message}`);
|
|
249
|
+
await (0, setup_browsers_1.installBrowser)(browserType);
|
|
250
|
+
executablePath = (0, utils_1.getBrowserExecutablePath)(browserType, browsersPath);
|
|
251
|
+
}
|
|
252
|
+
console.log(`Launching browser from: ${executablePath}`);
|
|
253
|
+
const browser = await playwright[browserType].launch({
|
|
254
|
+
headless: browserOptions.headless !== false,
|
|
255
|
+
slowMo: browserOptions.slowMo || 0,
|
|
256
|
+
executablePath,
|
|
257
|
+
});
|
|
258
|
+
const context = await browser.newContext();
|
|
259
|
+
const page = await context.newPage();
|
|
260
|
+
await page.goto(url);
|
|
261
|
+
const result = await (0, operations_1.handleOperation)(operation, page, this, i);
|
|
262
|
+
await browser.close();
|
|
263
|
+
returnData.push(result);
|
|
264
|
+
}
|
|
265
|
+
catch (error) {
|
|
266
|
+
console.error(`Browser launch error:`, error);
|
|
267
|
+
if (this.continueOnFail()) {
|
|
268
|
+
returnData.push({
|
|
269
|
+
json: {
|
|
270
|
+
error: error.message,
|
|
271
|
+
browserType,
|
|
272
|
+
os: (0, os_1.platform)(),
|
|
273
|
+
},
|
|
274
|
+
});
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
throw error;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
return [returnData];
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
exports.Playwright = Playwright;
|
|
284
|
+
//# sourceMappingURL=Playwright.node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Playwright.node.js","sourceRoot":"","sources":["../../../nodes/playwright/Playwright.node.ts"],"names":[],"mappings":";;;AAMA,+BAA4B;AAC5B,2BAA8B;AAC9B,mCAAgE;AAChE,6CAA+C;AAE/C,8DAA2D;AAE3D,MAAa,UAAU;IAAvB;QACI,gBAAW,GAAyB;YAChC,WAAW,EAAE,YAAY;YACzB,IAAI,EAAE,YAAY;YAClB,IAAI,EAAE,qBAAqB;YAC3B,KAAK,EAAE,CAAC,WAAW,CAAC;YACpB,OAAO,EAAE,CAAC;YACV,QAAQ,EAAE,8BAA8B;YACxC,WAAW,EAAE,2CAA2C;YACx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,KAAK,EAAE,KAAK,CAAC,OAAO;4BACpB,WAAW;4BACX,EAAE,EAAE,IAAA,aAAQ,GAAE;yBACjB;qBACJ,CAAC,CAAC;oBACH,SAAS;gBACb,CAAC;gBACD,MAAM,KAAK,CAAC;YAChB,CAAC;QACL,CAAC;QAED,OAAO,CAAC,UAAU,CAAC,CAAC;IACxB,CAAC;CACJ;AA5RD,gCA4RC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"node": "n8n-nodes-base.playwright",
|
|
3
|
+
"nodeVersion": "1.0",
|
|
4
|
+
"codexVersion": "1.0",
|
|
5
|
+
"categories": [
|
|
6
|
+
"Development",
|
|
7
|
+
"Automation"
|
|
8
|
+
],
|
|
9
|
+
"resources": {
|
|
10
|
+
"primaryDocumentation": [
|
|
11
|
+
{
|
|
12
|
+
"url": "https://playwright.dev/docs/intro"
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_BROWSER_OPTIONS = exports.BrowserType = void 0;
|
|
4
|
+
var BrowserType;
|
|
5
|
+
(function (BrowserType) {
|
|
6
|
+
BrowserType["Chromium"] = "chromium";
|
|
7
|
+
BrowserType["Firefox"] = "firefox";
|
|
8
|
+
BrowserType["Webkit"] = "webkit";
|
|
9
|
+
})(BrowserType || (exports.BrowserType = BrowserType = {}));
|
|
10
|
+
exports.DEFAULT_BROWSER_OPTIONS = {
|
|
11
|
+
headless: true,
|
|
12
|
+
slowMo: 0,
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../nodes/playwright/config.ts"],"names":[],"mappings":";;;AAAA,IAAY,WAIX;AAJD,WAAY,WAAW;IACnB,oCAAqB,CAAA;IACrB,kCAAmB,CAAA;IACnB,gCAAiB,CAAA;AACrB,CAAC,EAJW,WAAW,2BAAX,WAAW,QAItB;AAEY,QAAA,uBAAuB,GAAG;IACnC,QAAQ,EAAE,IAAI;IACd,MAAM,EAAE,CAAC;CACZ,CAAC"}
|