@dev-blinq/cucumber_client 1.0.1712-dev → 1.0.1714-dev
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.
|
@@ -168,7 +168,7 @@ async function BVTRecorderInit({ envName, projectDir, roomId, TOKEN, socket = nu
|
|
|
168
168
|
return (await recorder.getImplementedSteps(input)).scenarios;
|
|
169
169
|
},
|
|
170
170
|
"recorderWindow.getCurrentChromiumPath": async () => {
|
|
171
|
-
return
|
|
171
|
+
return recorder.getCurrentChromiumPath();
|
|
172
172
|
},
|
|
173
173
|
"recorderWindow.overwriteTestData": async (input) => {
|
|
174
174
|
return await recorder.overwriteTestData(input);
|
|
@@ -241,7 +241,7 @@ async function BVTRecorderInit({ envName, projectDir, roomId, TOKEN, socket = nu
|
|
|
241
241
|
return await recorder.getCurrentPageTitle();
|
|
242
242
|
},
|
|
243
243
|
"recorderWindow.getCurrentPageUrl": async () => {
|
|
244
|
-
return
|
|
244
|
+
return recorder.getCurrentPageUrl();
|
|
245
245
|
},
|
|
246
246
|
"recorderWindow.sendAriaSnapshot": async (input) => {
|
|
247
247
|
const snapshot = input?.snapshot;
|
|
@@ -293,6 +293,9 @@ async function BVTRecorderInit({ envName, projectDir, roomId, TOKEN, socket = nu
|
|
|
293
293
|
"recorderWindow.deleteCommandFromStepCode": async (input) => {
|
|
294
294
|
return await recorder.deleteCommandFromStepCode(input);
|
|
295
295
|
},
|
|
296
|
+
"recorderWindow.generateLocatorSummaries": async (input) => {
|
|
297
|
+
return await recorder.generateLocatorSummaries(input);
|
|
298
|
+
}
|
|
296
299
|
});
|
|
297
300
|
socket.on("targetBrowser.command.event", async (input) => {
|
|
298
301
|
return recorder.onAction(input);
|
|
@@ -196,7 +196,13 @@ export class BVTRecorder {
|
|
|
196
196
|
workspaceService;
|
|
197
197
|
pageSet = new Set();
|
|
198
198
|
lastKnownUrlPath = "";
|
|
199
|
-
world = {
|
|
199
|
+
world = {
|
|
200
|
+
attach: async () => { },
|
|
201
|
+
parameters: {},
|
|
202
|
+
log: (message) => {
|
|
203
|
+
socketLogger.log.call(socketLogger, "info", message, undefined, "Cucumber.JS World");
|
|
204
|
+
},
|
|
205
|
+
};
|
|
200
206
|
shouldTakeScreenshot = true;
|
|
201
207
|
watcher = null;
|
|
202
208
|
networkEventsFolder;
|
|
@@ -348,7 +354,6 @@ export class BVTRecorder {
|
|
|
348
354
|
this.#remoteDebuggerPort = Number(process.env.CDP_LISTEN_PORT);
|
|
349
355
|
}
|
|
350
356
|
// this.stepRunner.setRemoteDebugPort(this.#remoteDebuggerPort);
|
|
351
|
-
this.world = { attach: () => { } };
|
|
352
357
|
const ai_config_file = path.join(this.projectDir, "ai_config.json");
|
|
353
358
|
let ai_config = {};
|
|
354
359
|
if (existsSync(ai_config_file)) {
|
|
@@ -367,7 +372,8 @@ export class BVTRecorder {
|
|
|
367
372
|
`\ndelete Object.getPrototypeOf(navigator).webdriver;${process.env.WINDOW_DEBUGGER ? "window.debug=true;\n" : ""}`,
|
|
368
373
|
],
|
|
369
374
|
};
|
|
370
|
-
const
|
|
375
|
+
const scenario = { pickle: this.scenarioDoc };
|
|
376
|
+
const bvtContext = await initContext(url, false, false, this.world, 450, initScripts, this.envName, scenario);
|
|
371
377
|
this.bvtContext = bvtContext;
|
|
372
378
|
this.stepRunner = new BVTStepRunner({
|
|
373
379
|
projectDir: this.projectDir,
|
|
@@ -421,7 +427,7 @@ export class BVTRecorder {
|
|
|
421
427
|
}
|
|
422
428
|
async onClosePopup() {
|
|
423
429
|
// console.log("close popups");
|
|
424
|
-
await this.bvtContext.web
|
|
430
|
+
await this.bvtContext.web?.closeUnexpectedPopups(null, null);
|
|
425
431
|
}
|
|
426
432
|
async evaluateInAllFrames(context, script) {
|
|
427
433
|
// retry 3 times
|
|
@@ -650,17 +656,17 @@ export class BVTRecorder {
|
|
|
650
656
|
async getCurrentPageTitle() {
|
|
651
657
|
let title = "";
|
|
652
658
|
try {
|
|
653
|
-
title = await this.bvtContext
|
|
659
|
+
title = await this.bvtContext?.page?.title();
|
|
654
660
|
}
|
|
655
661
|
catch (e) {
|
|
656
662
|
this.logger.error(`Error getting page title: ${getErrorMessage(e)}`);
|
|
657
663
|
}
|
|
658
664
|
return title;
|
|
659
665
|
}
|
|
660
|
-
|
|
666
|
+
getCurrentPageUrl() {
|
|
661
667
|
let url = "";
|
|
662
668
|
try {
|
|
663
|
-
url =
|
|
669
|
+
url = this.bvtContext?.page?.url();
|
|
664
670
|
}
|
|
665
671
|
catch (e) {
|
|
666
672
|
this.logger.error(`Error getting page url: ${getErrorMessage(e)}`);
|
|
@@ -840,8 +846,8 @@ export class BVTRecorder {
|
|
|
840
846
|
}
|
|
841
847
|
_updateUrlPath() {
|
|
842
848
|
try {
|
|
843
|
-
const url = this.bvtContext
|
|
844
|
-
if (url !== "about:blank") {
|
|
849
|
+
const url = this.bvtContext?.web?.page.url();
|
|
850
|
+
if (url && url !== "about:blank") {
|
|
845
851
|
this.lastKnownUrlPath = new URL(url).pathname;
|
|
846
852
|
}
|
|
847
853
|
}
|
|
@@ -947,7 +953,7 @@ export class BVTRecorder {
|
|
|
947
953
|
const envVars = {
|
|
948
954
|
TOKEN: this.TOKEN,
|
|
949
955
|
TEMP_RUN: "true",
|
|
950
|
-
REPORT_FOLDER: this.bvtContext
|
|
956
|
+
REPORT_FOLDER: this.bvtContext?.reportFolder,
|
|
951
957
|
BLINQ_ENV: this.envName,
|
|
952
958
|
DEBUG: "blinq:route",
|
|
953
959
|
};
|
|
@@ -1035,12 +1041,6 @@ export class BVTRecorder {
|
|
|
1035
1041
|
}
|
|
1036
1042
|
}
|
|
1037
1043
|
return steps;
|
|
1038
|
-
// return getStepsAndCommandsForScenario({
|
|
1039
|
-
// name,
|
|
1040
|
-
// featureName,
|
|
1041
|
-
// projectDir: this.projectDir,
|
|
1042
|
-
// map: this.scenariosStepsMap,
|
|
1043
|
-
// });
|
|
1044
1044
|
}
|
|
1045
1045
|
async generateStepName({ commands, stepsNames, parameters, map, }) {
|
|
1046
1046
|
return await this.namesService.generateStepName({ commands, stepsNames, parameters, map });
|
|
@@ -1051,11 +1051,15 @@ export class BVTRecorder {
|
|
|
1051
1051
|
async generateCommandName({ command }) {
|
|
1052
1052
|
return await this.namesService.generateCommandName({ command });
|
|
1053
1053
|
}
|
|
1054
|
-
|
|
1055
|
-
const currentURL = await this.bvtContext.web.page.url();
|
|
1054
|
+
getCurrentChromiumPath() {
|
|
1056
1055
|
const env = JSON.parse(readFileSync(this.envName, "utf8"));
|
|
1057
1056
|
const baseURL = env.baseUrl;
|
|
1058
|
-
|
|
1057
|
+
let currentURL = null;
|
|
1058
|
+
currentURL = this.bvtContext?.web?.page?.url();
|
|
1059
|
+
let relativeURL = undefined;
|
|
1060
|
+
if (typeof currentURL == "string") {
|
|
1061
|
+
relativeURL = currentURL.startsWith(baseURL) ? currentURL.replace(baseURL, "/") : undefined;
|
|
1062
|
+
}
|
|
1059
1063
|
return {
|
|
1060
1064
|
relativeURL,
|
|
1061
1065
|
baseURL,
|
|
@@ -1225,6 +1229,13 @@ export class BVTRecorder {
|
|
|
1225
1229
|
datasets,
|
|
1226
1230
|
};
|
|
1227
1231
|
}
|
|
1232
|
+
async generateLocatorSummaries({ allStrategyLocators, element_name }) {
|
|
1233
|
+
const input = {
|
|
1234
|
+
[element_name ?? "element"]: allStrategyLocators
|
|
1235
|
+
};
|
|
1236
|
+
const result = await this.namesService.generateLocatorDescriptions({ locatorsObj: input });
|
|
1237
|
+
return result;
|
|
1238
|
+
}
|
|
1228
1239
|
async findRelatedTextInAllFrames({ searchString, climb, contextText, params, }) {
|
|
1229
1240
|
if (searchString.length === 0)
|
|
1230
1241
|
return -1;
|
|
@@ -1580,9 +1591,20 @@ export class BVTRecorder {
|
|
|
1580
1591
|
return;
|
|
1581
1592
|
}
|
|
1582
1593
|
try {
|
|
1583
|
-
|
|
1594
|
+
const value = params[key].substring(2, params[key].length - 2).trim();
|
|
1595
|
+
const faking = value.split("(")[0].split(".");
|
|
1596
|
+
let argument = value.substring(value.indexOf("(") + 1, value.lastIndexOf(")"));
|
|
1597
|
+
argument = isNaN(Number(argument)) || argument === "" ? argument : Number(argument);
|
|
1598
|
+
let fakeFunc = faker;
|
|
1599
|
+
faking.forEach((f) => {
|
|
1600
|
+
//@ts-expect-error Trying to support both old and new faker versions
|
|
1601
|
+
fakeFunc = fakeFunc[f];
|
|
1602
|
+
});
|
|
1603
|
+
//@ts-expect-error Trying to support both old and new faker versions
|
|
1604
|
+
const newValue = fakeFunc(argument);
|
|
1605
|
+
newFakeParams[key] = newValue;
|
|
1584
1606
|
}
|
|
1585
|
-
catch {
|
|
1607
|
+
catch (error) {
|
|
1586
1608
|
newFakeParams[key] = rawValue;
|
|
1587
1609
|
}
|
|
1588
1610
|
});
|
|
@@ -147,6 +147,25 @@ export class NamesService {
|
|
|
147
147
|
}
|
|
148
148
|
return result.data;
|
|
149
149
|
}
|
|
150
|
+
async generateLocatorDescriptions({ locatorsObj }) {
|
|
151
|
+
const url = `${getRunsServiceBaseURL()}/generate_locator_summaries`;
|
|
152
|
+
const result = await axiosClient({
|
|
153
|
+
url,
|
|
154
|
+
method: "POST",
|
|
155
|
+
data: locatorsObj,
|
|
156
|
+
headers: {
|
|
157
|
+
Authorization: `Bearer ${this.TOKEN}`,
|
|
158
|
+
"X-Source": "recorder",
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
if (result.status !== 200) {
|
|
162
|
+
throw new Error("Error while generating locator descriptions");
|
|
163
|
+
}
|
|
164
|
+
if (!result.data.status) {
|
|
165
|
+
throw new Error(result.data.error || "Error while generating locator descriptions");
|
|
166
|
+
}
|
|
167
|
+
return result.data.locatorsObj;
|
|
168
|
+
}
|
|
150
169
|
}
|
|
151
170
|
export class PublishService {
|
|
152
171
|
TOKEN;
|