automation_model 1.0.592-dev → 1.0.592-stage
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/README.md +130 -0
- package/lib/api.js +35 -21
- package/lib/api.js.map +1 -1
- package/lib/auto_page.d.ts +4 -2
- package/lib/auto_page.js +136 -8
- package/lib/auto_page.js.map +1 -1
- package/lib/browser_manager.js +53 -16
- package/lib/browser_manager.js.map +1 -1
- package/lib/bruno.d.ts +1 -0
- package/lib/bruno.js +284 -0
- package/lib/bruno.js.map +1 -0
- package/lib/command_common.d.ts +4 -4
- package/lib/command_common.js +47 -16
- package/lib/command_common.js.map +1 -1
- package/lib/error-messages.js +18 -0
- package/lib/error-messages.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/init_browser.d.ts +3 -2
- package/lib/init_browser.js +64 -11
- package/lib/init_browser.js.map +1 -1
- package/lib/locate_element.js +2 -2
- package/lib/locate_element.js.map +1 -1
- package/lib/network.d.ts +1 -1
- package/lib/network.js +5 -5
- package/lib/network.js.map +1 -1
- package/lib/stable_browser.d.ts +22 -4
- package/lib/stable_browser.js +775 -197
- package/lib/stable_browser.js.map +1 -1
- package/lib/table_helper.d.ts +19 -0
- package/lib/table_helper.js +116 -0
- package/lib/table_helper.js.map +1 -0
- package/lib/test_context.d.ts +3 -0
- package/lib/test_context.js +2 -0
- package/lib/test_context.js.map +1 -1
- package/lib/utils.d.ts +9 -3
- package/lib/utils.js +309 -21
- package/lib/utils.js.map +1 -1
- package/package.json +8 -8
package/lib/browser_manager.js
CHANGED
|
@@ -16,9 +16,12 @@ class BrowserManager {
|
|
|
16
16
|
}
|
|
17
17
|
async closeBrowser(browser) {
|
|
18
18
|
if (!browser && this.browsers.length > 0) {
|
|
19
|
-
|
|
19
|
+
for (let i = 0; i < this.browsers.length; i++) {
|
|
20
|
+
await this.browsers[i].close();
|
|
21
|
+
}
|
|
22
|
+
this.browsers = [];
|
|
20
23
|
}
|
|
21
|
-
if (browser) {
|
|
24
|
+
if (browser && !process.env.IGNORE_BROWSER_CLOSE) {
|
|
22
25
|
await browser.close();
|
|
23
26
|
for (let i = 0; i < this.browsers.length; i++) {
|
|
24
27
|
if (this.browsers[i].browser === browser || this.browsers[i] === browser) {
|
|
@@ -67,14 +70,23 @@ class Browser {
|
|
|
67
70
|
let viewport = null;
|
|
68
71
|
if (process.env.HEADLESS === "true") {
|
|
69
72
|
headless = true;
|
|
73
|
+
this.headless = true;
|
|
70
74
|
}
|
|
71
75
|
else if (process.env.HEADLESS === "false") {
|
|
72
76
|
headless = false;
|
|
77
|
+
this.headless = false;
|
|
73
78
|
}
|
|
74
79
|
if (process.env.VIEWPORT) {
|
|
75
80
|
let viewportParts = process.env.VIEWPORT.split(",");
|
|
76
81
|
viewport = { width: parseInt(viewportParts[0]), height: parseInt(viewportParts[1]) };
|
|
77
82
|
}
|
|
83
|
+
else {
|
|
84
|
+
viewport = { width: 1280, height: 800 };
|
|
85
|
+
}
|
|
86
|
+
const args = ["--ignore-https-errors", "--ignore-certificate-errors"];
|
|
87
|
+
if (process.env.CDP_LISTEN_PORT) {
|
|
88
|
+
args.push(`--remote-debugging-port=${process.env.CDP_LISTEN_PORT}`);
|
|
89
|
+
}
|
|
78
90
|
if (!extensionPath && userDataDirPath) {
|
|
79
91
|
this.context = await chromium.launchPersistentContext(userDataDirPath, {
|
|
80
92
|
headless: false,
|
|
@@ -102,7 +114,7 @@ class Browser {
|
|
|
102
114
|
this.browser = await firefox.launch({
|
|
103
115
|
headless: headless,
|
|
104
116
|
timeout: 0,
|
|
105
|
-
args
|
|
117
|
+
args,
|
|
106
118
|
//downloadsPath: downloadsPath,
|
|
107
119
|
});
|
|
108
120
|
}
|
|
@@ -110,7 +122,7 @@ class Browser {
|
|
|
110
122
|
this.browser = await webkit.launch({
|
|
111
123
|
headless: headless,
|
|
112
124
|
timeout: 0,
|
|
113
|
-
args
|
|
125
|
+
args,
|
|
114
126
|
//downloadsPath: downloadsPath,
|
|
115
127
|
});
|
|
116
128
|
}
|
|
@@ -119,19 +131,24 @@ class Browser {
|
|
|
119
131
|
this.browser = await chromium.launch({
|
|
120
132
|
headless: headless,
|
|
121
133
|
timeout: 0,
|
|
122
|
-
args
|
|
134
|
+
args,
|
|
123
135
|
channel: channel,
|
|
124
136
|
//downloadsPath: downloadsPath,
|
|
125
137
|
});
|
|
126
138
|
}
|
|
127
139
|
}
|
|
128
140
|
else {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
141
|
+
if (process.env.CDP_CONNECT_URL) {
|
|
142
|
+
this.browser = await chromium.connectOverCDP(process.env.CDP_CONNECT_URL);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
this.browser = await chromium.launch({
|
|
146
|
+
headless: headless,
|
|
147
|
+
timeout: 0,
|
|
148
|
+
args,
|
|
149
|
+
//downloadsPath: downloadsPath,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
135
152
|
}
|
|
136
153
|
// downloadsPath
|
|
137
154
|
let contextOptions = {};
|
|
@@ -150,11 +167,21 @@ class Browser {
|
|
|
150
167
|
if (viewport) {
|
|
151
168
|
contextOptions.viewport = viewport;
|
|
152
169
|
}
|
|
170
|
+
else {
|
|
171
|
+
if (!this.headless) {
|
|
172
|
+
contextOptions.viewport = null;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
153
175
|
if (userAgent) {
|
|
154
176
|
contextOptions.userAgent = userAgent;
|
|
155
177
|
}
|
|
156
178
|
if (!this.context && this.browser) {
|
|
157
|
-
|
|
179
|
+
if (this.browser.contexts().length > 0) {
|
|
180
|
+
this.context = this.browser.contexts()[this.browser.contexts().length - 1];
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
this.context = await this.browser.newContext(contextOptions);
|
|
184
|
+
}
|
|
158
185
|
}
|
|
159
186
|
}
|
|
160
187
|
if ((process.env.TRACE === "true" || aiConfig.trace === true) && this.context) {
|
|
@@ -204,12 +231,22 @@ class Browser {
|
|
|
204
231
|
await this.context?.addInitScript({
|
|
205
232
|
content: axeMinJsContent,
|
|
206
233
|
});
|
|
207
|
-
this.
|
|
234
|
+
if (this.context && this.context.pages().length > 0) {
|
|
235
|
+
this.page = this.context.pages()[this.context.pages().length - 1];
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
this.page = await this.context.newPage();
|
|
239
|
+
}
|
|
240
|
+
if (this.context) {
|
|
241
|
+
this.context.on("close", () => {
|
|
242
|
+
this.context.isClosed = true;
|
|
243
|
+
});
|
|
244
|
+
}
|
|
208
245
|
}
|
|
209
246
|
async close() {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
247
|
+
if (process.env.IGNORE_BROWSER_CLOSE === "true") {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
213
250
|
if (this.browser !== null) {
|
|
214
251
|
await this.browser.close();
|
|
215
252
|
this.browser = null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser_manager.js","sourceRoot":"","sources":["../../src/browser_manager.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,OAAO,EACP,MAAM,GAKP,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,sCAAsC;AACtC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAM3C,MAAM,cAAc;IACC;IAAnB,YAAmB,WAAsB,EAAE;QAAxB,aAAQ,GAAR,QAAQ,CAAgB;IAAG,CAAC;IAE/C,KAAK,CAAC,QAAQ;QACZ,MAAM,OAAO,CAAC,GAAG,CAAC,I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,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;SACnE;aAAM;YACL,IAAI,CAAC,IAAI,GAAG,MAAM,IAAI,CAAC,OAAQ,CAAC,OAAO,EAAE,CAAC;SAC3C;QACD,IAAI,IAAI,CAAC,OAAO,EAAE;YAChB,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;gBAC3B,IAAI,CAAC,OAAe,CAAC,QAAQ,GAAG,IAAI,CAAC;YACxC,CAAC,CAAC,CAAC;SACJ;IACH,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,OAAO,CAAC,GAAG,CAAC,oBAAoB,KAAK,MAAM,EAAE;YAC/C,OAAO;SACR;QACD,IAAI,IAAI,CAAC,OAAO,KAAK,IAAI,EAAE;YACzB,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YAC3B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;YACpB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;YACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;SAClB;IACH,CAAC;CACF;AACD,MAAM,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC;AAE5C,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
package/lib/bruno.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function executeBrunoRequest(requestName: string, options: any, context: any, world: any): Promise<any[] | undefined>;
|
package/lib/bruno.js
ADDED
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import { spawn } from "child_process";
|
|
4
|
+
import { _commandError, _commandFinally, _preCommand } from "./command_common.js";
|
|
5
|
+
import { Types } from "./stable_browser.js";
|
|
6
|
+
export async function executeBrunoRequest(requestName, options, context, world) {
|
|
7
|
+
if (!options) {
|
|
8
|
+
options = {};
|
|
9
|
+
}
|
|
10
|
+
const state = {
|
|
11
|
+
locate: false,
|
|
12
|
+
scroll: false,
|
|
13
|
+
screenshot: false,
|
|
14
|
+
highlight: false,
|
|
15
|
+
throwError: true,
|
|
16
|
+
operation: "bruno",
|
|
17
|
+
text: "bruno " + requestName,
|
|
18
|
+
_text: "bruno " + requestName,
|
|
19
|
+
options: options,
|
|
20
|
+
type: Types.BRUNO,
|
|
21
|
+
world: world,
|
|
22
|
+
};
|
|
23
|
+
await _preCommand(state, context.web);
|
|
24
|
+
try {
|
|
25
|
+
let brunoFolder = options.brunoFolder || path.join(process.cwd(), "bruno");
|
|
26
|
+
if (!brunoFolder) {
|
|
27
|
+
throw new Error("brunoFolder is not defined, place your bruno folder in the current working directory.");
|
|
28
|
+
}
|
|
29
|
+
// generate a temporary folder .tmp under the project root
|
|
30
|
+
const runtimeFolder = path.join(process.cwd(), ".tmp");
|
|
31
|
+
if (!fs.existsSync(runtimeFolder)) {
|
|
32
|
+
fs.mkdirSync(runtimeFolder);
|
|
33
|
+
}
|
|
34
|
+
// link node_modules to the runtime folder
|
|
35
|
+
const nodeModulesFolder = path.join(process.cwd(), "node_modules");
|
|
36
|
+
if (fs.existsSync(nodeModulesFolder)) {
|
|
37
|
+
// check if the node_modules folder exists
|
|
38
|
+
const runtimeNodeModulesFolder = path.join(runtimeFolder, "node_modules");
|
|
39
|
+
if (!fs.existsSync(runtimeNodeModulesFolder)) {
|
|
40
|
+
// create a symbolic link to the node_modules folder
|
|
41
|
+
fs.symlinkSync(nodeModulesFolder, runtimeNodeModulesFolder, "dir");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// identify the bruno file
|
|
45
|
+
const brunoFile = path.join(brunoFolder, `${requestName}.bru`);
|
|
46
|
+
// check if the bruno file exists
|
|
47
|
+
if (!fs.existsSync(brunoFile)) {
|
|
48
|
+
throw new Error(`Bruno file not found: ${brunoFile}`);
|
|
49
|
+
}
|
|
50
|
+
const brunoConfigFile = path.join(brunoFolder, "bruno.json");
|
|
51
|
+
let brunoConfig = {
|
|
52
|
+
version: "1",
|
|
53
|
+
name: "blinq",
|
|
54
|
+
type: "collection",
|
|
55
|
+
ignore: ["node_modules", ".git"],
|
|
56
|
+
};
|
|
57
|
+
// check if the bruno config file exists and copy it to the runtime folder
|
|
58
|
+
if (fs.existsSync(brunoConfigFile)) {
|
|
59
|
+
// read the bruno config file
|
|
60
|
+
brunoConfig = JSON.parse(fs.readFileSync(brunoConfigFile, "utf-8"));
|
|
61
|
+
if (!brunoConfig.scripts) {
|
|
62
|
+
brunoConfig.scripts = {
|
|
63
|
+
filesystemAccess: {
|
|
64
|
+
allow: true,
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
fs.writeFileSync(path.join(runtimeFolder, "bruno.json"), JSON.stringify(brunoConfig, null, 2));
|
|
70
|
+
let expectRuntime = false;
|
|
71
|
+
// read the bruno file
|
|
72
|
+
let brunoFileContent = fs.readFileSync(brunoFile, "utf-8");
|
|
73
|
+
// populate runtime variables
|
|
74
|
+
brunoFileContent = await context.web._replaceWithLocalData(brunoFileContent, world);
|
|
75
|
+
// inject code to extract runtime variables
|
|
76
|
+
// first find the script:post-response
|
|
77
|
+
const scriptPostResponse = brunoFileContent.indexOf("script:post-response {");
|
|
78
|
+
if (scriptPostResponse !== -1) {
|
|
79
|
+
// need to search a new line follow by }
|
|
80
|
+
// find the end of the script
|
|
81
|
+
const scriptEnd = brunoFileContent.indexOf("\n}", scriptPostResponse);
|
|
82
|
+
// extract the script
|
|
83
|
+
const script = brunoFileContent.substring(scriptPostResponse, scriptEnd + 2);
|
|
84
|
+
// extract all the variables key names: bru.setVar("key", value)
|
|
85
|
+
const regex = /bru\.setVar\("([^"]+)",/g;
|
|
86
|
+
const variables = [];
|
|
87
|
+
let match;
|
|
88
|
+
while ((match = regex.exec(script)) !== null) {
|
|
89
|
+
// check if the variable is already in the list
|
|
90
|
+
if (!variables.includes(match[1])) {
|
|
91
|
+
variables.push(match[1]);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// check if the variables are not empty
|
|
95
|
+
if (variables.length > 0) {
|
|
96
|
+
expectRuntime = true;
|
|
97
|
+
let scriptVariables = "const runtimeVariables = {};\n";
|
|
98
|
+
// iterate over the variables and create a script to extract them
|
|
99
|
+
for (const variable of variables) {
|
|
100
|
+
scriptVariables += ` runtimeVariables["${variable}"] = bru.getVar("${variable}");\n`;
|
|
101
|
+
}
|
|
102
|
+
// check if the variable is not empty
|
|
103
|
+
// replace the script with the modified one
|
|
104
|
+
brunoFileContent = brunoFileContent.replace(script, `script:post-response {
|
|
105
|
+
const fs = require('fs');
|
|
106
|
+
// inject code to extract runtime variables
|
|
107
|
+
${script.substring(script.indexOf("{") + 1, script.lastIndexOf("}"))}
|
|
108
|
+
// write the runtime variables to a file
|
|
109
|
+
${scriptVariables}
|
|
110
|
+
fs.writeFileSync("${path.join(runtimeFolder, "runtime.json")}", JSON.stringify(runtimeVariables, null, 2));
|
|
111
|
+
}`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
// write the bruno file to the runtime folder
|
|
115
|
+
fs.writeFileSync(path.join(runtimeFolder, `${requestName}.bru`), brunoFileContent);
|
|
116
|
+
const outputFile = path.join(runtimeFolder, `bruno_${context.web.stepIndex ? context.web.stepIndex : 0}.json`);
|
|
117
|
+
if (fs.existsSync(outputFile)) {
|
|
118
|
+
// remove the file if it exists
|
|
119
|
+
fs.unlinkSync(outputFile);
|
|
120
|
+
}
|
|
121
|
+
// if the runtime.json file exists, remove it
|
|
122
|
+
const runtimeFile = path.join(runtimeFolder, "runtime.json");
|
|
123
|
+
if (fs.existsSync(runtimeFile)) {
|
|
124
|
+
// remove the file if it exists
|
|
125
|
+
fs.unlinkSync(runtimeFile);
|
|
126
|
+
}
|
|
127
|
+
const commandOptions = {
|
|
128
|
+
cwd: runtimeFolder,
|
|
129
|
+
env: {
|
|
130
|
+
...process.env,
|
|
131
|
+
},
|
|
132
|
+
stdio: "pipe",
|
|
133
|
+
encoding: "utf-8",
|
|
134
|
+
};
|
|
135
|
+
const brunoFilePath = path.join(runtimeFolder, `${requestName}.bru`);
|
|
136
|
+
const args = ["bru", "run", "--reporter-json", outputFile];
|
|
137
|
+
// check if options.brunoArgs is defined
|
|
138
|
+
if (options.brunoArgs) {
|
|
139
|
+
// check if options.brunoArgs is an array
|
|
140
|
+
if (Array.isArray(options.brunoArgs)) {
|
|
141
|
+
// add the args to the command
|
|
142
|
+
args.push(...options.brunoArgs);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
args.push(brunoFilePath);
|
|
146
|
+
const { stdout, stderr } = await runCommand(args, commandOptions);
|
|
147
|
+
// check if the command was successful
|
|
148
|
+
if (!fs.existsSync(outputFile)) {
|
|
149
|
+
if (stderr) {
|
|
150
|
+
console.error(`Error executing Bruno request: ${stderr}`);
|
|
151
|
+
}
|
|
152
|
+
if (stdout) {
|
|
153
|
+
console.log(`Bruno request executed successfully: ${stdout}`);
|
|
154
|
+
}
|
|
155
|
+
throw new Error(`Bruno request failed: ${stderr}`);
|
|
156
|
+
}
|
|
157
|
+
// read the output file
|
|
158
|
+
const result = JSON.parse(fs.readFileSync(outputFile, "utf-8"));
|
|
159
|
+
if (world && world.attach) {
|
|
160
|
+
await world.attach(JSON.stringify(fs.readFileSync(outputFile, "utf-8")), "application/json+bruno");
|
|
161
|
+
}
|
|
162
|
+
if (context.reportFolder) {
|
|
163
|
+
// copy the output file to the report folder
|
|
164
|
+
const reportFile = path.join(context.reportFolder, `bruno_${context.web.stepIndex ? context.web.stepIndex : 0}.json`);
|
|
165
|
+
fs.copyFileSync(outputFile, reportFile);
|
|
166
|
+
}
|
|
167
|
+
// validate result: totlaRequests === passedRequests, totalAssertions === passedAssertions, totalTests === passedTests
|
|
168
|
+
/*
|
|
169
|
+
[
|
|
170
|
+
{
|
|
171
|
+
"iterationIndex": 0,
|
|
172
|
+
"summary": {
|
|
173
|
+
"totalRequests": 1,
|
|
174
|
+
"passedRequests": 1,
|
|
175
|
+
"failedRequests": 0,
|
|
176
|
+
"skippedRequests": 0,
|
|
177
|
+
"totalAssertions": 0,
|
|
178
|
+
"passedAssertions": 0,
|
|
179
|
+
"failedAssertions": 0,
|
|
180
|
+
"totalTests": 1,
|
|
181
|
+
"passedTests": 1,
|
|
182
|
+
"failedTests": 0
|
|
183
|
+
},
|
|
184
|
+
*/
|
|
185
|
+
if (result &&
|
|
186
|
+
result.length > 0 &&
|
|
187
|
+
result[0] &&
|
|
188
|
+
result[0].results &&
|
|
189
|
+
result[0].results.length > 0 &&
|
|
190
|
+
result[0].results[0].error) {
|
|
191
|
+
console.error(`Error executing Bruno request: ${result[0].results[0].error}`);
|
|
192
|
+
throw new Error(`Bruno request failed: ${result[0].results[0].error}`);
|
|
193
|
+
}
|
|
194
|
+
if (!result || !Array.isArray(result) || result.length === 0) {
|
|
195
|
+
throw new Error(`Bruno request failed: ${stderr}`);
|
|
196
|
+
}
|
|
197
|
+
const summary = result[0].summary;
|
|
198
|
+
if (summary.totalRequests !== summary.passedRequests) {
|
|
199
|
+
throw new Error(`Bruno request failed: ${stderr}`);
|
|
200
|
+
}
|
|
201
|
+
if (summary.totalAssertions !== summary.passedAssertions) {
|
|
202
|
+
let assertionError = "";
|
|
203
|
+
if (result[0].results && result[0].results.length > 0 && result[0].results[0].assertionResults) {
|
|
204
|
+
for (const assertion of result[0].results[0].assertionResults) {
|
|
205
|
+
if (assertion.error) {
|
|
206
|
+
assertionError += assertion.error + "\n";
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
throw new Error(`Bruno request failed: ${assertionError}`);
|
|
211
|
+
}
|
|
212
|
+
let testsError = "";
|
|
213
|
+
if (summary.totalTests !== summary.passedTests) {
|
|
214
|
+
testsError = "";
|
|
215
|
+
if (result[0].results && result[0].results.length > 0 && result[0].results[0].testResults) {
|
|
216
|
+
for (const testResult of result[0].results[0].testResults) {
|
|
217
|
+
if (testResult.error) {
|
|
218
|
+
testsError += testResult.error + "\n";
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
throw new Error(`Bruno tests failed: ${testsError}`);
|
|
223
|
+
}
|
|
224
|
+
console.log(requestName + " - request executed successfully");
|
|
225
|
+
console.log(`requests: ${summary.passedRequests}/${summary.totalRequests}`);
|
|
226
|
+
if (summary.totalAssertions > 0) {
|
|
227
|
+
console.log(`assertions: ${summary.passedAssertions}/${summary.totalAssertions}`);
|
|
228
|
+
}
|
|
229
|
+
if (summary.totalTests > 0) {
|
|
230
|
+
console.log(`tests: ${summary.passedTests}/${summary.totalTests}`);
|
|
231
|
+
}
|
|
232
|
+
if (!options.brunoScope) {
|
|
233
|
+
options.brunoScope = "bruno";
|
|
234
|
+
}
|
|
235
|
+
const data = {};
|
|
236
|
+
data[options.testDataScope] = result[0].results.response;
|
|
237
|
+
context.web.setTestData(data, world);
|
|
238
|
+
// if the expectRuntime is true, read the runtime.json file
|
|
239
|
+
if (expectRuntime) {
|
|
240
|
+
// check if the runtime.json file exists
|
|
241
|
+
if (fs.existsSync(runtimeFile)) {
|
|
242
|
+
// read the runtime.json file
|
|
243
|
+
const runtimeData = JSON.parse(fs.readFileSync(runtimeFile, "utf-8"));
|
|
244
|
+
// set test data
|
|
245
|
+
context.web.setTestData(runtimeData, world);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return result;
|
|
249
|
+
}
|
|
250
|
+
catch (error) {
|
|
251
|
+
await _commandError(state, error, context.web);
|
|
252
|
+
}
|
|
253
|
+
finally {
|
|
254
|
+
_commandFinally(state, context.web);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
const runCommand = async (args, options) => {
|
|
258
|
+
return new Promise((resolve, reject) => {
|
|
259
|
+
const _cmd = process.platform === "win32" ? "npx.cmd" : "npx";
|
|
260
|
+
const _options = process.platform === "win32" ? { ...options, shell: true } : options;
|
|
261
|
+
const child = spawn(_cmd, args, _options);
|
|
262
|
+
let stdout = "";
|
|
263
|
+
let stderr = "";
|
|
264
|
+
child.stdout?.on("data", (data) => {
|
|
265
|
+
stdout += data.toString();
|
|
266
|
+
//process.stdout.write(data);
|
|
267
|
+
});
|
|
268
|
+
child.stderr?.on("data", (data) => {
|
|
269
|
+
stderr += data.toString();
|
|
270
|
+
process.stderr.write(data);
|
|
271
|
+
});
|
|
272
|
+
child.on("error", (err) => {
|
|
273
|
+
reject(err);
|
|
274
|
+
});
|
|
275
|
+
child.on("close", (code) => {
|
|
276
|
+
// if (code !== 0) {
|
|
277
|
+
// reject(new Error(`Process exited with code ${code}: ${stderr}`));
|
|
278
|
+
// } else {
|
|
279
|
+
resolve({ stdout, stderr });
|
|
280
|
+
//}
|
|
281
|
+
});
|
|
282
|
+
});
|
|
283
|
+
};
|
|
284
|
+
//# sourceMappingURL=bruno.js.map
|
package/lib/bruno.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bruno.js","sourceRoot":"","sources":["../../src/bruno.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClF,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAa5C,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,WAAmB,EAAE,OAAY,EAAE,OAAY,EAAE,KAAU;IACnG,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,GAAG,EAAE,CAAC;KACd;IACD,MAAM,KAAK,GAAG;QACZ,MAAM,EAAE,KAAK;QACb,MAAM,EAAE,KAAK;QACb,UAAU,EAAE,KAAK;QACjB,SAAS,EAAE,KAAK;QAChB,UAAU,EAAE,IAAI;QAChB,SAAS,EAAE,OAAO;QAClB,IAAI,EAAE,QAAQ,GAAG,WA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,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;QAE1C,IAAI,MAAM,GAAG,EAAE,CAAC;QAChB,IAAI,MAAM,GAAG,EAAE,CAAC;QAEhB,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;YAChC,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC1B,6BAA6B;QAC/B,CAAC,CAAC,CAAC;QAEH,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;YAChC,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC1B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;QAEH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YACxB,MAAM,CAAC,GAAG,CAAC,CAAC;QACd,CAAC,CAAC,CAAC;QAEH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;YACzB,oBAAoB;YACpB,sEAAsE;YACtE,WAAW;YACX,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;YAC5B,GAAG;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
package/lib/command_common.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export declare function _preCommand(state: any,
|
|
2
|
-
export declare function _commandError(state: any, error: any,
|
|
3
|
-
export declare function _screenshot(state: any,
|
|
4
|
-
export declare function _commandFinally(state: any,
|
|
1
|
+
export declare function _preCommand(state: any, web: any): Promise<void>;
|
|
2
|
+
export declare function _commandError(state: any, error: any, web: any): Promise<void>;
|
|
3
|
+
export declare function _screenshot(state: any, web: any, specificElement?: any): Promise<void>;
|
|
4
|
+
export declare function _commandFinally(state: any, web: any): Promise<void>;
|
|
5
5
|
export declare function _validateSelectors(selectors: any): void;
|
|
6
6
|
export declare function _reportToWorld(world: any, properties: any): void;
|
package/lib/command_common.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getHumanReadableErrorMessage } from "./error-messages.js";
|
|
2
2
|
import { LocatorLog } from "./locator_log.js";
|
|
3
|
-
import { _fixUsingParams, maskValue } from "./utils.js";
|
|
4
|
-
export async function _preCommand(state,
|
|
3
|
+
import { _fixUsingParams, maskValue, replaceWithLocalTestData } from "./utils.js";
|
|
4
|
+
export async function _preCommand(state, web) {
|
|
5
5
|
if (!state) {
|
|
6
6
|
return;
|
|
7
7
|
}
|
|
@@ -57,17 +57,17 @@ export async function _preCommand(state, stable) {
|
|
|
57
57
|
if (state.options && state.options.timeout) {
|
|
58
58
|
timeout = state.options.timeout;
|
|
59
59
|
}
|
|
60
|
-
state.element = await
|
|
60
|
+
state.element = await web._locate(state.selectors, state.info, state._params, timeout, allowDisabled);
|
|
61
61
|
}
|
|
62
62
|
if (state.scroll === true) {
|
|
63
|
-
await
|
|
63
|
+
await web.scrollIfNeeded(state.element, state.info);
|
|
64
64
|
}
|
|
65
65
|
if (state.screenshot === true) {
|
|
66
|
-
await _screenshot(state,
|
|
66
|
+
await _screenshot(state, web);
|
|
67
67
|
}
|
|
68
68
|
if (state.highlight === true) {
|
|
69
69
|
try {
|
|
70
|
-
await
|
|
70
|
+
await web._highlightElements(state.element);
|
|
71
71
|
}
|
|
72
72
|
catch (e) {
|
|
73
73
|
// ignore
|
|
@@ -75,24 +75,24 @@ export async function _preCommand(state, stable) {
|
|
|
75
75
|
}
|
|
76
76
|
state.info.failCause.operationFailed = true;
|
|
77
77
|
}
|
|
78
|
-
export async function _commandError(state, error,
|
|
78
|
+
export async function _commandError(state, error, web) {
|
|
79
79
|
if (!state.info) {
|
|
80
80
|
state.info = {};
|
|
81
81
|
}
|
|
82
82
|
if (!state.info.failCause) {
|
|
83
83
|
state.info.failCause = {};
|
|
84
84
|
}
|
|
85
|
-
|
|
85
|
+
web.logger.error(state.text + " failed");
|
|
86
86
|
if (error && error.message) {
|
|
87
|
-
|
|
87
|
+
web.logger.error(error.message);
|
|
88
88
|
}
|
|
89
89
|
if (state.info.locatorLog) {
|
|
90
90
|
const lines = state.info.locatorLog.toString().split("\n");
|
|
91
91
|
for (let line of lines) {
|
|
92
|
-
|
|
92
|
+
web.logger.error(line);
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
-
const { screenshotId, screenshotPath } = await
|
|
95
|
+
const { screenshotId, screenshotPath } = await web._screenShot(state.options, state.world, state.info);
|
|
96
96
|
state.screenshotId = screenshotId;
|
|
97
97
|
state.screenshotPath = screenshotPath;
|
|
98
98
|
state.info.screenshotPath = screenshotPath;
|
|
@@ -101,6 +101,7 @@ export async function _commandError(state, error, stable) {
|
|
|
101
101
|
const errorClassification = getHumanReadableErrorMessage(error, state.info);
|
|
102
102
|
state.info.errorType = errorClassification.errorType;
|
|
103
103
|
state.info.errorMessage = errorClassification.errorMessage;
|
|
104
|
+
state.info.errorStack = error.stack;
|
|
104
105
|
Object.assign(error, { info: state.info });
|
|
105
106
|
state.error = error;
|
|
106
107
|
state.commandError = true;
|
|
@@ -108,28 +109,58 @@ export async function _commandError(state, error, stable) {
|
|
|
108
109
|
throw error;
|
|
109
110
|
}
|
|
110
111
|
}
|
|
111
|
-
export async function _screenshot(state,
|
|
112
|
-
|
|
112
|
+
export async function _screenshot(state, web, specificElement) {
|
|
113
|
+
// let focusedElement = null;
|
|
114
|
+
// if (specificElement !== undefined) {
|
|
115
|
+
// focusedElement = specificElement;
|
|
116
|
+
// } else {
|
|
117
|
+
// focusedElement = state.element;
|
|
118
|
+
// }
|
|
119
|
+
// const { screenshotId, screenshotPath } = await web._screenShot(
|
|
120
|
+
// state.options,
|
|
121
|
+
// state.world,
|
|
122
|
+
// state.info,
|
|
123
|
+
// focusedElement
|
|
124
|
+
// );
|
|
125
|
+
// ;
|
|
126
|
+
const { screenshotId, screenshotPath } = await web._screenShot(state.options, state.world, state.info);
|
|
113
127
|
state.screenshotId = screenshotId;
|
|
114
128
|
state.screenshotPath = screenshotPath;
|
|
115
129
|
}
|
|
116
|
-
export function _commandFinally(state,
|
|
130
|
+
export async function _commandFinally(state, web) {
|
|
117
131
|
if (state && !state.commandError === true) {
|
|
118
132
|
state.info.failCause = {};
|
|
119
133
|
}
|
|
120
134
|
state.endTime = Date.now();
|
|
135
|
+
let _value = "";
|
|
136
|
+
if (state.originalValue) {
|
|
137
|
+
try {
|
|
138
|
+
if (state.originalValue.startsWith("{{") && state.originalValue.endsWith("}}")) {
|
|
139
|
+
_value = (await replaceWithLocalTestData(state.originalValue, state.world, false, true, web.context, web));
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
_value = state.originalValue;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
catch (e) {
|
|
146
|
+
console.error("Error replacing test data value", e);
|
|
147
|
+
_value = state.originalValue;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
121
150
|
const reportObject = {
|
|
122
151
|
element_name: state.selectors ? state.selectors.element_name : null,
|
|
123
152
|
type: state.type,
|
|
124
153
|
text: state.text,
|
|
125
|
-
|
|
154
|
+
_text: state._text,
|
|
155
|
+
value: state.originalValue ? maskValue(_value) : state.value,
|
|
126
156
|
screenshotId: state.screenshotId,
|
|
127
157
|
result: state.error
|
|
128
158
|
? {
|
|
129
159
|
status: "FAILED",
|
|
130
160
|
startTime: state.startTime,
|
|
131
161
|
endTime: state.endTime,
|
|
132
|
-
message: state.error?.message,
|
|
162
|
+
message: state?.info?.errorMessage ?? state.error?.message,
|
|
163
|
+
stack: state.error?.stack,
|
|
133
164
|
}
|
|
134
165
|
: {
|
|
135
166
|
status: "PASSED",
|