@silasfmartins/testhub 1.0.6 → 1.0.8
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.
|
@@ -1,38 +1,94 @@
|
|
|
1
1
|
import { WebActions } from './WebActions.js';
|
|
2
2
|
import { Logger } from '../utils/Logger.js';
|
|
3
|
-
// Register wrappers that call WebActions.withRecovery around public static methods
|
|
4
|
-
// This file is imported once during AutoCore initialization to enable global recovery.
|
|
5
3
|
(function registerRecoveryWrappers() {
|
|
6
4
|
try {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
'
|
|
10
|
-
'
|
|
11
|
-
'
|
|
12
|
-
'
|
|
13
|
-
'
|
|
14
|
-
'
|
|
15
|
-
'
|
|
16
|
-
'
|
|
17
|
-
'
|
|
18
|
-
'
|
|
19
|
-
'
|
|
20
|
-
'
|
|
21
|
-
'
|
|
22
|
-
'
|
|
23
|
-
'
|
|
24
|
-
'
|
|
5
|
+
// Whitelist: only these user-facing action methods get recovery wrapping
|
|
6
|
+
const actionMethods = new Set([
|
|
7
|
+
'click',
|
|
8
|
+
'doubleClick',
|
|
9
|
+
'rightClick',
|
|
10
|
+
'clickAndHold',
|
|
11
|
+
'clickAndWait',
|
|
12
|
+
'clickMenuOption',
|
|
13
|
+
'clickAlert',
|
|
14
|
+
'waitAndClickAlert',
|
|
15
|
+
'setText',
|
|
16
|
+
'clearAndType',
|
|
17
|
+
'clearField',
|
|
18
|
+
'typeSlowly',
|
|
19
|
+
'setPhone',
|
|
20
|
+
'setPhoneRobust',
|
|
21
|
+
'setDate',
|
|
22
|
+
'setDateNative',
|
|
23
|
+
'setDateRobust',
|
|
24
|
+
'setFiles',
|
|
25
|
+
'setInnerHTML',
|
|
26
|
+
'setInnerText',
|
|
27
|
+
'selectOption',
|
|
28
|
+
'selectOptionByXPath',
|
|
29
|
+
'selectDropdownOption',
|
|
30
|
+
'selectFromList',
|
|
31
|
+
'selectTableOption',
|
|
32
|
+
'checkCheckbox',
|
|
33
|
+
'uncheckCheckbox',
|
|
34
|
+
'hover',
|
|
35
|
+
'focus',
|
|
36
|
+
'mouseMove',
|
|
37
|
+
'pressKey',
|
|
38
|
+
'pressWithModifier',
|
|
39
|
+
'navigateTo',
|
|
40
|
+
'switchTo',
|
|
41
|
+
'switchToDefault',
|
|
42
|
+
'switchToWindowByTitle',
|
|
43
|
+
'switchToWindowByUrl',
|
|
44
|
+
'closeWindowAndSwitchBack',
|
|
45
|
+
'closePage',
|
|
46
|
+
'closeAllTabs',
|
|
47
|
+
'goBack',
|
|
48
|
+
'goForward',
|
|
49
|
+
'refresh',
|
|
50
|
+
'hardRefresh',
|
|
51
|
+
'scrollTo',
|
|
52
|
+
'scrollToElement',
|
|
53
|
+
'dragAndDrop',
|
|
54
|
+
'validateObject',
|
|
55
|
+
'validateObjectNotExists',
|
|
56
|
+
'validateObjectCount',
|
|
57
|
+
'validateObjectNotExistsCount',
|
|
58
|
+
'validateEquals',
|
|
59
|
+
'validateCheckboxChecked',
|
|
60
|
+
'verifyCondition',
|
|
61
|
+
'verifyExists',
|
|
62
|
+
'waitForVisible',
|
|
63
|
+
'waitForElement',
|
|
64
|
+
'waitForClickable',
|
|
65
|
+
'waitForElementVisible',
|
|
66
|
+
'waitForElementDetached',
|
|
67
|
+
'waitForLoad',
|
|
68
|
+
'waitForNavigation',
|
|
69
|
+
'waitForNetworkIdle',
|
|
70
|
+
'waitForPageReady',
|
|
71
|
+
'waitForAlert',
|
|
72
|
+
'getText',
|
|
73
|
+
'getTextContent',
|
|
74
|
+
'getAttribute',
|
|
75
|
+
'getFieldValue',
|
|
76
|
+
'getUrl',
|
|
77
|
+
'isVisible',
|
|
78
|
+
'isEnabled',
|
|
79
|
+
'countElements',
|
|
80
|
+
'toHaveCount',
|
|
81
|
+
'takeScreenshot',
|
|
82
|
+
'executeJavaScript',
|
|
83
|
+
'executeScriptOnElement',
|
|
84
|
+
'setViewportSize',
|
|
85
|
+
'fixedWait',
|
|
25
86
|
]);
|
|
26
|
-
const
|
|
27
|
-
const candidates = staticNames.filter((n) => {
|
|
28
|
-
if (exclude.has(n))
|
|
29
|
-
return false;
|
|
30
|
-
const v = WebActions[n];
|
|
31
|
-
return typeof v === 'function';
|
|
32
|
-
});
|
|
33
|
-
for (const name of candidates) {
|
|
87
|
+
for (const name of actionMethods) {
|
|
34
88
|
const orig = WebActions[name];
|
|
35
|
-
if (
|
|
89
|
+
if (typeof orig !== 'function')
|
|
90
|
+
continue;
|
|
91
|
+
if (orig.__recovery_wrapped)
|
|
36
92
|
continue;
|
|
37
93
|
const wrapped = function (...args) {
|
|
38
94
|
const originalElement = args.length ? args[0] : undefined;
|
|
@@ -48,7 +104,6 @@ import { Logger } from '../utils/Logger.js';
|
|
|
48
104
|
}
|
|
49
105
|
}
|
|
50
106
|
catch (e) {
|
|
51
|
-
// eslint-disable-next-line no-console
|
|
52
107
|
Logger.warning(`⚠️ [WebActions] Failed to register recovery wrappers: ${e}`);
|
|
53
108
|
}
|
|
54
109
|
})();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@silasfmartins/testhub",
|
|
3
3
|
"description": "Biblioteca de utilitários para automação de testes",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.8",
|
|
5
5
|
"author": "Silas Martins Feliciano da Silva <silas.martins2041@gmail.com>",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/index.js",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"./vitest.config": "./dist/src/config/vitest-jest-safe.config.js"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
|
-
"@biomejs/biome": "2.4.
|
|
87
|
+
"@biomejs/biome": "2.4.8",
|
|
88
88
|
"@types/js-yaml": "^4.0.9",
|
|
89
89
|
"@types/node": "^25.5.0",
|
|
90
90
|
"@types/node-fetch": "^2.6.13",
|