@kogeet/sagent-playwright 0.2.1 → 0.2.3

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.
Files changed (2) hide show
  1. package/bin/libs/StdLib.js +47 -2
  2. package/package.json +4 -4
@@ -32,7 +32,7 @@ export default class StdLib {
32
32
  static async elemClick(stepCtx) {
33
33
  return await uiWrapper(stepCtx, async (stepCtx, elem) => {
34
34
  try {
35
- await complexClick(elem);
35
+ await complexClick2(elem);
36
36
  await core.waitForLoadActivePage();
37
37
  return true;
38
38
  }
@@ -230,7 +230,7 @@ export default class StdLib {
230
230
  try {
231
231
  const pagePromise = core.pagePromise();
232
232
  if (pagePromise) {
233
- await complexClick(elem);
233
+ await complexClick2(elem);
234
234
  await core.switchToNewPage(pagePromise);
235
235
  context.setVariable(stepCtx.getStringParam('0'), core.getCurrentPageHandle());
236
236
  }
@@ -478,3 +478,48 @@ async function complexClick(elem) {
478
478
  }
479
479
  }
480
480
  }
481
+ async function complexClick2(elem) {
482
+ const timeout = 1000;
483
+ let retry = false;
484
+ let force = false;
485
+ try {
486
+ await elem.dispatchEvent('click', undefined, { timeout });
487
+ }
488
+ catch (e) {
489
+ const { message } = e;
490
+ console.log('> Failed click action with dispatchEvent :', message);
491
+ if (message.match(/Timeout/)) {
492
+ console.log('> Retry click action with default options');
493
+ retry = true;
494
+ }
495
+ else {
496
+ throw new Error(message);
497
+ }
498
+ }
499
+ if (retry) {
500
+ try {
501
+ await elem.click({ timeout });
502
+ }
503
+ catch (e) {
504
+ const { message } = e;
505
+ console.log('> Failed click action with default options :', message);
506
+ console.log('> Retry click action with standard mode');
507
+ if (message.match(/Timeout/)) {
508
+ console.log('> Retry click action with force option');
509
+ force = true;
510
+ }
511
+ else {
512
+ throw new Error(message);
513
+ }
514
+ }
515
+ }
516
+ if (force) {
517
+ try {
518
+ await elem.click({ timeout, force });
519
+ }
520
+ catch (e) {
521
+ const { message } = e;
522
+ throw new Error(message);
523
+ }
524
+ }
525
+ }
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@kogeet/sagent-playwright",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Scapin Agent for Playwright",
5
5
  "main": "bin/index.js",
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
9
9
  "engines": {
10
- "node": "^18.17.1"
10
+ "node": ">=18.17.1"
11
11
  },
12
12
  "scripts": {
13
13
  "build": "tsc --sourceMap false --declaration true",
@@ -17,8 +17,8 @@
17
17
  "author": "Loïc Griveau",
18
18
  "license": "MIT",
19
19
  "dependencies": {
20
- "@kogeet/sagent-plugin-dataset": "^0.1.1",
21
- "@kogeet/scapin-core-agent": "^0.1.5",
20
+ "@kogeet/sagent-plugin-dataset": "^0.1.2",
21
+ "@kogeet/scapin-core-agent": "^0.1.6",
22
22
  "@playwright/browser-chromium": "^1.39.0",
23
23
  "@playwright/browser-firefox": "^1.39.0",
24
24
  "@playwright/browser-webkit": "^1.39.0",