@dev-blinq/cucumber_client 1.0.1629-dev → 1.0.1631-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.
|
@@ -390,6 +390,7 @@ class BVTRecorder {
|
|
|
390
390
|
}
|
|
391
391
|
case "input": {
|
|
392
392
|
const target = this.eventUtils.getNearestInteractiveElement(this.eventUtils.deepEventTarget(event));
|
|
393
|
+
|
|
393
394
|
if (target.nodeName === "INPUT" && target.type.toLowerCase() === "file") {
|
|
394
395
|
return {
|
|
395
396
|
details: {
|
|
@@ -434,6 +435,36 @@ class BVTRecorder {
|
|
|
434
435
|
return;
|
|
435
436
|
}
|
|
436
437
|
case "keydown": {
|
|
438
|
+
// override event.preventDefault to capture the value
|
|
439
|
+
|
|
440
|
+
const oldPreventDefault = event.preventDefault.bind(event);
|
|
441
|
+
event.preventDefault = () => {
|
|
442
|
+
if (event.key.length >= 1 && !event.ctrlKey && !event.metaKey && !event.altKey) {
|
|
443
|
+
const target = this.eventUtils.getNearestInteractiveElement(this.eventUtils.deepEventTarget(event));
|
|
444
|
+
setTimeout(() => {
|
|
445
|
+
if (event.__bvt_recorded !== undefined) return;
|
|
446
|
+
const valueBefore = target.value;
|
|
447
|
+
let newValue = valueBefore;
|
|
448
|
+
|
|
449
|
+
this.recordEvent(
|
|
450
|
+
{
|
|
451
|
+
details: {
|
|
452
|
+
name: "fill",
|
|
453
|
+
text: newValue,
|
|
454
|
+
},
|
|
455
|
+
element: target,
|
|
456
|
+
},
|
|
457
|
+
target,
|
|
458
|
+
"input",
|
|
459
|
+
event
|
|
460
|
+
);
|
|
461
|
+
|
|
462
|
+
event.__bvt_recorded = true;
|
|
463
|
+
}, 20);
|
|
464
|
+
}
|
|
465
|
+
oldPreventDefault();
|
|
466
|
+
};
|
|
467
|
+
|
|
437
468
|
if (!this.eventUtils.shouldGenerateKeyPressFor(event)) return;
|
|
438
469
|
// if (this._actionInProgress(event)) {
|
|
439
470
|
// this._expectProgrammaticKeyUp = true;
|
|
@@ -835,30 +866,7 @@ class BVTRecorder {
|
|
|
835
866
|
}
|
|
836
867
|
|
|
837
868
|
performance.mark("command-send");
|
|
838
|
-
|
|
839
|
-
mode: this.#mode,
|
|
840
|
-
action: action.details,
|
|
841
|
-
element: this.getElementDetails(actionElement, eventName),
|
|
842
|
-
isPopupCloseClick: this.isPopupCloseEvent(e),
|
|
843
|
-
// ...(actionElement.__locators ?? this.getLocatorsObject(actionElement, { maxLocators: 1 })),
|
|
844
|
-
frame: this.getFrameDetails(),
|
|
845
|
-
statistics: {
|
|
846
|
-
time: `${performance.measure("command-received", "command-send").duration.toFixed(2)} ms`,
|
|
847
|
-
},
|
|
848
|
-
};
|
|
849
|
-
const snapshotDetails = {
|
|
850
|
-
id: actionElement.getAttribute("data-blinq-id"),
|
|
851
|
-
contextId: this.contextElement?.getAttribute("data-blinq-context-id"),
|
|
852
|
-
doc: this.snapshotCapturer.createSnapshot({
|
|
853
|
-
excludeSelectors: ["x-bvt-toolbar", "script", "style", "link[rel=stylesheet]"],
|
|
854
|
-
}),
|
|
855
|
-
};
|
|
856
|
-
cmd.snapshotDetails = snapshotDetails;
|
|
857
|
-
// eventQueue.enqueue(async () => {
|
|
858
|
-
// await bvtRecorderBindings.validateLocators(snapshotDetails);
|
|
859
|
-
// });
|
|
860
|
-
// console.log(cmd);
|
|
861
|
-
bvtRecorderBindings.recordCommand(cmd);
|
|
869
|
+
this.recordEvent(action, actionElement, eventName, e);
|
|
862
870
|
this.handleStateTransition(action.element);
|
|
863
871
|
},
|
|
864
872
|
{ capture: true }
|
|
@@ -866,6 +874,33 @@ class BVTRecorder {
|
|
|
866
874
|
});
|
|
867
875
|
}
|
|
868
876
|
|
|
877
|
+
recordEvent(action, actionElement, eventName, e) {
|
|
878
|
+
const cmd = {
|
|
879
|
+
mode: this.#mode,
|
|
880
|
+
action: action.details,
|
|
881
|
+
element: this.getElementDetails(actionElement, eventName),
|
|
882
|
+
isPopupCloseClick: this.isPopupCloseEvent(e),
|
|
883
|
+
// ...(actionElement.__locators ?? this.getLocatorsObject(actionElement, { maxLocators: 1 })),
|
|
884
|
+
frame: this.getFrameDetails(),
|
|
885
|
+
statistics: {
|
|
886
|
+
time: `${performance.measure("command-received", "command-send").duration.toFixed(2)} ms`,
|
|
887
|
+
},
|
|
888
|
+
};
|
|
889
|
+
const snapshotDetails = {
|
|
890
|
+
id: actionElement.getAttribute("data-blinq-id"),
|
|
891
|
+
contextId: this.contextElement?.getAttribute("data-blinq-context-id"),
|
|
892
|
+
doc: this.snapshotCapturer.createSnapshot({
|
|
893
|
+
excludeSelectors: ["x-bvt-toolbar", "script", "style", "link[rel=stylesheet]"],
|
|
894
|
+
}),
|
|
895
|
+
};
|
|
896
|
+
cmd.snapshotDetails = snapshotDetails;
|
|
897
|
+
// eventQueue.enqueue(async () => {
|
|
898
|
+
// await bvtRecorderBindings.validateLocators(snapshotDetails);
|
|
899
|
+
// });
|
|
900
|
+
// console.log(cmd);
|
|
901
|
+
bvtRecorderBindings.recordCommand(cmd);
|
|
902
|
+
}
|
|
903
|
+
|
|
869
904
|
// TODO: implement the corresponding logic for the below methods
|
|
870
905
|
setPopupHandlers(_popopHandlers) {
|
|
871
906
|
this.popupHandlers = _popopHandlers;
|
|
@@ -623,11 +623,14 @@ export class CodePage {
|
|
|
623
623
|
return this.fileContent.length;
|
|
624
624
|
}
|
|
625
625
|
addLocatorsMetadata(locatorsMetadata) {
|
|
626
|
+
console.log("Saving locators metadata to file");
|
|
626
627
|
if (!this.sourceFileName)
|
|
627
628
|
return;
|
|
629
|
+
console.log("Source file name:", this.sourceFileName);
|
|
628
630
|
let locatorsMetadataFileName = this.sourceFileName.replace(".mjs", ".json");
|
|
629
631
|
const config = getAiConfig();
|
|
630
632
|
if (config && config.locatorsMetadataDir) {
|
|
633
|
+
console.log("Using locators metadata directory from config:", config.locatorsMetadataDir);
|
|
631
634
|
locatorsMetadataFileName = path.join(config.locatorsMetadataDir, path.basename(locatorsMetadataFileName));
|
|
632
635
|
if (!existsSync(path.dirname(locatorsMetadataFileName))) {
|
|
633
636
|
mkdirSync(path.dirname(locatorsMetadataFileName), { recursive: true });
|
|
@@ -635,11 +638,13 @@ export class CodePage {
|
|
|
635
638
|
}
|
|
636
639
|
let metadata = {};
|
|
637
640
|
try {
|
|
641
|
+
console.log("Reading locators metadata file:", locatorsMetadataFileName);
|
|
638
642
|
if (existsSync(locatorsMetadataFileName)) {
|
|
639
643
|
metadata = JSON.parse(readFileSync(locatorsMetadataFileName, "utf8"));
|
|
640
644
|
}
|
|
641
645
|
}
|
|
642
|
-
catch {
|
|
646
|
+
catch (error) {
|
|
647
|
+
console.log("Error reading locators metadata file:", error);
|
|
643
648
|
logger.info("failed to read locators metadata file", locatorsMetadataFileName);
|
|
644
649
|
}
|
|
645
650
|
const keys = Object.keys(locatorsMetadata);
|
|
@@ -763,6 +763,7 @@ const generateCode = (recording, codePage, userData, projectDir, methodName) =>
|
|
|
763
763
|
if (recordingStep.type === Types.COMPLETE) {
|
|
764
764
|
return;
|
|
765
765
|
}
|
|
766
|
+
console.log("Generating code for step: ", recordingStep.type);
|
|
766
767
|
|
|
767
768
|
// if (process.env.TEMP_RUN === "true") {
|
|
768
769
|
// codeLines.push(...generateReportCommand("start", recordingStep.cmdId));
|
|
@@ -774,9 +775,11 @@ const generateCode = (recording, codePage, userData, projectDir, methodName) =>
|
|
|
774
775
|
// codeLines.push(...generateReportCommand("end", recordingStep.cmdId));
|
|
775
776
|
// }
|
|
776
777
|
if (result.elements) {
|
|
778
|
+
console.log("Updating elements with ", Object.keys(result.elements));
|
|
777
779
|
elements = result.elements;
|
|
778
780
|
}
|
|
779
781
|
if (result.elementIdentifier) {
|
|
782
|
+
console.log("Adding locator metadata for ", result.elementIdentifier);
|
|
780
783
|
locatorsMetadata[result.elementIdentifier] = result.allStrategyLocators;
|
|
781
784
|
}
|
|
782
785
|
});
|
|
@@ -624,6 +624,7 @@ export async function saveRecording({ step, cucumberStep, codePage, projectDir,
|
|
|
624
624
|
return result.codePage;
|
|
625
625
|
} else {
|
|
626
626
|
const generateCodeResult = generateCode(recording, codePage, userData, projectDir, methodName);
|
|
627
|
+
console.log("Generated code for step:", step.text);
|
|
627
628
|
if (generateCodeResult.noCode === true) {
|
|
628
629
|
logger.log("No code generated for step: " + step.text);
|
|
629
630
|
return generateCodeResult.page;
|
|
@@ -673,6 +674,7 @@ export async function saveRecording({ step, cucumberStep, codePage, projectDir,
|
|
|
673
674
|
codePage.mergeSimilarElements();
|
|
674
675
|
cucumberStep.methodName = methodName;
|
|
675
676
|
if (generateCodeResult.locatorsMetadata) {
|
|
677
|
+
console.log("Adding locators metadata to code page");
|
|
676
678
|
codePage.addLocatorsMetadata(generateCodeResult.locatorsMetadata);
|
|
677
679
|
}
|
|
678
680
|
return generateCodeResult.page;
|