@kogeet/sagent-playwright 0.1.0 → 0.2.0
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/bin/libs/StdLib.d.ts +39 -0
- package/bin/libs/StdLib.d.ts.map +1 -1
- package/bin/libs/StdLib.js +202 -1
- package/package.json +1 -1
package/bin/libs/StdLib.d.ts
CHANGED
|
@@ -25,6 +25,13 @@ export default class StdLib {
|
|
|
25
25
|
* @param stepCtx Paramètre du step
|
|
26
26
|
*/
|
|
27
27
|
static elemHasText(stepCtx: StepContext): Promise<boolean>;
|
|
28
|
+
/**
|
|
29
|
+
* **Recherche d'un texte dans un élément texte statique**
|
|
30
|
+
*
|
|
31
|
+
* En réserve d'implémentation dans une instruction.
|
|
32
|
+
* @param stepCtx Paramètres du step
|
|
33
|
+
*/
|
|
34
|
+
static elemMatchText(stepCtx: StepContext): Promise<boolean>;
|
|
28
35
|
/**
|
|
29
36
|
* **Implémentation de l'instruction de contrôle IsVisible**
|
|
30
37
|
* @param stepCtx Paramètre du step
|
|
@@ -71,5 +78,37 @@ export default class StdLib {
|
|
|
71
78
|
* @param stepCtx Paramètre du step
|
|
72
79
|
*/
|
|
73
80
|
static calculator(stepCtx: StepContext): Promise<boolean>;
|
|
81
|
+
/**
|
|
82
|
+
* **Sélectionne l'option d'une combobox par son texte affiché**
|
|
83
|
+
* @param stepCtx Paramètres du step
|
|
84
|
+
*/
|
|
85
|
+
static selectCountOptions(stepCtx: StepContext): Promise<boolean>;
|
|
86
|
+
/**
|
|
87
|
+
* **Sélectionne l'option d'une combobox par son texte affiché**
|
|
88
|
+
* @param stepCtx Paramètres du step
|
|
89
|
+
*/
|
|
90
|
+
static selectHasCountOptions(stepCtx: StepContext): Promise<boolean>;
|
|
91
|
+
/**
|
|
92
|
+
* **Sélectionne l'option d'une combobox par son texte affiché**
|
|
93
|
+
* @param stepCtx Paramètres du step
|
|
94
|
+
*/
|
|
95
|
+
static selectByText(stepCtx: StepContext): Promise<boolean>;
|
|
96
|
+
/**
|
|
97
|
+
* **Sélectionne l'option d'une combobox par son texte affiché**
|
|
98
|
+
* @param stepCtx Paramètres du step
|
|
99
|
+
*/
|
|
100
|
+
static selectByValue(stepCtx: StepContext): Promise<boolean>;
|
|
101
|
+
/**
|
|
102
|
+
* **Sélectionne l'option d'une combobox par son texte affiché**
|
|
103
|
+
* @param stepCtx Paramètres du step
|
|
104
|
+
*/
|
|
105
|
+
static selectByIndex(stepCtx: StepContext): Promise<boolean>;
|
|
106
|
+
/**
|
|
107
|
+
* **Sélectionne l'option d'une combobox par son texte affiché**
|
|
108
|
+
* @param stepCtx Paramètres du step
|
|
109
|
+
*/
|
|
110
|
+
static selectHasOption(stepCtx: StepContext): Promise<boolean>;
|
|
111
|
+
static uploadFile(stepCtx: StepContext): Promise<boolean>;
|
|
112
|
+
static downloadFile(stepCtx: StepContext): Promise<boolean>;
|
|
74
113
|
}
|
|
75
114
|
//# sourceMappingURL=StdLib.d.ts.map
|
package/bin/libs/StdLib.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StdLib.d.ts","sourceRoot":"","sources":["../../src/libs/StdLib.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,2BAA2B,CAAC;AAM3D,MAAM,CAAC,OAAO,OAAO,MAAM;IAEzB,OAAc,WAAW,
|
|
1
|
+
{"version":3,"file":"StdLib.d.ts","sourceRoot":"","sources":["../../src/libs/StdLib.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,2BAA2B,CAAC;AAM3D,MAAM,CAAC,OAAO,OAAO,MAAM;IAEzB,OAAc,WAAW,uCAsBvB;IAEF;;;OAGG;WACiB,SAAS,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;IAarE;;;OAGG;WACiB,WAAW,CAAC,OAAO,EAAE,WAAW;IAiBpD;;;;;OAKG;WACiB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AO,CAAC,OAAO,CAAC;CAyBzE"}
|
package/bin/libs/StdLib.js
CHANGED
|
@@ -7,14 +7,23 @@ export default class StdLib {
|
|
|
7
7
|
['elemSetText', StdLib.elemSetText],
|
|
8
8
|
['elemGetText', StdLib.elemGetText],
|
|
9
9
|
['elemHasText', StdLib.elemHasText],
|
|
10
|
+
['elemMatchText', StdLib.elemMatchText],
|
|
10
11
|
['elemIsVisible', StdLib.elemIsVisible],
|
|
11
12
|
['elemIsEnabled', StdLib.elemIsEnabled],
|
|
12
13
|
['elemHasState', StdLib.elemHasState],
|
|
13
14
|
['elemGetState', StdLib.elemGetState],
|
|
14
15
|
['elemSetState', StdLib.elemSetState],
|
|
15
16
|
['elemClickToNew', StdLib.elemClickToNew],
|
|
17
|
+
['selectHasOption', StdLib.selectHasOption],
|
|
18
|
+
['selectCountOptions', StdLib.selectCountOptions],
|
|
19
|
+
['selectHasCountOptions', StdLib.selectHasCountOptions],
|
|
20
|
+
['selectByText', StdLib.selectByText],
|
|
21
|
+
['selectByValue', StdLib.selectByValue],
|
|
22
|
+
['selectByIndex', StdLib.selectByIndex],
|
|
16
23
|
['wait', StdLib.wait],
|
|
17
|
-
['calculator', StdLib.calculator]
|
|
24
|
+
['calculator', StdLib.calculator],
|
|
25
|
+
['uploadFile', StdLib.uploadFile],
|
|
26
|
+
['downloadFile', StdLib.downloadFile]
|
|
18
27
|
]);
|
|
19
28
|
/**
|
|
20
29
|
* **Implémentation de l'instruction d'action Click**
|
|
@@ -95,6 +104,32 @@ export default class StdLib {
|
|
|
95
104
|
}
|
|
96
105
|
});
|
|
97
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* **Recherche d'un texte dans un élément texte statique**
|
|
109
|
+
*
|
|
110
|
+
* En réserve d'implémentation dans une instruction.
|
|
111
|
+
* @param stepCtx Paramètres du step
|
|
112
|
+
*/
|
|
113
|
+
static async elemMatchText(stepCtx) {
|
|
114
|
+
return await uiWrapper(stepCtx, async (stepCtx, elem) => {
|
|
115
|
+
try {
|
|
116
|
+
const text = await elem.innerText();
|
|
117
|
+
const regex = new RegExp(stepCtx.getStringParam('0'), stepCtx.getStringParam('1', ''));
|
|
118
|
+
const found = text ? text.match(regex) : false;
|
|
119
|
+
if (found) {
|
|
120
|
+
context.setVariable(stepCtx.getStringParam('2'), found.length);
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
catch (e) {
|
|
128
|
+
report.warning(`Paywright error on 'FindText' instruction : ${e.message}`);
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}
|
|
98
133
|
/**
|
|
99
134
|
* **Implémentation de l'instruction de contrôle IsVisible**
|
|
100
135
|
* @param stepCtx Paramètre du step
|
|
@@ -224,6 +259,172 @@ export default class StdLib {
|
|
|
224
259
|
context.setVariable(stepCtx.getStringParam('1'), stepCtx.getParam('0'));
|
|
225
260
|
return true;
|
|
226
261
|
}
|
|
262
|
+
/**
|
|
263
|
+
* **Sélectionne l'option d'une combobox par son texte affiché**
|
|
264
|
+
* @param stepCtx Paramètres du step
|
|
265
|
+
*/
|
|
266
|
+
static async selectCountOptions(stepCtx) {
|
|
267
|
+
return await uiWrapper(stepCtx, async (stepCtx, elem) => {
|
|
268
|
+
try {
|
|
269
|
+
const options = elem.getByRole('option');
|
|
270
|
+
context.setVariable(stepCtx.getStringParam('0'), await options.count());
|
|
271
|
+
return true;
|
|
272
|
+
}
|
|
273
|
+
catch (e) {
|
|
274
|
+
report.warning(`Paywright error on 'SelectByText' instruction : ${e.message}`);
|
|
275
|
+
return false;
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* **Sélectionne l'option d'une combobox par son texte affiché**
|
|
281
|
+
* @param stepCtx Paramètres du step
|
|
282
|
+
*/
|
|
283
|
+
static async selectHasCountOptions(stepCtx) {
|
|
284
|
+
return await uiWrapper(stepCtx, async (stepCtx, elem) => {
|
|
285
|
+
try {
|
|
286
|
+
const options = elem.getByRole('option');
|
|
287
|
+
return await options.count() === stepCtx.getParam('0', true);
|
|
288
|
+
}
|
|
289
|
+
catch (e) {
|
|
290
|
+
report.warning(`Paywright error on 'SelectByText' instruction : ${e.message}`);
|
|
291
|
+
return false;
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* **Sélectionne l'option d'une combobox par son texte affiché**
|
|
297
|
+
* @param stepCtx Paramètres du step
|
|
298
|
+
*/
|
|
299
|
+
static async selectByText(stepCtx) {
|
|
300
|
+
return await uiWrapper(stepCtx, async (stepCtx, elem) => {
|
|
301
|
+
try {
|
|
302
|
+
const label = stepCtx.getStringParam('0');
|
|
303
|
+
await elem.selectOption({ label });
|
|
304
|
+
return true;
|
|
305
|
+
}
|
|
306
|
+
catch (e) {
|
|
307
|
+
report.warning(`Paywright error on 'SelectByText' instruction : ${e.message}`);
|
|
308
|
+
return false;
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* **Sélectionne l'option d'une combobox par son texte affiché**
|
|
314
|
+
* @param stepCtx Paramètres du step
|
|
315
|
+
*/
|
|
316
|
+
static async selectByValue(stepCtx) {
|
|
317
|
+
return await uiWrapper(stepCtx, async (stepCtx, elem) => {
|
|
318
|
+
try {
|
|
319
|
+
const value = stepCtx.getStringParam('0');
|
|
320
|
+
await elem.selectOption({ value });
|
|
321
|
+
return true;
|
|
322
|
+
}
|
|
323
|
+
catch (e) {
|
|
324
|
+
report.warning(`Paywright error on 'SelectByText' instruction : ${e.message}`);
|
|
325
|
+
return false;
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* **Sélectionne l'option d'une combobox par son texte affiché**
|
|
331
|
+
* @param stepCtx Paramètres du step
|
|
332
|
+
*/
|
|
333
|
+
static async selectByIndex(stepCtx) {
|
|
334
|
+
return await uiWrapper(stepCtx, async (stepCtx, elem) => {
|
|
335
|
+
try {
|
|
336
|
+
const index = +stepCtx.getStringParam('0');
|
|
337
|
+
await elem.selectOption({ index });
|
|
338
|
+
return true;
|
|
339
|
+
}
|
|
340
|
+
catch (e) {
|
|
341
|
+
report.warning(`Paywright error on 'SelectByText' instruction : ${e.message}`);
|
|
342
|
+
return false;
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* **Sélectionne l'option d'une combobox par son texte affiché**
|
|
348
|
+
* @param stepCtx Paramètres du step
|
|
349
|
+
*/
|
|
350
|
+
static async selectHasOption(stepCtx) {
|
|
351
|
+
return await uiWrapper(stepCtx, async (stepCtx, elem) => {
|
|
352
|
+
try {
|
|
353
|
+
const by = stepCtx.getStringParam('0');
|
|
354
|
+
const data = stepCtx.getStringParam('1');
|
|
355
|
+
switch (by) {
|
|
356
|
+
case 'name':
|
|
357
|
+
await elem.selectOption({ label: `/${data}/` });
|
|
358
|
+
return true;
|
|
359
|
+
case 'value':
|
|
360
|
+
await elem.selectOption({ value: `/${data}/` });
|
|
361
|
+
return true;
|
|
362
|
+
case 'index':
|
|
363
|
+
await elem.selectOption({ index: +data });
|
|
364
|
+
return true;
|
|
365
|
+
}
|
|
366
|
+
report.warning(`Paywright error on 'HasOption' instruction : '${by}' is an invalid value for 'By' parameter`);
|
|
367
|
+
return false;
|
|
368
|
+
}
|
|
369
|
+
catch (e) {
|
|
370
|
+
report.warning(`Paywright error on 'SelectByText' instruction : ${e.message}`);
|
|
371
|
+
return false;
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
static async uploadFile(stepCtx) {
|
|
376
|
+
return await uiWrapper(stepCtx, async (stepCtx, elem) => {
|
|
377
|
+
try {
|
|
378
|
+
const filename = stepCtx.getStringParam('0');
|
|
379
|
+
const page = core.getActivePage();
|
|
380
|
+
if (page) {
|
|
381
|
+
const fileChooserPromise = page.waitForEvent('filechooser');
|
|
382
|
+
await elem.click();
|
|
383
|
+
const fileChooser = await fileChooserPromise;
|
|
384
|
+
if (filename) {
|
|
385
|
+
await fileChooser.setFiles(filename);
|
|
386
|
+
}
|
|
387
|
+
else {
|
|
388
|
+
await fileChooser.setFiles([]);
|
|
389
|
+
}
|
|
390
|
+
return true;
|
|
391
|
+
}
|
|
392
|
+
else {
|
|
393
|
+
report.warning(`Paywright error on 'uploadFile' instruction : No active page`);
|
|
394
|
+
return false;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
catch (e) {
|
|
398
|
+
report.warning(`Paywright error on 'uploadFile' instruction : ${e.message}`);
|
|
399
|
+
return false;
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
static async downloadFile(stepCtx) {
|
|
404
|
+
return await uiWrapper(stepCtx, async (stepCtx, elem) => {
|
|
405
|
+
try {
|
|
406
|
+
let path = stepCtx.getStringParam('0', '');
|
|
407
|
+
if (path.length > 0 && path.substring(path.length - 1) !== "\\")
|
|
408
|
+
path = path + "\\";
|
|
409
|
+
const page = core.getActivePage();
|
|
410
|
+
if (page) {
|
|
411
|
+
const downloadPromise = page.waitForEvent('download');
|
|
412
|
+
await elem.click();
|
|
413
|
+
const download = await downloadPromise;
|
|
414
|
+
await download.saveAs(path + download.suggestedFilename());
|
|
415
|
+
return true;
|
|
416
|
+
}
|
|
417
|
+
else {
|
|
418
|
+
report.warning(`Paywright error on 'uploadFile' instruction : No active page`);
|
|
419
|
+
return false;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
catch (e) {
|
|
423
|
+
report.warning(`Paywright error on 'uploadFile' instruction : ${e.message}`);
|
|
424
|
+
return false;
|
|
425
|
+
}
|
|
426
|
+
});
|
|
427
|
+
}
|
|
227
428
|
}
|
|
228
429
|
function delay(t) {
|
|
229
430
|
return new Promise((done) => {
|