@brightdata/n8n-nodes-brightdata 1.1.0 → 1.1.1
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/dist/nodes/BrightData/BrightData.node.d.ts +1 -112
- package/dist/nodes/BrightData/BrightData.node.js +0 -500
- package/dist/nodes/BrightData/BrightData.node.js.map +1 -1
- package/dist/nodes/BrightData/SearchFunctions.js +6 -7
- package/dist/nodes/BrightData/SearchFunctions.js.map +1 -1
- package/dist/package.json +2 -5
- package/package.json +2 -5
- package/dist/__tests__/BrightData.node.test.d.ts +0 -1
- package/dist/__tests__/BrightData.node.test.js +0 -21
- package/dist/__tests__/BrightData.node.test.js.map +0 -1
- package/dist/nodes/BrightData/AriaSnapshotFilter.d.ts +0 -13
- package/dist/nodes/BrightData/AriaSnapshotFilter.js +0 -110
- package/dist/nodes/BrightData/AriaSnapshotFilter.js.map +0 -1
- package/dist/nodes/BrightData/BrowserDescription.d.ts +0 -3
- package/dist/nodes/BrightData/BrowserDescription.js +0 -362
- package/dist/nodes/BrightData/BrowserDescription.js.map +0 -1
- package/dist/nodes/BrightData/BrowserFunctions.d.ts +0 -23
- package/dist/nodes/BrightData/BrowserFunctions.js +0 -131
- package/dist/nodes/BrightData/BrowserFunctions.js.map +0 -1
- package/dist/nodes/BrightData/BrowserSession.d.ts +0 -34
- package/dist/nodes/BrightData/BrowserSession.js +0 -291
- package/dist/nodes/BrightData/BrowserSession.js.map +0 -1
- package/dist/nodes/BrightData/GenericFunctions.backup.d.ts +0 -3
- package/dist/nodes/BrightData/GenericFunctions.backup.js +0 -44
- package/dist/nodes/BrightData/GenericFunctions.backup.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
2
2
|
import { getActiveZones, getCountries, getDataSets } from './SearchFunctions';
|
|
3
3
|
export declare class BrightData implements INodeType {
|
|
4
4
|
description: INodeTypeDescription;
|
|
@@ -9,115 +9,4 @@ export declare class BrightData implements INodeType {
|
|
|
9
9
|
getDataSets: typeof getDataSets;
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
|
-
customOperations: {
|
|
13
|
-
browser: {
|
|
14
|
-
navigate: (this: IExecuteFunctions) => Promise<{
|
|
15
|
-
json: {
|
|
16
|
-
message: string;
|
|
17
|
-
title: string;
|
|
18
|
-
url: string;
|
|
19
|
-
};
|
|
20
|
-
}[][]>;
|
|
21
|
-
goBack: (this: IExecuteFunctions) => Promise<{
|
|
22
|
-
json: {
|
|
23
|
-
message: string;
|
|
24
|
-
title: string;
|
|
25
|
-
url: string;
|
|
26
|
-
};
|
|
27
|
-
}[][]>;
|
|
28
|
-
goForward: (this: IExecuteFunctions) => Promise<{
|
|
29
|
-
json: {
|
|
30
|
-
message: string;
|
|
31
|
-
title: string;
|
|
32
|
-
url: string;
|
|
33
|
-
};
|
|
34
|
-
}[][]>;
|
|
35
|
-
scroll: (this: IExecuteFunctions) => Promise<{
|
|
36
|
-
json: {
|
|
37
|
-
message: string;
|
|
38
|
-
};
|
|
39
|
-
}[][]>;
|
|
40
|
-
click: (this: IExecuteFunctions) => Promise<{
|
|
41
|
-
json: {
|
|
42
|
-
message: string;
|
|
43
|
-
ref: string | undefined;
|
|
44
|
-
selector: string | undefined;
|
|
45
|
-
};
|
|
46
|
-
}[][]>;
|
|
47
|
-
type: (this: IExecuteFunctions) => Promise<{
|
|
48
|
-
json: {
|
|
49
|
-
message: string;
|
|
50
|
-
submitted: boolean;
|
|
51
|
-
ref: string | undefined;
|
|
52
|
-
selector: string | undefined;
|
|
53
|
-
};
|
|
54
|
-
}[][]>;
|
|
55
|
-
scrollToElement: (this: IExecuteFunctions) => Promise<{
|
|
56
|
-
json: {
|
|
57
|
-
message: string;
|
|
58
|
-
ref: string | undefined;
|
|
59
|
-
selector: string | undefined;
|
|
60
|
-
};
|
|
61
|
-
}[][]>;
|
|
62
|
-
waitForElement: (this: IExecuteFunctions) => Promise<{
|
|
63
|
-
json: {
|
|
64
|
-
message: string;
|
|
65
|
-
timeout: number;
|
|
66
|
-
ref: string | undefined;
|
|
67
|
-
selector: string | undefined;
|
|
68
|
-
};
|
|
69
|
-
}[][]>;
|
|
70
|
-
screenshot: (this: IExecuteFunctions) => Promise<{
|
|
71
|
-
json: {
|
|
72
|
-
message: string;
|
|
73
|
-
fullPage: boolean;
|
|
74
|
-
};
|
|
75
|
-
binary: {
|
|
76
|
-
screenshot: import("n8n-workflow").IBinaryData;
|
|
77
|
-
};
|
|
78
|
-
}[][]>;
|
|
79
|
-
getHtml: (this: IExecuteFunctions) => Promise<{
|
|
80
|
-
json: {
|
|
81
|
-
html: string;
|
|
82
|
-
fullPage: boolean;
|
|
83
|
-
};
|
|
84
|
-
}[][]>;
|
|
85
|
-
getText: (this: IExecuteFunctions) => Promise<{
|
|
86
|
-
json: {
|
|
87
|
-
text: any;
|
|
88
|
-
};
|
|
89
|
-
}[][]>;
|
|
90
|
-
getSnapshot: (this: IExecuteFunctions) => Promise<{
|
|
91
|
-
json: {
|
|
92
|
-
url: string;
|
|
93
|
-
title: string;
|
|
94
|
-
ariaSnapshot: string;
|
|
95
|
-
domSnapshot?: string | null;
|
|
96
|
-
};
|
|
97
|
-
}[][]>;
|
|
98
|
-
fillForm: (this: IExecuteFunctions) => Promise<{
|
|
99
|
-
json: {
|
|
100
|
-
message: string;
|
|
101
|
-
results: string[];
|
|
102
|
-
};
|
|
103
|
-
}[][]>;
|
|
104
|
-
getNetworkRequests: (this: IExecuteFunctions) => Promise<{
|
|
105
|
-
json: {
|
|
106
|
-
total: number;
|
|
107
|
-
requests: {
|
|
108
|
-
method: string;
|
|
109
|
-
url: string;
|
|
110
|
-
status?: number;
|
|
111
|
-
statusText?: string;
|
|
112
|
-
}[];
|
|
113
|
-
};
|
|
114
|
-
}[][]>;
|
|
115
|
-
closeSession: (this: IExecuteFunctions) => Promise<{
|
|
116
|
-
json: {
|
|
117
|
-
message: string;
|
|
118
|
-
sessionId: string;
|
|
119
|
-
};
|
|
120
|
-
}[][]>;
|
|
121
|
-
};
|
|
122
|
-
};
|
|
123
12
|
}
|
|
@@ -5,22 +5,7 @@ const n8n_workflow_1 = require("n8n-workflow");
|
|
|
5
5
|
const WebUnlockerDescription_1 = require("./WebUnlockerDescription");
|
|
6
6
|
const MarketplaceDatasetDescription_1 = require("./MarketplaceDatasetDescription");
|
|
7
7
|
const WebScrapperDescription_1 = require("./WebScrapperDescription");
|
|
8
|
-
const BrowserDescription_1 = require("./BrowserDescription");
|
|
9
8
|
const SearchFunctions_1 = require("./SearchFunctions");
|
|
10
|
-
const BrowserFunctions_1 = require("./BrowserFunctions");
|
|
11
|
-
const resolveZone = (value) => {
|
|
12
|
-
if (!value) {
|
|
13
|
-
return undefined;
|
|
14
|
-
}
|
|
15
|
-
if (typeof value === 'string') {
|
|
16
|
-
return value;
|
|
17
|
-
}
|
|
18
|
-
if (typeof value === 'object' && value !== null && 'value' in value) {
|
|
19
|
-
const zoneValue = value.value;
|
|
20
|
-
return typeof zoneValue === 'string' ? zoneValue : undefined;
|
|
21
|
-
}
|
|
22
|
-
return undefined;
|
|
23
|
-
};
|
|
24
9
|
class BrightData {
|
|
25
10
|
constructor() {
|
|
26
11
|
this.description = {
|
|
@@ -62,10 +47,6 @@ class BrightData {
|
|
|
62
47
|
name: 'Marketplace Dataset',
|
|
63
48
|
value: 'marketplaceDataset',
|
|
64
49
|
},
|
|
65
|
-
{
|
|
66
|
-
name: 'Browser',
|
|
67
|
-
value: 'browser',
|
|
68
|
-
},
|
|
69
50
|
{
|
|
70
51
|
name: 'Web Scraper',
|
|
71
52
|
value: 'webScrapper',
|
|
@@ -83,8 +64,6 @@ class BrightData {
|
|
|
83
64
|
...MarketplaceDatasetDescription_1.marketplaceDatasetFields,
|
|
84
65
|
...WebScrapperDescription_1.webScrapperOperations,
|
|
85
66
|
...WebScrapperDescription_1.webScrapperFields,
|
|
86
|
-
...BrowserDescription_1.browserOperations,
|
|
87
|
-
...BrowserDescription_1.browserFields,
|
|
88
67
|
],
|
|
89
68
|
};
|
|
90
69
|
this.methods = {
|
|
@@ -94,485 +73,6 @@ class BrightData {
|
|
|
94
73
|
getDataSets: SearchFunctions_1.getDataSets,
|
|
95
74
|
},
|
|
96
75
|
};
|
|
97
|
-
this.customOperations = {
|
|
98
|
-
browser: {
|
|
99
|
-
navigate: async function () {
|
|
100
|
-
const items = this.getInputData();
|
|
101
|
-
const returnData = [];
|
|
102
|
-
for (let i = 0; i < items.length; i++) {
|
|
103
|
-
const url = this.getNodeParameter('url', i);
|
|
104
|
-
const countryRaw = this.getNodeParameter('country', i) || '';
|
|
105
|
-
const country = countryRaw.trim() ? countryRaw.trim() : undefined;
|
|
106
|
-
const sessionId = this.getNodeParameter('sessionId', i) || undefined;
|
|
107
|
-
const zone = resolveZone(this.getNodeParameter('zone', i)) || (0, BrowserFunctions_1.getDefaultBrowserZone)();
|
|
108
|
-
try {
|
|
109
|
-
const session = await BrowserFunctions_1.getOrCreateBrowserSession.call(this, {
|
|
110
|
-
sessionId,
|
|
111
|
-
zone,
|
|
112
|
-
country,
|
|
113
|
-
});
|
|
114
|
-
const page = await session.getPage({ url });
|
|
115
|
-
await session.clearRequests();
|
|
116
|
-
await page.goto(url, { timeout: 120000, waitUntil: 'domcontentloaded' });
|
|
117
|
-
returnData.push({
|
|
118
|
-
json: {
|
|
119
|
-
message: `Successfully navigated to ${page.url()}`,
|
|
120
|
-
title: await page.title(),
|
|
121
|
-
url: page.url(),
|
|
122
|
-
},
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
catch (error) {
|
|
126
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, { itemIndex: i });
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
return [returnData];
|
|
130
|
-
},
|
|
131
|
-
goBack: async function () {
|
|
132
|
-
const items = this.getInputData();
|
|
133
|
-
const returnData = [];
|
|
134
|
-
for (let i = 0; i < items.length; i++) {
|
|
135
|
-
const sessionId = this.getNodeParameter('sessionId', i) || undefined;
|
|
136
|
-
const zone = resolveZone(this.getNodeParameter('zone', i)) || (0, BrowserFunctions_1.getDefaultBrowserZone)();
|
|
137
|
-
try {
|
|
138
|
-
const session = await BrowserFunctions_1.getOrCreateBrowserSession.call(this, {
|
|
139
|
-
sessionId,
|
|
140
|
-
zone,
|
|
141
|
-
});
|
|
142
|
-
const page = await session.getPage();
|
|
143
|
-
await page.goBack();
|
|
144
|
-
returnData.push({
|
|
145
|
-
json: {
|
|
146
|
-
message: 'Successfully navigated back',
|
|
147
|
-
title: await page.title(),
|
|
148
|
-
url: page.url(),
|
|
149
|
-
},
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
catch (error) {
|
|
153
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, { itemIndex: i });
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
return [returnData];
|
|
157
|
-
},
|
|
158
|
-
goForward: async function () {
|
|
159
|
-
const items = this.getInputData();
|
|
160
|
-
const returnData = [];
|
|
161
|
-
for (let i = 0; i < items.length; i++) {
|
|
162
|
-
const sessionId = this.getNodeParameter('sessionId', i) || undefined;
|
|
163
|
-
const zone = resolveZone(this.getNodeParameter('zone', i)) || (0, BrowserFunctions_1.getDefaultBrowserZone)();
|
|
164
|
-
try {
|
|
165
|
-
const session = await BrowserFunctions_1.getOrCreateBrowserSession.call(this, {
|
|
166
|
-
sessionId,
|
|
167
|
-
zone,
|
|
168
|
-
});
|
|
169
|
-
const page = await session.getPage();
|
|
170
|
-
await page.goForward();
|
|
171
|
-
returnData.push({
|
|
172
|
-
json: {
|
|
173
|
-
message: 'Successfully navigated forward',
|
|
174
|
-
title: await page.title(),
|
|
175
|
-
url: page.url(),
|
|
176
|
-
},
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
catch (error) {
|
|
180
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, { itemIndex: i });
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
return [returnData];
|
|
184
|
-
},
|
|
185
|
-
scroll: async function () {
|
|
186
|
-
const items = this.getInputData();
|
|
187
|
-
const returnData = [];
|
|
188
|
-
for (let i = 0; i < items.length; i++) {
|
|
189
|
-
const sessionId = this.getNodeParameter('sessionId', i) || undefined;
|
|
190
|
-
const zone = resolveZone(this.getNodeParameter('zone', i)) || (0, BrowserFunctions_1.getDefaultBrowserZone)();
|
|
191
|
-
try {
|
|
192
|
-
const session = await BrowserFunctions_1.getOrCreateBrowserSession.call(this, {
|
|
193
|
-
sessionId,
|
|
194
|
-
zone,
|
|
195
|
-
});
|
|
196
|
-
const page = await session.getPage();
|
|
197
|
-
await page.evaluate(() => {
|
|
198
|
-
const win = globalThis.window;
|
|
199
|
-
const doc = globalThis.document;
|
|
200
|
-
win.scrollTo(0, doc.body.scrollHeight);
|
|
201
|
-
});
|
|
202
|
-
returnData.push({
|
|
203
|
-
json: {
|
|
204
|
-
message: 'Successfully scrolled to the bottom of the page',
|
|
205
|
-
},
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
catch (error) {
|
|
209
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, { itemIndex: i });
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
return [returnData];
|
|
213
|
-
},
|
|
214
|
-
click: async function () {
|
|
215
|
-
const items = this.getInputData();
|
|
216
|
-
const returnData = [];
|
|
217
|
-
for (let i = 0; i < items.length; i++) {
|
|
218
|
-
const element = this.getNodeParameter('element', i);
|
|
219
|
-
const ref = this.getNodeParameter('ref', i) || '';
|
|
220
|
-
const selector = this.getNodeParameter('selector', i) || '';
|
|
221
|
-
const sessionId = this.getNodeParameter('sessionId', i) || undefined;
|
|
222
|
-
const zone = resolveZone(this.getNodeParameter('zone', i)) || (0, BrowserFunctions_1.getDefaultBrowserZone)();
|
|
223
|
-
try {
|
|
224
|
-
const session = await BrowserFunctions_1.getOrCreateBrowserSession.call(this, {
|
|
225
|
-
sessionId,
|
|
226
|
-
zone,
|
|
227
|
-
});
|
|
228
|
-
const locator = await session.getLocator({
|
|
229
|
-
element,
|
|
230
|
-
ref: ref.trim() ? ref.trim() : undefined,
|
|
231
|
-
selector: selector.trim() ? selector.trim() : undefined,
|
|
232
|
-
});
|
|
233
|
-
await locator.click({ timeout: 5000 });
|
|
234
|
-
returnData.push({
|
|
235
|
-
json: {
|
|
236
|
-
message: `Successfully clicked element: ${element}`,
|
|
237
|
-
ref: ref.trim() || undefined,
|
|
238
|
-
selector: selector.trim() || undefined,
|
|
239
|
-
},
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
catch (error) {
|
|
243
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, { itemIndex: i });
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
return [returnData];
|
|
247
|
-
},
|
|
248
|
-
type: async function () {
|
|
249
|
-
const items = this.getInputData();
|
|
250
|
-
const returnData = [];
|
|
251
|
-
for (let i = 0; i < items.length; i++) {
|
|
252
|
-
const element = this.getNodeParameter('element', i);
|
|
253
|
-
const ref = this.getNodeParameter('ref', i) || '';
|
|
254
|
-
const selector = this.getNodeParameter('selector', i) || '';
|
|
255
|
-
const text = this.getNodeParameter('text', i);
|
|
256
|
-
const submit = this.getNodeParameter('submit', i);
|
|
257
|
-
const sessionId = this.getNodeParameter('sessionId', i) || undefined;
|
|
258
|
-
const zone = resolveZone(this.getNodeParameter('zone', i)) || (0, BrowserFunctions_1.getDefaultBrowserZone)();
|
|
259
|
-
try {
|
|
260
|
-
const session = await BrowserFunctions_1.getOrCreateBrowserSession.call(this, {
|
|
261
|
-
sessionId,
|
|
262
|
-
zone,
|
|
263
|
-
});
|
|
264
|
-
const locator = await session.getLocator({
|
|
265
|
-
element,
|
|
266
|
-
ref: ref.trim() ? ref.trim() : undefined,
|
|
267
|
-
selector: selector.trim() ? selector.trim() : undefined,
|
|
268
|
-
});
|
|
269
|
-
await locator.fill(text);
|
|
270
|
-
if (submit) {
|
|
271
|
-
await locator.press('Enter');
|
|
272
|
-
}
|
|
273
|
-
returnData.push({
|
|
274
|
-
json: {
|
|
275
|
-
message: `Successfully typed into element: ${element}`,
|
|
276
|
-
submitted: submit,
|
|
277
|
-
ref: ref.trim() || undefined,
|
|
278
|
-
selector: selector.trim() || undefined,
|
|
279
|
-
},
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
catch (error) {
|
|
283
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, { itemIndex: i });
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
return [returnData];
|
|
287
|
-
},
|
|
288
|
-
scrollToElement: async function () {
|
|
289
|
-
const items = this.getInputData();
|
|
290
|
-
const returnData = [];
|
|
291
|
-
for (let i = 0; i < items.length; i++) {
|
|
292
|
-
const element = this.getNodeParameter('element', i);
|
|
293
|
-
const ref = this.getNodeParameter('ref', i) || '';
|
|
294
|
-
const selector = this.getNodeParameter('selector', i) || '';
|
|
295
|
-
const sessionId = this.getNodeParameter('sessionId', i) || undefined;
|
|
296
|
-
const zone = resolveZone(this.getNodeParameter('zone', i)) || (0, BrowserFunctions_1.getDefaultBrowserZone)();
|
|
297
|
-
try {
|
|
298
|
-
const session = await BrowserFunctions_1.getOrCreateBrowserSession.call(this, {
|
|
299
|
-
sessionId,
|
|
300
|
-
zone,
|
|
301
|
-
});
|
|
302
|
-
const locator = await session.getLocator({
|
|
303
|
-
element,
|
|
304
|
-
ref: ref.trim() ? ref.trim() : undefined,
|
|
305
|
-
selector: selector.trim() ? selector.trim() : undefined,
|
|
306
|
-
});
|
|
307
|
-
await locator.scrollIntoViewIfNeeded();
|
|
308
|
-
returnData.push({
|
|
309
|
-
json: {
|
|
310
|
-
message: `Successfully scrolled to element: ${element}`,
|
|
311
|
-
ref: ref.trim() || undefined,
|
|
312
|
-
selector: selector.trim() || undefined,
|
|
313
|
-
},
|
|
314
|
-
});
|
|
315
|
-
}
|
|
316
|
-
catch (error) {
|
|
317
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, { itemIndex: i });
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
return [returnData];
|
|
321
|
-
},
|
|
322
|
-
waitForElement: async function () {
|
|
323
|
-
const items = this.getInputData();
|
|
324
|
-
const returnData = [];
|
|
325
|
-
for (let i = 0; i < items.length; i++) {
|
|
326
|
-
const element = this.getNodeParameter('element', i);
|
|
327
|
-
const ref = this.getNodeParameter('ref', i) || '';
|
|
328
|
-
const selector = this.getNodeParameter('selector', i) || '';
|
|
329
|
-
const timeout = this.getNodeParameter('timeout', i);
|
|
330
|
-
const sessionId = this.getNodeParameter('sessionId', i) || undefined;
|
|
331
|
-
const zone = resolveZone(this.getNodeParameter('zone', i)) || (0, BrowserFunctions_1.getDefaultBrowserZone)();
|
|
332
|
-
try {
|
|
333
|
-
const session = await BrowserFunctions_1.getOrCreateBrowserSession.call(this, {
|
|
334
|
-
sessionId,
|
|
335
|
-
zone,
|
|
336
|
-
});
|
|
337
|
-
const locator = await session.getLocator({
|
|
338
|
-
element,
|
|
339
|
-
ref: ref.trim() ? ref.trim() : undefined,
|
|
340
|
-
selector: selector.trim() ? selector.trim() : undefined,
|
|
341
|
-
});
|
|
342
|
-
await locator.waitFor({ timeout: timeout || 30000 });
|
|
343
|
-
returnData.push({
|
|
344
|
-
json: {
|
|
345
|
-
message: `Successfully waited for element: ${element}`,
|
|
346
|
-
timeout: timeout || 30000,
|
|
347
|
-
ref: ref.trim() || undefined,
|
|
348
|
-
selector: selector.trim() || undefined,
|
|
349
|
-
},
|
|
350
|
-
});
|
|
351
|
-
}
|
|
352
|
-
catch (error) {
|
|
353
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, { itemIndex: i });
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
return [returnData];
|
|
357
|
-
},
|
|
358
|
-
screenshot: async function () {
|
|
359
|
-
const items = this.getInputData();
|
|
360
|
-
const returnData = [];
|
|
361
|
-
for (let i = 0; i < items.length; i++) {
|
|
362
|
-
const fullPage = this.getNodeParameter('full_page', i);
|
|
363
|
-
const sessionId = this.getNodeParameter('sessionId', i) || undefined;
|
|
364
|
-
const zone = resolveZone(this.getNodeParameter('zone', i)) || (0, BrowserFunctions_1.getDefaultBrowserZone)();
|
|
365
|
-
try {
|
|
366
|
-
const session = await BrowserFunctions_1.getOrCreateBrowserSession.call(this, {
|
|
367
|
-
sessionId,
|
|
368
|
-
zone,
|
|
369
|
-
});
|
|
370
|
-
const page = await session.getPage();
|
|
371
|
-
const buffer = await page.screenshot({ fullPage });
|
|
372
|
-
const binaryPropertyName = 'screenshot';
|
|
373
|
-
const binaryData = await this.helpers.prepareBinaryData(buffer, 'screenshot.png', 'image/png');
|
|
374
|
-
returnData.push({
|
|
375
|
-
json: {
|
|
376
|
-
message: 'Screenshot captured',
|
|
377
|
-
fullPage,
|
|
378
|
-
},
|
|
379
|
-
binary: {
|
|
380
|
-
[binaryPropertyName]: binaryData,
|
|
381
|
-
},
|
|
382
|
-
});
|
|
383
|
-
}
|
|
384
|
-
catch (error) {
|
|
385
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, { itemIndex: i });
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
return [returnData];
|
|
389
|
-
},
|
|
390
|
-
getHtml: async function () {
|
|
391
|
-
const items = this.getInputData();
|
|
392
|
-
const returnData = [];
|
|
393
|
-
for (let i = 0; i < items.length; i++) {
|
|
394
|
-
const fullPage = this.getNodeParameter('full_page', i);
|
|
395
|
-
const sessionId = this.getNodeParameter('sessionId', i) || undefined;
|
|
396
|
-
const zone = resolveZone(this.getNodeParameter('zone', i)) || (0, BrowserFunctions_1.getDefaultBrowserZone)();
|
|
397
|
-
try {
|
|
398
|
-
const session = await BrowserFunctions_1.getOrCreateBrowserSession.call(this, {
|
|
399
|
-
sessionId,
|
|
400
|
-
zone,
|
|
401
|
-
});
|
|
402
|
-
const page = await session.getPage();
|
|
403
|
-
let html = '';
|
|
404
|
-
if (!fullPage) {
|
|
405
|
-
html = await page.$eval('body', (body) => body.innerHTML);
|
|
406
|
-
}
|
|
407
|
-
else {
|
|
408
|
-
html = await page.content();
|
|
409
|
-
}
|
|
410
|
-
returnData.push({
|
|
411
|
-
json: {
|
|
412
|
-
html,
|
|
413
|
-
fullPage,
|
|
414
|
-
},
|
|
415
|
-
});
|
|
416
|
-
}
|
|
417
|
-
catch (error) {
|
|
418
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, { itemIndex: i });
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
return [returnData];
|
|
422
|
-
},
|
|
423
|
-
getText: async function () {
|
|
424
|
-
const items = this.getInputData();
|
|
425
|
-
const returnData = [];
|
|
426
|
-
for (let i = 0; i < items.length; i++) {
|
|
427
|
-
const sessionId = this.getNodeParameter('sessionId', i) || undefined;
|
|
428
|
-
const zone = resolveZone(this.getNodeParameter('zone', i)) || (0, BrowserFunctions_1.getDefaultBrowserZone)();
|
|
429
|
-
try {
|
|
430
|
-
const session = await BrowserFunctions_1.getOrCreateBrowserSession.call(this, {
|
|
431
|
-
sessionId,
|
|
432
|
-
zone,
|
|
433
|
-
});
|
|
434
|
-
const page = await session.getPage();
|
|
435
|
-
const text = await page.$eval('body', (body) => body.innerText);
|
|
436
|
-
returnData.push({
|
|
437
|
-
json: {
|
|
438
|
-
text,
|
|
439
|
-
},
|
|
440
|
-
});
|
|
441
|
-
}
|
|
442
|
-
catch (error) {
|
|
443
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, { itemIndex: i });
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
return [returnData];
|
|
447
|
-
},
|
|
448
|
-
getSnapshot: async function () {
|
|
449
|
-
const items = this.getInputData();
|
|
450
|
-
const returnData = [];
|
|
451
|
-
for (let i = 0; i < items.length; i++) {
|
|
452
|
-
const filtered = this.getNodeParameter('filtered', i);
|
|
453
|
-
const sessionId = this.getNodeParameter('sessionId', i) || undefined;
|
|
454
|
-
const zone = resolveZone(this.getNodeParameter('zone', i)) || (0, BrowserFunctions_1.getDefaultBrowserZone)();
|
|
455
|
-
try {
|
|
456
|
-
const session = await BrowserFunctions_1.getOrCreateBrowserSession.call(this, {
|
|
457
|
-
sessionId,
|
|
458
|
-
zone,
|
|
459
|
-
});
|
|
460
|
-
const snapshot = await session.captureSnapshot({ filtered });
|
|
461
|
-
returnData.push({
|
|
462
|
-
json: snapshot,
|
|
463
|
-
});
|
|
464
|
-
}
|
|
465
|
-
catch (error) {
|
|
466
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, { itemIndex: i });
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
return [returnData];
|
|
470
|
-
},
|
|
471
|
-
fillForm: async function () {
|
|
472
|
-
const items = this.getInputData();
|
|
473
|
-
const returnData = [];
|
|
474
|
-
for (let i = 0; i < items.length; i++) {
|
|
475
|
-
const fieldsParam = this.getNodeParameter('fields', i);
|
|
476
|
-
const fields = (fieldsParam === null || fieldsParam === void 0 ? void 0 : fieldsParam.field) || [];
|
|
477
|
-
const sessionId = this.getNodeParameter('sessionId', i) || undefined;
|
|
478
|
-
const zone = resolveZone(this.getNodeParameter('zone', i)) || (0, BrowserFunctions_1.getDefaultBrowserZone)();
|
|
479
|
-
try {
|
|
480
|
-
const session = await BrowserFunctions_1.getOrCreateBrowserSession.call(this, {
|
|
481
|
-
sessionId,
|
|
482
|
-
zone,
|
|
483
|
-
});
|
|
484
|
-
const results = [];
|
|
485
|
-
for (const field of fields) {
|
|
486
|
-
const locator = await session.getLocator({
|
|
487
|
-
element: field.name,
|
|
488
|
-
ref: field.ref,
|
|
489
|
-
});
|
|
490
|
-
if (field.type === 'textbox' || field.type === 'slider') {
|
|
491
|
-
await locator.fill(field.value);
|
|
492
|
-
results.push(`Filled ${field.name} with "${field.value}"`);
|
|
493
|
-
}
|
|
494
|
-
else if (field.type === 'checkbox' || field.type === 'radio') {
|
|
495
|
-
const checked = field.value === 'true';
|
|
496
|
-
await locator.setChecked(checked);
|
|
497
|
-
results.push(`Set ${field.name} to ${checked ? 'checked' : 'unchecked'}`);
|
|
498
|
-
}
|
|
499
|
-
else if (field.type === 'combobox') {
|
|
500
|
-
await locator.selectOption({ label: field.value });
|
|
501
|
-
results.push(`Selected "${field.value}" in ${field.name}`);
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
returnData.push({
|
|
505
|
-
json: {
|
|
506
|
-
message: 'Successfully filled form',
|
|
507
|
-
results,
|
|
508
|
-
},
|
|
509
|
-
});
|
|
510
|
-
}
|
|
511
|
-
catch (error) {
|
|
512
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, { itemIndex: i });
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
return [returnData];
|
|
516
|
-
},
|
|
517
|
-
getNetworkRequests: async function () {
|
|
518
|
-
const items = this.getInputData();
|
|
519
|
-
const returnData = [];
|
|
520
|
-
for (let i = 0; i < items.length; i++) {
|
|
521
|
-
const sessionId = this.getNodeParameter('sessionId', i) || undefined;
|
|
522
|
-
const zone = resolveZone(this.getNodeParameter('zone', i)) || (0, BrowserFunctions_1.getDefaultBrowserZone)();
|
|
523
|
-
try {
|
|
524
|
-
const session = await BrowserFunctions_1.getOrCreateBrowserSession.call(this, {
|
|
525
|
-
sessionId,
|
|
526
|
-
zone,
|
|
527
|
-
});
|
|
528
|
-
const requests = await session.getRequests();
|
|
529
|
-
const results = [];
|
|
530
|
-
requests.forEach((response, request) => {
|
|
531
|
-
const result = {
|
|
532
|
-
method: request.method().toUpperCase(),
|
|
533
|
-
url: request.url(),
|
|
534
|
-
};
|
|
535
|
-
if (response) {
|
|
536
|
-
result.status = response.status();
|
|
537
|
-
result.statusText = response.statusText();
|
|
538
|
-
}
|
|
539
|
-
results.push(result);
|
|
540
|
-
});
|
|
541
|
-
returnData.push({
|
|
542
|
-
json: {
|
|
543
|
-
total: results.length,
|
|
544
|
-
requests: results,
|
|
545
|
-
},
|
|
546
|
-
});
|
|
547
|
-
}
|
|
548
|
-
catch (error) {
|
|
549
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, { itemIndex: i });
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
return [returnData];
|
|
553
|
-
},
|
|
554
|
-
closeSession: async function () {
|
|
555
|
-
const items = this.getInputData();
|
|
556
|
-
const returnData = [];
|
|
557
|
-
for (let i = 0; i < items.length; i++) {
|
|
558
|
-
const sessionId = this.getNodeParameter('sessionId', i) || 'default';
|
|
559
|
-
try {
|
|
560
|
-
await BrowserFunctions_1.closeBrowserSession.call(this, sessionId);
|
|
561
|
-
returnData.push({
|
|
562
|
-
json: {
|
|
563
|
-
message: `Closed browser session ${sessionId}`,
|
|
564
|
-
sessionId,
|
|
565
|
-
},
|
|
566
|
-
});
|
|
567
|
-
}
|
|
568
|
-
catch (error) {
|
|
569
|
-
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, { itemIndex: i });
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
return [returnData];
|
|
573
|
-
},
|
|
574
|
-
},
|
|
575
|
-
};
|
|
576
76
|
}
|
|
577
77
|
}
|
|
578
78
|
exports.BrightData = BrightData;
|