@auto-wiz/puppeteer 1.1.0 → 1.2.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/runner.d.ts +4 -0
- package/dist/runner.js +15 -9
- package/package.json +3 -3
package/dist/runner.d.ts
CHANGED
|
@@ -3,6 +3,10 @@ import { Page } from "puppeteer";
|
|
|
3
3
|
export declare class PuppeteerFlowRunner implements FlowRunner<Page> {
|
|
4
4
|
run(flow: Flow, page: Page, options?: RunnerOptions): Promise<RunResult>;
|
|
5
5
|
runStep(step: Step, page: Page, options?: RunnerOptions): Promise<ExecutionResult>;
|
|
6
|
+
/**
|
|
7
|
+
* Resolve placeholders in text (e.g., {{username}} → variables.username)
|
|
8
|
+
*/
|
|
9
|
+
private resolveText;
|
|
6
10
|
private getSelector;
|
|
7
11
|
private getElement;
|
|
8
12
|
}
|
package/dist/runner.js
CHANGED
|
@@ -48,7 +48,8 @@ class PuppeteerFlowRunner {
|
|
|
48
48
|
}
|
|
49
49
|
case "type": {
|
|
50
50
|
const el = await this.getElement(page, step, timeout);
|
|
51
|
-
const
|
|
51
|
+
const rawText = step.text || step.originalText || "";
|
|
52
|
+
const text = this.resolveText(rawText, options.variables);
|
|
52
53
|
await el.type(text);
|
|
53
54
|
if (step.submit) {
|
|
54
55
|
await page.keyboard.press("Enter");
|
|
@@ -73,7 +74,7 @@ class PuppeteerFlowRunner {
|
|
|
73
74
|
return { success: true, extractedData: text?.trim() };
|
|
74
75
|
}
|
|
75
76
|
case "waitFor": {
|
|
76
|
-
if (step.
|
|
77
|
+
if (step.locator) {
|
|
77
78
|
const selector = this.getSelector(step);
|
|
78
79
|
await page.waitForSelector(selector, {
|
|
79
80
|
visible: true,
|
|
@@ -92,15 +93,20 @@ class PuppeteerFlowRunner {
|
|
|
92
93
|
return { success: false, error: error.message };
|
|
93
94
|
}
|
|
94
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Resolve placeholders in text (e.g., {{username}} → variables.username)
|
|
98
|
+
*/
|
|
99
|
+
resolveText(text, variables) {
|
|
100
|
+
if (!variables || !text)
|
|
101
|
+
return text;
|
|
102
|
+
return text.replace(/\{\{(\w+)\}\}/g, (_, key) => variables[key] ?? "");
|
|
103
|
+
}
|
|
95
104
|
getSelector(step) {
|
|
96
|
-
if ("locator" in step
|
|
97
|
-
|
|
98
|
-
return primary;
|
|
99
|
-
}
|
|
100
|
-
if ("selector" in step && step.selector) {
|
|
101
|
-
return step.selector;
|
|
105
|
+
if (!("locator" in step) || !step.locator) {
|
|
106
|
+
throw new Error(`Step ${step.type} requires a locator`);
|
|
102
107
|
}
|
|
103
|
-
|
|
108
|
+
const { primary } = step.locator;
|
|
109
|
+
return primary;
|
|
104
110
|
}
|
|
105
111
|
async getElement(page, step, timeout) {
|
|
106
112
|
const selector = this.getSelector(step);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@auto-wiz/puppeteer",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "JaeSang",
|
|
6
6
|
"repository": {
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"@auto-wiz/core": "^1.
|
|
26
|
+
"@auto-wiz/core": "^1.2.0"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"puppeteer": "^23.0.0"
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"typescript": "^5.0.0",
|
|
33
33
|
"@types/node": "^20.0.0",
|
|
34
|
-
"@auto-wiz/core": "1.1
|
|
34
|
+
"@auto-wiz/core": "1.2.1"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"build": "tsc"
|