testaro 52.0.1 → 52.0.2
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/dirWatch.js +0 -1
- package/package.json +1 -1
- package/procs/doTestAct.js +3 -1
- package/procs/identify.js +7 -9
- package/run.js +28 -11
package/dirWatch.js
CHANGED
|
@@ -99,7 +99,6 @@ const wait = ms => {
|
|
|
99
99
|
exports.dirWatch = async (isForever, intervalInSeconds) => {
|
|
100
100
|
intervalInSeconds ||= 5;
|
|
101
101
|
intervalInSeconds = Math.max(intervalInSeconds, 5);
|
|
102
|
-
console.log(intervalInSeconds);
|
|
103
102
|
console.log(`Starting to watch directory ${jobDir}/todo for jobs`);
|
|
104
103
|
let notYetRun = true;
|
|
105
104
|
// As long as watching as to continue:
|
package/package.json
CHANGED
package/procs/doTestAct.js
CHANGED
|
@@ -44,6 +44,8 @@ const waits = Number.parseInt(process.env.WAITS) || 0;
|
|
|
44
44
|
|
|
45
45
|
const actIndex = Number.parseInt(process.argv[2]);
|
|
46
46
|
|
|
47
|
+
// FUNCTIONS
|
|
48
|
+
|
|
47
49
|
const doTestAct = async () => {
|
|
48
50
|
const reportPath = `${__dirname}/../temp/report.json`;
|
|
49
51
|
// Get the saved report.
|
|
@@ -53,7 +55,7 @@ const doTestAct = async () => {
|
|
|
53
55
|
const act = report.acts[actIndex];
|
|
54
56
|
// Get the tool name.
|
|
55
57
|
const {which} = act;
|
|
56
|
-
// Launch a browser, navigate to the URL, and redefine the page of the run module.
|
|
58
|
+
// Launch a browser, navigate to the URL, and redefine the page export of the run module.
|
|
57
59
|
await launch(
|
|
58
60
|
report,
|
|
59
61
|
debug,
|
package/procs/identify.js
CHANGED
|
@@ -33,8 +33,6 @@
|
|
|
33
33
|
const getPath = {
|
|
34
34
|
xPath: require('playwright-dompath').xPath
|
|
35
35
|
};
|
|
36
|
-
// Utility module.
|
|
37
|
-
const {doBy} = require('./job');
|
|
38
36
|
|
|
39
37
|
// FUNCTIONS
|
|
40
38
|
|
|
@@ -83,10 +81,13 @@ const addIDs = async (locators, recipient) => {
|
|
|
83
81
|
const box = await boxOf(locators);
|
|
84
82
|
recipient.boxID = boxToString(box);
|
|
85
83
|
}
|
|
86
|
-
//
|
|
84
|
+
// If the element has no path ID yet in the result:
|
|
87
85
|
if (! recipient.pathID) {
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
// Add it to the result.
|
|
87
|
+
const pathIDPromise = getPath.xPath(locators);
|
|
88
|
+
const timeoutPromise = setTimeout(() => true, 1000);
|
|
89
|
+
const pathID = Promise.race([pathIDPromise, timeoutPromise]);
|
|
90
|
+
if (typeof pathID === 'string') {
|
|
90
91
|
recipient.pathID = pathID;
|
|
91
92
|
}
|
|
92
93
|
}
|
|
@@ -159,10 +160,7 @@ exports.identify = async (instance, page) => {
|
|
|
159
160
|
}
|
|
160
161
|
// If either ID remains undefined and the instance specifies an element ID:
|
|
161
162
|
if (id && ! (elementID.boxID && elementID.pathID)) {
|
|
162
|
-
|
|
163
|
-
Get the first locator for an element with the ID, or throw an error if the identifier is
|
|
164
|
-
invalid.
|
|
165
|
-
*/
|
|
163
|
+
// Get the first locator for an element with the ID.
|
|
166
164
|
try {
|
|
167
165
|
let locator = page.locator(`#${id.replace(/([-&;/]|^\d)/g, '\\$1')}`).first();
|
|
168
166
|
// Add a box ID and a path ID to the result.
|
package/run.js
CHANGED
|
@@ -197,7 +197,7 @@ const browserClose = async () => {
|
|
|
197
197
|
browser = null;
|
|
198
198
|
}
|
|
199
199
|
};
|
|
200
|
-
// Launches a browser
|
|
200
|
+
// Launches a browser and navigates to a URL.
|
|
201
201
|
const launch = exports.launch = async (report, debug, waits, tempBrowserID, tempURL) => {
|
|
202
202
|
const act = report.acts[actIndex];
|
|
203
203
|
const {device} = report;
|
|
@@ -674,16 +674,33 @@ const doActs = async (report) => {
|
|
|
674
674
|
};
|
|
675
675
|
// Populate it.
|
|
676
676
|
standardize(act);
|
|
677
|
-
//
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
677
|
+
// Launch a browser and navigate to the page.
|
|
678
|
+
await launch(
|
|
679
|
+
report,
|
|
680
|
+
debug,
|
|
681
|
+
waits,
|
|
682
|
+
act.browserID || report.browserID || '',
|
|
683
|
+
act.target && act.target.url || report.target && report.target.url || ''
|
|
684
|
+
);
|
|
685
|
+
// If this failed:
|
|
686
|
+
if (page.prevented) {
|
|
687
|
+
// Add this to the act.
|
|
688
|
+
act.prevented = true;
|
|
689
|
+
act.error = page.error || '';
|
|
690
|
+
}
|
|
691
|
+
// Otherwise, i.e. if it succeeded:
|
|
692
|
+
else {
|
|
693
|
+
// Add a box ID and a path ID to each of its standard instances if missing.
|
|
694
|
+
for (const instance of act.standardResult.instances) {
|
|
695
|
+
const elementID = await identify(instance, page);
|
|
696
|
+
if (! instance.boxID) {
|
|
697
|
+
instance.boxID = elementID ? elementID.boxID : '';
|
|
698
|
+
}
|
|
699
|
+
if (! instance.pathID) {
|
|
700
|
+
instance.pathID = elementID ? elementID.pathID : '';
|
|
701
|
+
}
|
|
702
|
+
};
|
|
703
|
+
}
|
|
687
704
|
// If the original-format result is not to be included in the report:
|
|
688
705
|
if (standard === 'only') {
|
|
689
706
|
// Remove it.
|