@midscene/web 0.8.2 → 0.8.4
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/es/appium.js +10 -8
- package/dist/es/chrome-extension.js +20 -18
- package/dist/es/index.js +12 -10
- package/dist/es/midscene-playground.js +22 -20
- package/dist/es/playground.js +18 -16
- package/dist/es/playwright-report.js +4 -3
- package/dist/es/playwright.js +10 -8
- package/dist/es/puppeteer.js +10 -8
- package/dist/es/utils.js +4 -2
- package/dist/lib/appium.js +10 -8
- package/dist/lib/chrome-extension.js +20 -18
- package/dist/lib/index.js +12 -10
- package/dist/lib/midscene-playground.js +22 -20
- package/dist/lib/playground.js +18 -16
- package/dist/lib/playwright-report.js +4 -3
- package/dist/lib/playwright.js +10 -8
- package/dist/lib/puppeteer.js +10 -8
- package/dist/lib/utils.js +4 -2
- package/package.json +3 -3
package/dist/es/puppeteer.js
CHANGED
|
@@ -337,7 +337,7 @@ module.exports = __toCommonJS(puppeteer_exports);
|
|
|
337
337
|
// src/common/agent.ts
|
|
338
338
|
var import_core3 = require("@midscene/core");
|
|
339
339
|
var import_constants2 = require("@midscene/shared/constants");
|
|
340
|
-
var
|
|
340
|
+
var import_utils6 = require("@midscene/core/utils");
|
|
341
341
|
|
|
342
342
|
// src/common/tasks.ts
|
|
343
343
|
var import_node_assert = __toESM(require("assert"));
|
|
@@ -963,10 +963,11 @@ var WebElementInfo = class {
|
|
|
963
963
|
var import_node_assert2 = __toESM(require("assert"));
|
|
964
964
|
var import_node_fs2 = require("fs");
|
|
965
965
|
var import_node_path2 = __toESM(require("path"));
|
|
966
|
+
var import_utils4 = require("@midscene/core/utils");
|
|
966
967
|
var import_constants = require("@midscene/shared/constants");
|
|
967
968
|
var import_fs2 = require("@midscene/shared/fs");
|
|
968
969
|
var import_img = require("@midscene/shared/img");
|
|
969
|
-
var
|
|
970
|
+
var import_utils5 = require("@midscene/shared/utils");
|
|
970
971
|
var import_dayjs = __toESM(require_dayjs_min());
|
|
971
972
|
async function parseContextFromWebPage(page, _opt) {
|
|
972
973
|
(0, import_node_assert2.default)(page, "page is required");
|
|
@@ -974,6 +975,7 @@ async function parseContextFromWebPage(page, _opt) {
|
|
|
974
975
|
return await page._forceUsePageContext();
|
|
975
976
|
}
|
|
976
977
|
const url = await page.url();
|
|
978
|
+
(0, import_utils4.uploadTestInfoToServer)({ testUrl: url });
|
|
977
979
|
let screenshotBase64;
|
|
978
980
|
let elementsInfo = [];
|
|
979
981
|
await Promise.all([
|
|
@@ -1102,16 +1104,16 @@ var PageAgent = class {
|
|
|
1102
1104
|
dumpDataString() {
|
|
1103
1105
|
this.dump.groupName = this.opts.groupName;
|
|
1104
1106
|
this.dump.groupDescription = this.opts.groupDescription;
|
|
1105
|
-
return (0,
|
|
1107
|
+
return (0, import_utils6.stringifyDumpData)(this.dump);
|
|
1106
1108
|
}
|
|
1107
1109
|
reportHTMLString() {
|
|
1108
|
-
return (0,
|
|
1110
|
+
return (0, import_utils6.reportHTMLContent)(this.dumpDataString());
|
|
1109
1111
|
}
|
|
1110
1112
|
writeOutActionDumps() {
|
|
1111
1113
|
const { generateReport, autoPrintReportMsg } = this.opts;
|
|
1112
|
-
this.reportFile = (0,
|
|
1114
|
+
this.reportFile = (0, import_utils6.writeLogFile)({
|
|
1113
1115
|
fileName: this.reportFileName,
|
|
1114
|
-
fileExt:
|
|
1116
|
+
fileExt: import_utils6.groupedActionDumpFileExt,
|
|
1115
1117
|
fileContent: this.dumpDataString(),
|
|
1116
1118
|
type: "dump",
|
|
1117
1119
|
generateReport
|
|
@@ -1190,7 +1192,7 @@ ${errorTask == null ? void 0 : errorTask.errorStack}`);
|
|
|
1190
1192
|
};
|
|
1191
1193
|
|
|
1192
1194
|
// src/puppeteer/base-page.ts
|
|
1193
|
-
var
|
|
1195
|
+
var import_utils9 = require("@midscene/core/utils");
|
|
1194
1196
|
var import_img2 = require("@midscene/shared/img");
|
|
1195
1197
|
var Page = class {
|
|
1196
1198
|
async evaluate(pageFunction, arg) {
|
|
@@ -1222,7 +1224,7 @@ var Page = class {
|
|
|
1222
1224
|
return sizeInfo;
|
|
1223
1225
|
}
|
|
1224
1226
|
async screenshotBase64() {
|
|
1225
|
-
const path2 = (0,
|
|
1227
|
+
const path2 = (0, import_utils9.getTmpFile)("png");
|
|
1226
1228
|
await this.underlyingPage.screenshot({
|
|
1227
1229
|
path: path2,
|
|
1228
1230
|
type: "png"
|
package/dist/es/utils.js
CHANGED
|
@@ -340,10 +340,11 @@ module.exports = __toCommonJS(utils_exports);
|
|
|
340
340
|
var import_node_assert = __toESM(require("assert"));
|
|
341
341
|
var import_node_fs = require("fs");
|
|
342
342
|
var import_node_path = __toESM(require("path"));
|
|
343
|
+
var import_utils = require("@midscene/core/utils");
|
|
343
344
|
var import_constants = require("@midscene/shared/constants");
|
|
344
345
|
var import_fs = require("@midscene/shared/fs");
|
|
345
346
|
var import_img = require("@midscene/shared/img");
|
|
346
|
-
var
|
|
347
|
+
var import_utils2 = require("@midscene/shared/utils");
|
|
347
348
|
var import_dayjs = __toESM(require_dayjs_min());
|
|
348
349
|
|
|
349
350
|
// src/web-element.ts
|
|
@@ -378,6 +379,7 @@ async function parseContextFromWebPage(page, _opt) {
|
|
|
378
379
|
return await page._forceUsePageContext();
|
|
379
380
|
}
|
|
380
381
|
const url = await page.url();
|
|
382
|
+
(0, import_utils.uploadTestInfoToServer)({ testUrl: url });
|
|
381
383
|
let screenshotBase64;
|
|
382
384
|
let elementsInfo = [];
|
|
383
385
|
await Promise.all([
|
|
@@ -469,7 +471,7 @@ var testFileIndex = /* @__PURE__ */ new Map();
|
|
|
469
471
|
function generateCacheId(fileName) {
|
|
470
472
|
let taskFile = fileName || getCurrentExecutionFile();
|
|
471
473
|
if (!taskFile) {
|
|
472
|
-
taskFile = (0,
|
|
474
|
+
taskFile = (0, import_utils2.uuid)();
|
|
473
475
|
console.warn(
|
|
474
476
|
"Midscene - using random UUID for cache id. Cache may be invalid."
|
|
475
477
|
);
|
package/dist/lib/appium.js
CHANGED
|
@@ -855,7 +855,7 @@ module.exports = __toCommonJS(appium_exports);
|
|
|
855
855
|
// src/common/agent.ts
|
|
856
856
|
var import_core3 = require("@midscene/core");
|
|
857
857
|
var import_constants2 = require("@midscene/shared/constants");
|
|
858
|
-
var
|
|
858
|
+
var import_utils6 = require("@midscene/core/utils");
|
|
859
859
|
|
|
860
860
|
// src/common/tasks.ts
|
|
861
861
|
var import_node_assert = __toESM(require("assert"));
|
|
@@ -1481,10 +1481,11 @@ var WebElementInfo = class {
|
|
|
1481
1481
|
var import_node_assert2 = __toESM(require("assert"));
|
|
1482
1482
|
var import_node_fs2 = require("fs");
|
|
1483
1483
|
var import_node_path2 = __toESM(require("path"));
|
|
1484
|
+
var import_utils4 = require("@midscene/core/utils");
|
|
1484
1485
|
var import_constants = require("@midscene/shared/constants");
|
|
1485
1486
|
var import_fs2 = require("@midscene/shared/fs");
|
|
1486
1487
|
var import_img = require("@midscene/shared/img");
|
|
1487
|
-
var
|
|
1488
|
+
var import_utils5 = require("@midscene/shared/utils");
|
|
1488
1489
|
var import_dayjs = __toESM(require_dayjs_min());
|
|
1489
1490
|
async function parseContextFromWebPage(page, _opt) {
|
|
1490
1491
|
(0, import_node_assert2.default)(page, "page is required");
|
|
@@ -1492,6 +1493,7 @@ async function parseContextFromWebPage(page, _opt) {
|
|
|
1492
1493
|
return await page._forceUsePageContext();
|
|
1493
1494
|
}
|
|
1494
1495
|
const url = await page.url();
|
|
1496
|
+
(0, import_utils4.uploadTestInfoToServer)({ testUrl: url });
|
|
1495
1497
|
let screenshotBase64;
|
|
1496
1498
|
let elementsInfo = [];
|
|
1497
1499
|
await Promise.all([
|
|
@@ -1613,16 +1615,16 @@ var PageAgent = class {
|
|
|
1613
1615
|
dumpDataString() {
|
|
1614
1616
|
this.dump.groupName = this.opts.groupName;
|
|
1615
1617
|
this.dump.groupDescription = this.opts.groupDescription;
|
|
1616
|
-
return (0,
|
|
1618
|
+
return (0, import_utils6.stringifyDumpData)(this.dump);
|
|
1617
1619
|
}
|
|
1618
1620
|
reportHTMLString() {
|
|
1619
|
-
return (0,
|
|
1621
|
+
return (0, import_utils6.reportHTMLContent)(this.dumpDataString());
|
|
1620
1622
|
}
|
|
1621
1623
|
writeOutActionDumps() {
|
|
1622
1624
|
const { generateReport, autoPrintReportMsg } = this.opts;
|
|
1623
|
-
this.reportFile = (0,
|
|
1625
|
+
this.reportFile = (0, import_utils6.writeLogFile)({
|
|
1624
1626
|
fileName: this.reportFileName,
|
|
1625
|
-
fileExt:
|
|
1627
|
+
fileExt: import_utils6.groupedActionDumpFileExt,
|
|
1626
1628
|
fileContent: this.dumpDataString(),
|
|
1627
1629
|
type: "dump",
|
|
1628
1630
|
generateReport
|
|
@@ -1702,7 +1704,7 @@ ${errorTask == null ? void 0 : errorTask.errorStack}`);
|
|
|
1702
1704
|
|
|
1703
1705
|
// src/appium/page.ts
|
|
1704
1706
|
var import_node_fs3 = __toESM(require("fs"));
|
|
1705
|
-
var
|
|
1707
|
+
var import_utils9 = require("@midscene/core/utils");
|
|
1706
1708
|
var import_img2 = require("@midscene/shared/img");
|
|
1707
1709
|
var import_xmldom = require("@xmldom/xmldom");
|
|
1708
1710
|
|
|
@@ -1914,7 +1916,7 @@ var Page = class {
|
|
|
1914
1916
|
}
|
|
1915
1917
|
async screenshotBase64() {
|
|
1916
1918
|
const { width, height } = await this.size();
|
|
1917
|
-
const path2 = (0,
|
|
1919
|
+
const path2 = (0, import_utils9.getTmpFile)("png");
|
|
1918
1920
|
const screenshotBuffer = await this.browser.saveScreenshot(path2);
|
|
1919
1921
|
const resizedScreenshotBuffer = await (0, import_img2.resizeImg)(screenshotBuffer, {
|
|
1920
1922
|
width,
|
|
@@ -338,10 +338,11 @@ module.exports = __toCommonJS(chrome_extension_exports);
|
|
|
338
338
|
var import_node_assert = __toESM(require("assert"));
|
|
339
339
|
var import_node_fs = require("fs");
|
|
340
340
|
var import_node_path = __toESM(require("path"));
|
|
341
|
+
var import_utils = require("@midscene/core/utils");
|
|
341
342
|
var import_constants = require("@midscene/shared/constants");
|
|
342
343
|
var import_fs = require("@midscene/shared/fs");
|
|
343
344
|
var import_img = require("@midscene/shared/img");
|
|
344
|
-
var
|
|
345
|
+
var import_utils2 = require("@midscene/shared/utils");
|
|
345
346
|
var import_dayjs = __toESM(require_dayjs_min());
|
|
346
347
|
|
|
347
348
|
// src/web-element.ts
|
|
@@ -376,6 +377,7 @@ async function parseContextFromWebPage(page, _opt) {
|
|
|
376
377
|
return await page._forceUsePageContext();
|
|
377
378
|
}
|
|
378
379
|
const url = await page.url();
|
|
380
|
+
(0, import_utils.uploadTestInfoToServer)({ testUrl: url });
|
|
379
381
|
let screenshotBase64;
|
|
380
382
|
let elementsInfo = [];
|
|
381
383
|
await Promise.all([
|
|
@@ -443,20 +445,20 @@ var ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED = "NOT_IMPLEMENTED_AS_DESIGNED";
|
|
|
443
445
|
// src/common/agent.ts
|
|
444
446
|
var import_core3 = require("@midscene/core");
|
|
445
447
|
var import_constants2 = require("@midscene/shared/constants");
|
|
446
|
-
var
|
|
448
|
+
var import_utils6 = require("@midscene/core/utils");
|
|
447
449
|
|
|
448
450
|
// src/common/tasks.ts
|
|
449
451
|
var import_node_assert2 = __toESM(require("assert"));
|
|
450
452
|
var import_core2 = require("@midscene/core");
|
|
451
|
-
var
|
|
453
|
+
var import_utils5 = require("@midscene/core/utils");
|
|
452
454
|
|
|
453
455
|
// src/common/task-cache.ts
|
|
454
456
|
var import_node_fs2 = require("fs");
|
|
455
457
|
var import_node_path2 = require("path");
|
|
456
458
|
var import_core = require("@midscene/core");
|
|
457
|
-
var
|
|
459
|
+
var import_utils3 = require("@midscene/core/utils");
|
|
458
460
|
var import_fs2 = require("@midscene/shared/fs");
|
|
459
|
-
var
|
|
461
|
+
var import_utils4 = require("@midscene/shared/utils");
|
|
460
462
|
var TaskCache = class {
|
|
461
463
|
constructor(opts) {
|
|
462
464
|
this.midscenePkgInfo = (0, import_fs2.getRunningPkgInfo)();
|
|
@@ -541,10 +543,10 @@ var TaskCache = class {
|
|
|
541
543
|
return this.newCache;
|
|
542
544
|
}
|
|
543
545
|
readCacheFromFile() {
|
|
544
|
-
if (
|
|
546
|
+
if (import_utils4.ifInBrowser || !this.cacheId) {
|
|
545
547
|
return void 0;
|
|
546
548
|
}
|
|
547
|
-
const cacheFile = (0, import_node_path2.join)((0,
|
|
549
|
+
const cacheFile = (0, import_node_path2.join)((0, import_utils3.getLogDirByType)("cache"), `${this.cacheId}.json`);
|
|
548
550
|
if ((0, import_core.getAIConfig)("MIDSCENE_CACHE") === "true" && (0, import_node_fs2.existsSync)(cacheFile)) {
|
|
549
551
|
try {
|
|
550
552
|
const data = (0, import_node_fs2.readFileSync)(cacheFile, "utf8");
|
|
@@ -567,11 +569,11 @@ var TaskCache = class {
|
|
|
567
569
|
if (!midscenePkgInfo || !this.cacheId) {
|
|
568
570
|
return;
|
|
569
571
|
}
|
|
570
|
-
if (!
|
|
571
|
-
(0,
|
|
572
|
+
if (!import_utils4.ifInBrowser) {
|
|
573
|
+
(0, import_utils3.writeLogFile)({
|
|
572
574
|
fileName: `${this.cacheId}`,
|
|
573
575
|
fileExt: "json",
|
|
574
|
-
fileContent: (0,
|
|
576
|
+
fileContent: (0, import_utils3.stringifyDumpData)(
|
|
575
577
|
{
|
|
576
578
|
pkgName: midscenePkgInfo.name,
|
|
577
579
|
pkgVersion: midscenePkgInfo.version,
|
|
@@ -616,7 +618,7 @@ var PageTaskExecutor = class {
|
|
|
616
618
|
recorder.push(shot);
|
|
617
619
|
const result = await taskApply.executor(param, context, ...args);
|
|
618
620
|
if (taskApply.type === "Action") {
|
|
619
|
-
await (0,
|
|
621
|
+
await (0, import_utils5.sleep)(300);
|
|
620
622
|
}
|
|
621
623
|
if (appendAfterExecution) {
|
|
622
624
|
const shot2 = await this.recordScreenshot("after Action");
|
|
@@ -831,7 +833,7 @@ var PageTaskExecutor = class {
|
|
|
831
833
|
subType: "Sleep",
|
|
832
834
|
param: plan2.param,
|
|
833
835
|
executor: async (taskParam) => {
|
|
834
|
-
await (0,
|
|
836
|
+
await (0, import_utils5.sleep)(taskParam.timeMs || 3e3);
|
|
835
837
|
}
|
|
836
838
|
};
|
|
837
839
|
return taskActionSleep;
|
|
@@ -1098,16 +1100,16 @@ var PageAgent = class {
|
|
|
1098
1100
|
dumpDataString() {
|
|
1099
1101
|
this.dump.groupName = this.opts.groupName;
|
|
1100
1102
|
this.dump.groupDescription = this.opts.groupDescription;
|
|
1101
|
-
return (0,
|
|
1103
|
+
return (0, import_utils6.stringifyDumpData)(this.dump);
|
|
1102
1104
|
}
|
|
1103
1105
|
reportHTMLString() {
|
|
1104
|
-
return (0,
|
|
1106
|
+
return (0, import_utils6.reportHTMLContent)(this.dumpDataString());
|
|
1105
1107
|
}
|
|
1106
1108
|
writeOutActionDumps() {
|
|
1107
1109
|
const { generateReport, autoPrintReportMsg } = this.opts;
|
|
1108
|
-
this.reportFile = (0,
|
|
1110
|
+
this.reportFile = (0, import_utils6.writeLogFile)({
|
|
1109
1111
|
fileName: this.reportFileName,
|
|
1110
|
-
fileExt:
|
|
1112
|
+
fileExt: import_utils6.groupedActionDumpFileExt,
|
|
1111
1113
|
fileContent: this.dumpDataString(),
|
|
1112
1114
|
type: "dump",
|
|
1113
1115
|
generateReport
|
|
@@ -1194,13 +1196,13 @@ var ChromeExtensionProxyPageAgent = class extends PageAgent {
|
|
|
1194
1196
|
|
|
1195
1197
|
// src/chrome-extension/page.ts
|
|
1196
1198
|
var import_node_fs3 = __toESM(require("fs"));
|
|
1197
|
-
var
|
|
1199
|
+
var import_utils9 = require("@midscene/shared/utils");
|
|
1198
1200
|
var scriptFileToRetrieve = "./lib/htmlElement.js";
|
|
1199
1201
|
var scriptFileContentCache = null;
|
|
1200
1202
|
var scriptFileContent = async () => {
|
|
1201
1203
|
if (scriptFileContentCache)
|
|
1202
1204
|
return scriptFileContentCache;
|
|
1203
|
-
if (
|
|
1205
|
+
if (import_utils9.ifInBrowser) {
|
|
1204
1206
|
const script = await fetch("/lib/htmlElement.js");
|
|
1205
1207
|
scriptFileContentCache = await script.text();
|
|
1206
1208
|
return scriptFileContentCache;
|
package/dist/lib/index.js
CHANGED
|
@@ -863,7 +863,7 @@ var import_node_crypto = require("crypto");
|
|
|
863
863
|
// src/common/agent.ts
|
|
864
864
|
var import_core3 = require("@midscene/core");
|
|
865
865
|
var import_constants2 = require("@midscene/shared/constants");
|
|
866
|
-
var
|
|
866
|
+
var import_utils6 = require("@midscene/core/utils");
|
|
867
867
|
|
|
868
868
|
// src/common/tasks.ts
|
|
869
869
|
var import_node_assert = __toESM(require("assert"));
|
|
@@ -1489,10 +1489,11 @@ var WebElementInfo = class {
|
|
|
1489
1489
|
var import_node_assert2 = __toESM(require("assert"));
|
|
1490
1490
|
var import_node_fs2 = require("fs");
|
|
1491
1491
|
var import_node_path2 = __toESM(require("path"));
|
|
1492
|
+
var import_utils4 = require("@midscene/core/utils");
|
|
1492
1493
|
var import_constants = require("@midscene/shared/constants");
|
|
1493
1494
|
var import_fs2 = require("@midscene/shared/fs");
|
|
1494
1495
|
var import_img = require("@midscene/shared/img");
|
|
1495
|
-
var
|
|
1496
|
+
var import_utils5 = require("@midscene/shared/utils");
|
|
1496
1497
|
var import_dayjs = __toESM(require_dayjs_min());
|
|
1497
1498
|
async function parseContextFromWebPage(page, _opt) {
|
|
1498
1499
|
(0, import_node_assert2.default)(page, "page is required");
|
|
@@ -1500,6 +1501,7 @@ async function parseContextFromWebPage(page, _opt) {
|
|
|
1500
1501
|
return await page._forceUsePageContext();
|
|
1501
1502
|
}
|
|
1502
1503
|
const url = await page.url();
|
|
1504
|
+
(0, import_utils4.uploadTestInfoToServer)({ testUrl: url });
|
|
1503
1505
|
let screenshotBase64;
|
|
1504
1506
|
let elementsInfo = [];
|
|
1505
1507
|
await Promise.all([
|
|
@@ -1628,16 +1630,16 @@ var PageAgent = class {
|
|
|
1628
1630
|
dumpDataString() {
|
|
1629
1631
|
this.dump.groupName = this.opts.groupName;
|
|
1630
1632
|
this.dump.groupDescription = this.opts.groupDescription;
|
|
1631
|
-
return (0,
|
|
1633
|
+
return (0, import_utils6.stringifyDumpData)(this.dump);
|
|
1632
1634
|
}
|
|
1633
1635
|
reportHTMLString() {
|
|
1634
|
-
return (0,
|
|
1636
|
+
return (0, import_utils6.reportHTMLContent)(this.dumpDataString());
|
|
1635
1637
|
}
|
|
1636
1638
|
writeOutActionDumps() {
|
|
1637
1639
|
const { generateReport, autoPrintReportMsg } = this.opts;
|
|
1638
|
-
this.reportFile = (0,
|
|
1640
|
+
this.reportFile = (0, import_utils6.writeLogFile)({
|
|
1639
1641
|
fileName: this.reportFileName,
|
|
1640
|
-
fileExt:
|
|
1642
|
+
fileExt: import_utils6.groupedActionDumpFileExt,
|
|
1641
1643
|
fileContent: this.dumpDataString(),
|
|
1642
1644
|
type: "dump",
|
|
1643
1645
|
generateReport
|
|
@@ -1868,7 +1870,7 @@ function waitForNetworkIdle(page) {
|
|
|
1868
1870
|
}
|
|
1869
1871
|
|
|
1870
1872
|
// src/puppeteer/base-page.ts
|
|
1871
|
-
var
|
|
1873
|
+
var import_utils9 = require("@midscene/core/utils");
|
|
1872
1874
|
var import_img2 = require("@midscene/shared/img");
|
|
1873
1875
|
var Page = class {
|
|
1874
1876
|
async evaluate(pageFunction, arg) {
|
|
@@ -1900,7 +1902,7 @@ var Page = class {
|
|
|
1900
1902
|
return sizeInfo;
|
|
1901
1903
|
}
|
|
1902
1904
|
async screenshotBase64() {
|
|
1903
|
-
const path3 = (0,
|
|
1905
|
+
const path3 = (0, import_utils9.getTmpFile)("png");
|
|
1904
1906
|
await this.underlyingPage.screenshot({
|
|
1905
1907
|
path: path3,
|
|
1906
1908
|
type: "png"
|
|
@@ -2005,7 +2007,7 @@ var PuppeteerAgent = class extends PageAgent {
|
|
|
2005
2007
|
|
|
2006
2008
|
// src/appium/page.ts
|
|
2007
2009
|
var import_node_fs3 = __toESM(require("fs"));
|
|
2008
|
-
var
|
|
2010
|
+
var import_utils11 = require("@midscene/core/utils");
|
|
2009
2011
|
var import_img3 = require("@midscene/shared/img");
|
|
2010
2012
|
var import_xmldom = require("@xmldom/xmldom");
|
|
2011
2013
|
|
|
@@ -2217,7 +2219,7 @@ var Page2 = class {
|
|
|
2217
2219
|
}
|
|
2218
2220
|
async screenshotBase64() {
|
|
2219
2221
|
const { width, height } = await this.size();
|
|
2220
|
-
const path3 = (0,
|
|
2222
|
+
const path3 = (0, import_utils11.getTmpFile)("png");
|
|
2221
2223
|
const screenshotBuffer = await this.browser.saveScreenshot(path3);
|
|
2222
2224
|
const resizedScreenshotBuffer = await (0, import_img3.resizeImg)(screenshotBuffer, {
|
|
2223
2225
|
width,
|
|
@@ -669,10 +669,11 @@ var import_node_path3 = require("path");
|
|
|
669
669
|
var import_node_assert = __toESM(require("assert"));
|
|
670
670
|
var import_node_fs = require("fs");
|
|
671
671
|
var import_node_path = __toESM(require("path"));
|
|
672
|
+
var import_utils = require("@midscene/core/utils");
|
|
672
673
|
var import_constants = require("@midscene/shared/constants");
|
|
673
674
|
var import_fs = require("@midscene/shared/fs");
|
|
674
675
|
var import_img = require("@midscene/shared/img");
|
|
675
|
-
var
|
|
676
|
+
var import_utils2 = require("@midscene/shared/utils");
|
|
676
677
|
var import_dayjs = __toESM(require_dayjs_min());
|
|
677
678
|
|
|
678
679
|
// src/web-element.ts
|
|
@@ -707,6 +708,7 @@ async function parseContextFromWebPage(page, _opt) {
|
|
|
707
708
|
return await page._forceUsePageContext();
|
|
708
709
|
}
|
|
709
710
|
const url = await page.url();
|
|
711
|
+
(0, import_utils.uploadTestInfoToServer)({ testUrl: url });
|
|
710
712
|
let screenshotBase64;
|
|
711
713
|
let elementsInfo = [];
|
|
712
714
|
await Promise.all([
|
|
@@ -772,28 +774,28 @@ function printReportMsg(filepath) {
|
|
|
772
774
|
var ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED = "NOT_IMPLEMENTED_AS_DESIGNED";
|
|
773
775
|
|
|
774
776
|
// src/playground/server.ts
|
|
775
|
-
var
|
|
776
|
-
var
|
|
777
|
+
var import_utils11 = require("@midscene/core/utils");
|
|
778
|
+
var import_utils12 = require("@midscene/shared/utils");
|
|
777
779
|
var import_cors = __toESM(require("cors"));
|
|
778
780
|
var import_express = __toESM(require("express"));
|
|
779
781
|
|
|
780
782
|
// src/common/agent.ts
|
|
781
783
|
var import_core3 = require("@midscene/core");
|
|
782
784
|
var import_constants2 = require("@midscene/shared/constants");
|
|
783
|
-
var
|
|
785
|
+
var import_utils6 = require("@midscene/core/utils");
|
|
784
786
|
|
|
785
787
|
// src/common/tasks.ts
|
|
786
788
|
var import_node_assert2 = __toESM(require("assert"));
|
|
787
789
|
var import_core2 = require("@midscene/core");
|
|
788
|
-
var
|
|
790
|
+
var import_utils5 = require("@midscene/core/utils");
|
|
789
791
|
|
|
790
792
|
// src/common/task-cache.ts
|
|
791
793
|
var import_node_fs2 = require("fs");
|
|
792
794
|
var import_node_path2 = require("path");
|
|
793
795
|
var import_core = require("@midscene/core");
|
|
794
|
-
var
|
|
796
|
+
var import_utils3 = require("@midscene/core/utils");
|
|
795
797
|
var import_fs2 = require("@midscene/shared/fs");
|
|
796
|
-
var
|
|
798
|
+
var import_utils4 = require("@midscene/shared/utils");
|
|
797
799
|
var TaskCache = class {
|
|
798
800
|
constructor(opts) {
|
|
799
801
|
this.midscenePkgInfo = (0, import_fs2.getRunningPkgInfo)();
|
|
@@ -878,10 +880,10 @@ var TaskCache = class {
|
|
|
878
880
|
return this.newCache;
|
|
879
881
|
}
|
|
880
882
|
readCacheFromFile() {
|
|
881
|
-
if (
|
|
883
|
+
if (import_utils4.ifInBrowser || !this.cacheId) {
|
|
882
884
|
return void 0;
|
|
883
885
|
}
|
|
884
|
-
const cacheFile = (0, import_node_path2.join)((0,
|
|
886
|
+
const cacheFile = (0, import_node_path2.join)((0, import_utils3.getLogDirByType)("cache"), `${this.cacheId}.json`);
|
|
885
887
|
if ((0, import_core.getAIConfig)("MIDSCENE_CACHE") === "true" && (0, import_node_fs2.existsSync)(cacheFile)) {
|
|
886
888
|
try {
|
|
887
889
|
const data = (0, import_node_fs2.readFileSync)(cacheFile, "utf8");
|
|
@@ -904,11 +906,11 @@ var TaskCache = class {
|
|
|
904
906
|
if (!midscenePkgInfo || !this.cacheId) {
|
|
905
907
|
return;
|
|
906
908
|
}
|
|
907
|
-
if (!
|
|
908
|
-
(0,
|
|
909
|
+
if (!import_utils4.ifInBrowser) {
|
|
910
|
+
(0, import_utils3.writeLogFile)({
|
|
909
911
|
fileName: `${this.cacheId}`,
|
|
910
912
|
fileExt: "json",
|
|
911
|
-
fileContent: (0,
|
|
913
|
+
fileContent: (0, import_utils3.stringifyDumpData)(
|
|
912
914
|
{
|
|
913
915
|
pkgName: midscenePkgInfo.name,
|
|
914
916
|
pkgVersion: midscenePkgInfo.version,
|
|
@@ -953,7 +955,7 @@ var PageTaskExecutor = class {
|
|
|
953
955
|
recorder.push(shot);
|
|
954
956
|
const result = await taskApply.executor(param, context, ...args);
|
|
955
957
|
if (taskApply.type === "Action") {
|
|
956
|
-
await (0,
|
|
958
|
+
await (0, import_utils5.sleep)(300);
|
|
957
959
|
}
|
|
958
960
|
if (appendAfterExecution) {
|
|
959
961
|
const shot2 = await this.recordScreenshot("after Action");
|
|
@@ -1168,7 +1170,7 @@ var PageTaskExecutor = class {
|
|
|
1168
1170
|
subType: "Sleep",
|
|
1169
1171
|
param: plan2.param,
|
|
1170
1172
|
executor: async (taskParam) => {
|
|
1171
|
-
await (0,
|
|
1173
|
+
await (0, import_utils5.sleep)(taskParam.timeMs || 3e3);
|
|
1172
1174
|
}
|
|
1173
1175
|
};
|
|
1174
1176
|
return taskActionSleep;
|
|
@@ -1435,16 +1437,16 @@ var PageAgent = class {
|
|
|
1435
1437
|
dumpDataString() {
|
|
1436
1438
|
this.dump.groupName = this.opts.groupName;
|
|
1437
1439
|
this.dump.groupDescription = this.opts.groupDescription;
|
|
1438
|
-
return (0,
|
|
1440
|
+
return (0, import_utils6.stringifyDumpData)(this.dump);
|
|
1439
1441
|
}
|
|
1440
1442
|
reportHTMLString() {
|
|
1441
|
-
return (0,
|
|
1443
|
+
return (0, import_utils6.reportHTMLContent)(this.dumpDataString());
|
|
1442
1444
|
}
|
|
1443
1445
|
writeOutActionDumps() {
|
|
1444
1446
|
const { generateReport, autoPrintReportMsg } = this.opts;
|
|
1445
|
-
this.reportFile = (0,
|
|
1447
|
+
this.reportFile = (0, import_utils6.writeLogFile)({
|
|
1446
1448
|
fileName: this.reportFileName,
|
|
1447
|
-
fileExt:
|
|
1449
|
+
fileExt: import_utils6.groupedActionDumpFileExt,
|
|
1448
1450
|
fileContent: this.dumpDataString(),
|
|
1449
1451
|
type: "dump",
|
|
1450
1452
|
generateReport
|
|
@@ -1598,7 +1600,7 @@ var errorHandler = (err, req, res, next) => {
|
|
|
1598
1600
|
});
|
|
1599
1601
|
};
|
|
1600
1602
|
var setup = async () => {
|
|
1601
|
-
if (!
|
|
1603
|
+
if (!import_utils12.ifInBrowser) {
|
|
1602
1604
|
const dotenv = await Promise.resolve().then(() => __toESM(require_main()));
|
|
1603
1605
|
dotenv.config();
|
|
1604
1606
|
}
|
|
@@ -1606,7 +1608,7 @@ var setup = async () => {
|
|
|
1606
1608
|
var PlaygroundServer = class {
|
|
1607
1609
|
constructor() {
|
|
1608
1610
|
this.app = (0, import_express.default)();
|
|
1609
|
-
this.tmpDir = (0,
|
|
1611
|
+
this.tmpDir = (0, import_utils11.getTmpDir)();
|
|
1610
1612
|
setup();
|
|
1611
1613
|
}
|
|
1612
1614
|
filePathForUuid(uuid2) {
|
package/dist/lib/playground.js
CHANGED
|
@@ -338,10 +338,11 @@ module.exports = __toCommonJS(playground_exports);
|
|
|
338
338
|
var import_node_assert = __toESM(require("assert"));
|
|
339
339
|
var import_node_fs = require("fs");
|
|
340
340
|
var import_node_path = __toESM(require("path"));
|
|
341
|
+
var import_utils = require("@midscene/core/utils");
|
|
341
342
|
var import_constants = require("@midscene/shared/constants");
|
|
342
343
|
var import_fs = require("@midscene/shared/fs");
|
|
343
344
|
var import_img = require("@midscene/shared/img");
|
|
344
|
-
var
|
|
345
|
+
var import_utils2 = require("@midscene/shared/utils");
|
|
345
346
|
var import_dayjs = __toESM(require_dayjs_min());
|
|
346
347
|
|
|
347
348
|
// src/web-element.ts
|
|
@@ -376,6 +377,7 @@ async function parseContextFromWebPage(page, _opt) {
|
|
|
376
377
|
return await page._forceUsePageContext();
|
|
377
378
|
}
|
|
378
379
|
const url = await page.url();
|
|
380
|
+
(0, import_utils.uploadTestInfoToServer)({ testUrl: url });
|
|
379
381
|
let screenshotBase64;
|
|
380
382
|
let elementsInfo = [];
|
|
381
383
|
await Promise.all([
|
|
@@ -443,20 +445,20 @@ var ERROR_CODE_NOT_IMPLEMENTED_AS_DESIGNED = "NOT_IMPLEMENTED_AS_DESIGNED";
|
|
|
443
445
|
// src/common/agent.ts
|
|
444
446
|
var import_core3 = require("@midscene/core");
|
|
445
447
|
var import_constants2 = require("@midscene/shared/constants");
|
|
446
|
-
var
|
|
448
|
+
var import_utils6 = require("@midscene/core/utils");
|
|
447
449
|
|
|
448
450
|
// src/common/tasks.ts
|
|
449
451
|
var import_node_assert2 = __toESM(require("assert"));
|
|
450
452
|
var import_core2 = require("@midscene/core");
|
|
451
|
-
var
|
|
453
|
+
var import_utils5 = require("@midscene/core/utils");
|
|
452
454
|
|
|
453
455
|
// src/common/task-cache.ts
|
|
454
456
|
var import_node_fs2 = require("fs");
|
|
455
457
|
var import_node_path2 = require("path");
|
|
456
458
|
var import_core = require("@midscene/core");
|
|
457
|
-
var
|
|
459
|
+
var import_utils3 = require("@midscene/core/utils");
|
|
458
460
|
var import_fs2 = require("@midscene/shared/fs");
|
|
459
|
-
var
|
|
461
|
+
var import_utils4 = require("@midscene/shared/utils");
|
|
460
462
|
var TaskCache = class {
|
|
461
463
|
constructor(opts) {
|
|
462
464
|
this.midscenePkgInfo = (0, import_fs2.getRunningPkgInfo)();
|
|
@@ -541,10 +543,10 @@ var TaskCache = class {
|
|
|
541
543
|
return this.newCache;
|
|
542
544
|
}
|
|
543
545
|
readCacheFromFile() {
|
|
544
|
-
if (
|
|
546
|
+
if (import_utils4.ifInBrowser || !this.cacheId) {
|
|
545
547
|
return void 0;
|
|
546
548
|
}
|
|
547
|
-
const cacheFile = (0, import_node_path2.join)((0,
|
|
549
|
+
const cacheFile = (0, import_node_path2.join)((0, import_utils3.getLogDirByType)("cache"), `${this.cacheId}.json`);
|
|
548
550
|
if ((0, import_core.getAIConfig)("MIDSCENE_CACHE") === "true" && (0, import_node_fs2.existsSync)(cacheFile)) {
|
|
549
551
|
try {
|
|
550
552
|
const data = (0, import_node_fs2.readFileSync)(cacheFile, "utf8");
|
|
@@ -567,11 +569,11 @@ var TaskCache = class {
|
|
|
567
569
|
if (!midscenePkgInfo || !this.cacheId) {
|
|
568
570
|
return;
|
|
569
571
|
}
|
|
570
|
-
if (!
|
|
571
|
-
(0,
|
|
572
|
+
if (!import_utils4.ifInBrowser) {
|
|
573
|
+
(0, import_utils3.writeLogFile)({
|
|
572
574
|
fileName: `${this.cacheId}`,
|
|
573
575
|
fileExt: "json",
|
|
574
|
-
fileContent: (0,
|
|
576
|
+
fileContent: (0, import_utils3.stringifyDumpData)(
|
|
575
577
|
{
|
|
576
578
|
pkgName: midscenePkgInfo.name,
|
|
577
579
|
pkgVersion: midscenePkgInfo.version,
|
|
@@ -616,7 +618,7 @@ var PageTaskExecutor = class {
|
|
|
616
618
|
recorder.push(shot);
|
|
617
619
|
const result = await taskApply.executor(param, context, ...args);
|
|
618
620
|
if (taskApply.type === "Action") {
|
|
619
|
-
await (0,
|
|
621
|
+
await (0, import_utils5.sleep)(300);
|
|
620
622
|
}
|
|
621
623
|
if (appendAfterExecution) {
|
|
622
624
|
const shot2 = await this.recordScreenshot("after Action");
|
|
@@ -831,7 +833,7 @@ var PageTaskExecutor = class {
|
|
|
831
833
|
subType: "Sleep",
|
|
832
834
|
param: plan2.param,
|
|
833
835
|
executor: async (taskParam) => {
|
|
834
|
-
await (0,
|
|
836
|
+
await (0, import_utils5.sleep)(taskParam.timeMs || 3e3);
|
|
835
837
|
}
|
|
836
838
|
};
|
|
837
839
|
return taskActionSleep;
|
|
@@ -1098,16 +1100,16 @@ var PageAgent = class {
|
|
|
1098
1100
|
dumpDataString() {
|
|
1099
1101
|
this.dump.groupName = this.opts.groupName;
|
|
1100
1102
|
this.dump.groupDescription = this.opts.groupDescription;
|
|
1101
|
-
return (0,
|
|
1103
|
+
return (0, import_utils6.stringifyDumpData)(this.dump);
|
|
1102
1104
|
}
|
|
1103
1105
|
reportHTMLString() {
|
|
1104
|
-
return (0,
|
|
1106
|
+
return (0, import_utils6.reportHTMLContent)(this.dumpDataString());
|
|
1105
1107
|
}
|
|
1106
1108
|
writeOutActionDumps() {
|
|
1107
1109
|
const { generateReport, autoPrintReportMsg } = this.opts;
|
|
1108
|
-
this.reportFile = (0,
|
|
1110
|
+
this.reportFile = (0, import_utils6.writeLogFile)({
|
|
1109
1111
|
fileName: this.reportFileName,
|
|
1110
|
-
fileExt:
|
|
1112
|
+
fileExt: import_utils6.groupedActionDumpFileExt,
|
|
1111
1113
|
fileContent: this.dumpDataString(),
|
|
1112
1114
|
type: "dump",
|
|
1113
1115
|
generateReport
|
|
@@ -336,10 +336,11 @@ module.exports = __toCommonJS(reporter_exports);
|
|
|
336
336
|
var import_node_assert = __toESM(require("assert"));
|
|
337
337
|
var import_node_fs = require("fs");
|
|
338
338
|
var import_node_path = __toESM(require("path"));
|
|
339
|
+
var import_utils = require("@midscene/core/utils");
|
|
339
340
|
var import_constants = require("@midscene/shared/constants");
|
|
340
341
|
var import_fs = require("@midscene/shared/fs");
|
|
341
342
|
var import_img = require("@midscene/shared/img");
|
|
342
|
-
var
|
|
343
|
+
var import_utils2 = require("@midscene/shared/utils");
|
|
343
344
|
var import_dayjs = __toESM(require_dayjs_min());
|
|
344
345
|
function reportFileName(tag = "web") {
|
|
345
346
|
const dateTimeInFileName = (0, import_dayjs.default)().format("YYYY-MM-DD_HH-mm-ss-SSS");
|
|
@@ -350,7 +351,7 @@ function printReportMsg(filepath) {
|
|
|
350
351
|
}
|
|
351
352
|
|
|
352
353
|
// src/playwright/reporter/index.ts
|
|
353
|
-
var
|
|
354
|
+
var import_utils4 = require("@midscene/core/utils");
|
|
354
355
|
function logger(...message) {
|
|
355
356
|
if (process.env.DEBUG === "true") {
|
|
356
357
|
console.log("Midscene e2e report:", ...message);
|
|
@@ -359,7 +360,7 @@ function logger(...message) {
|
|
|
359
360
|
var testDataList = [];
|
|
360
361
|
var filename;
|
|
361
362
|
function updateReport() {
|
|
362
|
-
const reportPath = (0,
|
|
363
|
+
const reportPath = (0, import_utils4.writeDumpReport)(filename, testDataList);
|
|
363
364
|
reportPath && printReportMsg(reportPath);
|
|
364
365
|
}
|
|
365
366
|
var MidsceneReporter = class {
|