automation_model 1.0.0-amdocs
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/README.md +130 -0
- package/lib/analyze_helper.d.ts +9 -0
- package/lib/analyze_helper.js +161 -0
- package/lib/analyze_helper.js.map +1 -0
- package/lib/api.d.ts +55 -0
- package/lib/api.js +349 -0
- package/lib/api.js.map +1 -0
- package/lib/auto_page.d.ts +7 -0
- package/lib/auto_page.js +199 -0
- package/lib/auto_page.js.map +1 -0
- package/lib/browser_manager.d.ts +32 -0
- package/lib/browser_manager.js +257 -0
- package/lib/browser_manager.js.map +1 -0
- package/lib/command_common.d.ts +6 -0
- package/lib/command_common.js +182 -0
- package/lib/command_common.js.map +1 -0
- package/lib/date_time.d.ts +10 -0
- package/lib/date_time.js +45 -0
- package/lib/date_time.js.map +1 -0
- package/lib/drawRect.d.ts +2 -0
- package/lib/drawRect.js +25 -0
- package/lib/drawRect.js.map +1 -0
- package/lib/environment.d.ts +27 -0
- package/lib/environment.js +15 -0
- package/lib/environment.js.map +1 -0
- package/lib/error-messages.d.ts +6 -0
- package/lib/error-messages.js +206 -0
- package/lib/error-messages.js.map +1 -0
- package/lib/find_function.d.ts +2 -0
- package/lib/find_function.js +51 -0
- package/lib/find_function.js.map +1 -0
- package/lib/generation_scripts.d.ts +4 -0
- package/lib/generation_scripts.js +2 -0
- package/lib/generation_scripts.js.map +1 -0
- package/lib/index.d.ts +10 -0
- package/lib/index.js +11 -0
- package/lib/index.js.map +1 -0
- package/lib/init_browser.d.ts +10 -0
- package/lib/init_browser.js +216 -0
- package/lib/init_browser.js.map +1 -0
- package/lib/locate_element.d.ts +7 -0
- package/lib/locate_element.js +215 -0
- package/lib/locate_element.js.map +1 -0
- package/lib/locator.d.ts +70 -0
- package/lib/locator.js +392 -0
- package/lib/locator.js.map +1 -0
- package/lib/locator_log.d.ts +26 -0
- package/lib/locator_log.js +69 -0
- package/lib/locator_log.js.map +1 -0
- package/lib/network.d.ts +3 -0
- package/lib/network.js +183 -0
- package/lib/network.js.map +1 -0
- package/lib/popups.d.ts +0 -0
- package/lib/popups.js +36 -0
- package/lib/popups.js.map +1 -0
- package/lib/scripts/axe.mini.js +12 -0
- package/lib/stable_browser.d.ts +188 -0
- package/lib/stable_browser.js +3322 -0
- package/lib/stable_browser.js.map +1 -0
- package/lib/table.d.ts +13 -0
- package/lib/table.js +187 -0
- package/lib/table.js.map +1 -0
- package/lib/table_analyze.d.ts +4 -0
- package/lib/table_analyze.js +95 -0
- package/lib/table_analyze.js.map +1 -0
- package/lib/table_helper.d.ts +19 -0
- package/lib/table_helper.js +101 -0
- package/lib/table_helper.js.map +1 -0
- package/lib/test_context.d.ts +21 -0
- package/lib/test_context.js +17 -0
- package/lib/test_context.js.map +1 -0
- package/lib/utils.d.ts +21 -0
- package/lib/utils.js +601 -0
- package/lib/utils.js.map +1 -0
- package/package.json +56 -0
package/README.md
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# Stable API Description
|
|
2
|
+
|
|
3
|
+
This API is built on top of Playwright to control browsers. The most common commands are:
|
|
4
|
+
|
|
5
|
+
- `click`
|
|
6
|
+
- `clickType`
|
|
7
|
+
- `verifyTextExistInPage`
|
|
8
|
+
|
|
9
|
+
## Parameters
|
|
10
|
+
|
|
11
|
+
- **selectors** - An object that can contain the name of the element as well as multiple selectors (CSS, ARIA, etc.) used to locate the element.
|
|
12
|
+
- **world** - Used as part of `cucumber-js`.
|
|
13
|
+
- **\_params** - An object that includes the original function parameters (used in dynamic selectors).
|
|
14
|
+
- **options** - Can be used to set the timeout (`{timeout: 30000}` is the default).
|
|
15
|
+
- **climb** - After finding the element using the selectors, will climb the DOM.
|
|
16
|
+
|
|
17
|
+
Unless stated otherwise, the APIs will return an information object and will throw an error in case of failure.
|
|
18
|
+
|
|
19
|
+
## Function List
|
|
20
|
+
|
|
21
|
+
```javascript
|
|
22
|
+
async goto(url: string, world);
|
|
23
|
+
/* Use AI to identify an element and click on it */
|
|
24
|
+
async simpleClick(elementDescription, _params, options = {}, world);
|
|
25
|
+
async simpleClickType(elementDescription, value, _params, options = {}, world);
|
|
26
|
+
async click(selectors, _params, options = {}, world);
|
|
27
|
+
/* Return true/false */
|
|
28
|
+
async waitForElement(selectors, _params, options = {}, world);
|
|
29
|
+
async setCheck(selectors, checked = true, _params, options = {}, world);
|
|
30
|
+
async hover(selectors, _params, options = {}, world);
|
|
31
|
+
async selectOption(selectors, values, _params, options = {}, world);
|
|
32
|
+
async type(_value, _params, options = {}, world);
|
|
33
|
+
async setDateTime(selectors, value, format, enter = false, _params, options = {}, world);
|
|
34
|
+
/* Use to populate text fields */
|
|
35
|
+
async clickType(selectors, _value, enter = false, _params, options = {}, world);
|
|
36
|
+
/* Return the text */
|
|
37
|
+
async _getText(selectors, climb, _params, options = {}, info, world);
|
|
38
|
+
async containsText(selectors, text, climb, _params, options = {}, world);
|
|
39
|
+
setTestData(testData, world);
|
|
40
|
+
getTestData(world);
|
|
41
|
+
async verifyElementExistInPage(selectors, _params, options = {}, world);
|
|
42
|
+
async extractAttribute(selectors, attribute, variable, _params, options = {}, world);
|
|
43
|
+
async verifyAttribute(selectors, attribute, value, _params, options = {}, world);
|
|
44
|
+
async verifyPagePath(pathPart, options = {}, world);
|
|
45
|
+
async verifyTextExistInPage(text, options = {}, world);
|
|
46
|
+
async waitForTextToDisappear(text, options = {}, world);
|
|
47
|
+
async verifyTextRelatedToText(textAnchor, climb, textToVerify, options = {}, world);
|
|
48
|
+
async visualVerification(text, options = {}, world);
|
|
49
|
+
async waitForPageLoad(options = {}, world);
|
|
50
|
+
async closePage(options = {}, world);
|
|
51
|
+
saveTestDataAsGlobal(options, world);
|
|
52
|
+
async setViewportSize(width, height, options = {}, world);
|
|
53
|
+
async reloadPage(options = {}, world);
|
|
54
|
+
/* Return the ARIA snapshot as string */
|
|
55
|
+
async getAriaSnapshot();
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Code Use Cases
|
|
59
|
+
|
|
60
|
+
### Original Function
|
|
61
|
+
|
|
62
|
+
```javascript
|
|
63
|
+
async function login_with_user_and_password(_username, _password) {
|
|
64
|
+
const _params = { _username, _password };
|
|
65
|
+
// Fill Username textbox with "_username"
|
|
66
|
+
await context.stable.clickType(elements["textbox_username"], _username, false, _params, null, this);
|
|
67
|
+
// Fill Password textbox with "_password"
|
|
68
|
+
await context.stable.clickType(elements["textbox_password"], _password, false, _params, null, this);
|
|
69
|
+
// Click on Login button
|
|
70
|
+
await context.stable.click(elements["button_login"], _params, null, this);
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Example 1: Continue execution if step fails
|
|
75
|
+
|
|
76
|
+
```javascript
|
|
77
|
+
async function login_with_user_and_password(_username, _password) {
|
|
78
|
+
const _params = { _username, _password };
|
|
79
|
+
try {
|
|
80
|
+
await context.stable.clickType(elements["textbox_username"], _username, false, _params, null, this);
|
|
81
|
+
await context.stable.clickType(elements["textbox_password"], _password, false, _params, null, this);
|
|
82
|
+
await context.stable.click(elements["button_login"], _params, null, this);
|
|
83
|
+
} catch (error) {}
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Example 2: Perform action only if "textbox_username" is found
|
|
88
|
+
|
|
89
|
+
```javascript
|
|
90
|
+
async function login_with_user_and_password(_username, _password) {
|
|
91
|
+
const _params = { _username, _password };
|
|
92
|
+
if (await context.stable.waitForElement(elements["textbox_username"], _params, { timeout: 4000 }, this)) {
|
|
93
|
+
await context.stable.clickType(elements["textbox_username"], _username, false, _params, null, this);
|
|
94
|
+
await context.stable.clickType(elements["textbox_password"], _password, false, _params, null, this);
|
|
95
|
+
await context.stable.click(elements["button_login"], _params, null, this);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Example 3: Retry step if it fails
|
|
101
|
+
|
|
102
|
+
```javascript
|
|
103
|
+
async function login_with_user_and_password(_username, _password) {
|
|
104
|
+
const _params = { _username, _password };
|
|
105
|
+
const maxRetry = 2;
|
|
106
|
+
for (let i = 0; i < maxRetry; i++) {
|
|
107
|
+
try {
|
|
108
|
+
await context.stable.clickType(elements["textbox_username"], _username, false, _params, null, this);
|
|
109
|
+
await context.stable.clickType(elements["textbox_password"], _password, false, _params, null, this);
|
|
110
|
+
await context.stable.click(elements["button_login"], _params, null, this);
|
|
111
|
+
break;
|
|
112
|
+
} catch (error) {
|
|
113
|
+
if (i === maxRetry - 1) {
|
|
114
|
+
throw error;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Example 4: Set click timeout to 2 minutes
|
|
122
|
+
|
|
123
|
+
```javascript
|
|
124
|
+
async function login_with_user_and_password(_username, _password) {
|
|
125
|
+
const _params = { _username, _password };
|
|
126
|
+
await context.stable.clickType(elements["textbox_username"], _username, false, _params, { timeout: 120000 }, this);
|
|
127
|
+
await context.stable.clickType(elements["textbox_password"], _password, false, _params, { timeout: 120000 }, this);
|
|
128
|
+
await context.stable.click(elements["button_login"], _params, { timeout: 120000 }, this);
|
|
129
|
+
}
|
|
130
|
+
```
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare const findDateAlternatives: (dateString: string) => {
|
|
2
|
+
dates: string[];
|
|
3
|
+
date: boolean;
|
|
4
|
+
};
|
|
5
|
+
declare const findNumberAlternatives: (numberText: string) => {
|
|
6
|
+
numbers: string[];
|
|
7
|
+
number: boolean;
|
|
8
|
+
};
|
|
9
|
+
export { findDateAlternatives, findNumberAlternatives };
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
const findDateAlternatives = (dateString) => {
|
|
2
|
+
// supported date formats:
|
|
3
|
+
// 2021-12-31
|
|
4
|
+
// 31-12-2021
|
|
5
|
+
// 31/12/2021
|
|
6
|
+
// 12/31/2021
|
|
7
|
+
// 31 Dec 2021
|
|
8
|
+
// 31 December 2021
|
|
9
|
+
// 31 Dec
|
|
10
|
+
// 31 December
|
|
11
|
+
// first we need to identify the input format out of the supported formats
|
|
12
|
+
let year = null;
|
|
13
|
+
let month = null;
|
|
14
|
+
let day = null;
|
|
15
|
+
if (dateString.match(/^\d{4}-\d{2}-\d{2}$/)) {
|
|
16
|
+
year = dateString.substring(0, 4);
|
|
17
|
+
month = dateString.substring(5, 7);
|
|
18
|
+
day = dateString.substring(8, 10);
|
|
19
|
+
}
|
|
20
|
+
else if (dateString.match(/^\d{2}-\d{2}-\d{4}$/)) {
|
|
21
|
+
year = dateString.substring(6, 10);
|
|
22
|
+
month = dateString.substring(3, 5);
|
|
23
|
+
day = dateString.substring(0, 2);
|
|
24
|
+
}
|
|
25
|
+
else if (dateString.match(/^\d{2}\/\d{2}\/\d{4}$/)) {
|
|
26
|
+
year = dateString.substring(6, 10);
|
|
27
|
+
month = dateString.substring(3, 5);
|
|
28
|
+
day = dateString.substring(0, 2);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
let pattern = /(\d{1,2})\s(\w{3,9})\s(\d{4})/;
|
|
32
|
+
let match = dateString.match(pattern);
|
|
33
|
+
if (match) {
|
|
34
|
+
day = match[1];
|
|
35
|
+
month = monthTextToNumber(match[2].toLowerCase());
|
|
36
|
+
year = match[3];
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
let pattern = /(\d{1,2})\s(\w{3,9})/;
|
|
40
|
+
let match = dateString.match(pattern);
|
|
41
|
+
if (match) {
|
|
42
|
+
day = match[1];
|
|
43
|
+
month = monthTextToNumber(match[2].toLowerCase());
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (!day || !month) {
|
|
48
|
+
return { dates: [dateString], date: false };
|
|
49
|
+
}
|
|
50
|
+
// check if month is greater than 12
|
|
51
|
+
if (parseInt(month) > 12) {
|
|
52
|
+
let temp = month;
|
|
53
|
+
month = day;
|
|
54
|
+
day = temp;
|
|
55
|
+
}
|
|
56
|
+
let alternatives = [dateString];
|
|
57
|
+
let monthFull = monthsFull[parseInt(month) - 1];
|
|
58
|
+
let monthShort = months[parseInt(month) - 1];
|
|
59
|
+
if (year) {
|
|
60
|
+
alternatives.push(`${year}-${month}-${day}`);
|
|
61
|
+
alternatives.push(`${day}-${month}-${year}`);
|
|
62
|
+
alternatives.push(`${day}/${month}/${year}`);
|
|
63
|
+
alternatives.push(`${month}/${day}/${year}`);
|
|
64
|
+
alternatives.push(`${day} ${monthShort} ${year}`);
|
|
65
|
+
alternatives.push(`${day} ${monthFull} ${year}`);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
alternatives.push(`${day} ${monthShort}`);
|
|
69
|
+
alternatives.push(`${day} ${monthFull}`);
|
|
70
|
+
}
|
|
71
|
+
return { dates: alternatives, date: true };
|
|
72
|
+
};
|
|
73
|
+
const findNumberAlternatives = (numberText) => {
|
|
74
|
+
// check if the input contains only digits, dots, commas, $ or €
|
|
75
|
+
if (!numberText.match(/^[\d.,€$]+$/)) {
|
|
76
|
+
return { numbers: [numberText], number: false };
|
|
77
|
+
}
|
|
78
|
+
// support all of the following formats:
|
|
79
|
+
// 1,000,000
|
|
80
|
+
// 1,000,000.00
|
|
81
|
+
// 1000000
|
|
82
|
+
// 1000000.00
|
|
83
|
+
// $1,000,000
|
|
84
|
+
// $1,000,000.00
|
|
85
|
+
// $1000000
|
|
86
|
+
// $1000000.00
|
|
87
|
+
// €1,000,000
|
|
88
|
+
// €1,000,000.00
|
|
89
|
+
// €1000000
|
|
90
|
+
// €1000000.00
|
|
91
|
+
// clean the input from $ and €
|
|
92
|
+
let number = numberText.replace(/[$€]/g, "").trim();
|
|
93
|
+
// extract the decimal part
|
|
94
|
+
let decimal = null;
|
|
95
|
+
let parts = number.split("[.,]");
|
|
96
|
+
// check if the last part length is 1 or 2
|
|
97
|
+
if (parts.length > 1 && (parts[parts.length - 1].length === 1 || parts[parts.length - 1].length === 2)) {
|
|
98
|
+
decimal = parts.pop();
|
|
99
|
+
}
|
|
100
|
+
// check that all the parts that are not the first as 3 digits
|
|
101
|
+
for (let i = 1; i < parts.length; i++) {
|
|
102
|
+
if (parts[i].length !== 3) {
|
|
103
|
+
return { numbers: [numberText], number: false };
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
// remove all commas and dots
|
|
107
|
+
number = parts.join("");
|
|
108
|
+
const alternatives = [numberText];
|
|
109
|
+
alternatives.push(number);
|
|
110
|
+
if (decimal) {
|
|
111
|
+
alternatives.push(`${number}.${decimal}`);
|
|
112
|
+
}
|
|
113
|
+
// enter , every 3 digits from the right so 1000000 becomes 1,000,000
|
|
114
|
+
let formattedComma = "";
|
|
115
|
+
let formattedDot = "";
|
|
116
|
+
let counter = 0;
|
|
117
|
+
for (let i = number.length - 1; i >= 0; i--) {
|
|
118
|
+
if (counter === 3) {
|
|
119
|
+
formattedComma = "," + formattedComma;
|
|
120
|
+
formattedDot = "." + formattedDot;
|
|
121
|
+
counter = 0;
|
|
122
|
+
}
|
|
123
|
+
formattedComma = number[i] + formattedComma;
|
|
124
|
+
formattedDot = number[i] + formattedDot;
|
|
125
|
+
counter++;
|
|
126
|
+
}
|
|
127
|
+
alternatives.push(formattedComma);
|
|
128
|
+
alternatives.push(formattedDot);
|
|
129
|
+
if (decimal) {
|
|
130
|
+
alternatives.push(`${formattedComma}.${decimal}`);
|
|
131
|
+
alternatives.push(`${formattedDot},${decimal}`);
|
|
132
|
+
}
|
|
133
|
+
return { numbers: alternatives, number: true };
|
|
134
|
+
};
|
|
135
|
+
const months = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"];
|
|
136
|
+
const monthsFull = [
|
|
137
|
+
"january",
|
|
138
|
+
"february",
|
|
139
|
+
"march",
|
|
140
|
+
"april",
|
|
141
|
+
"may",
|
|
142
|
+
"june",
|
|
143
|
+
"july",
|
|
144
|
+
"august",
|
|
145
|
+
"september",
|
|
146
|
+
"october",
|
|
147
|
+
"november",
|
|
148
|
+
"december",
|
|
149
|
+
];
|
|
150
|
+
const monthTextToNumber = (monthText) => {
|
|
151
|
+
let monthIndex = months.indexOf(monthText);
|
|
152
|
+
if (monthIndex === -1) {
|
|
153
|
+
monthIndex = monthsFull.indexOf(monthText);
|
|
154
|
+
}
|
|
155
|
+
if (monthIndex !== -1) {
|
|
156
|
+
return (monthIndex + 1).toString();
|
|
157
|
+
}
|
|
158
|
+
return null;
|
|
159
|
+
};
|
|
160
|
+
export { findDateAlternatives, findNumberAlternatives };
|
|
161
|
+
//# sourceMappingURL=analyze_helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyze_helper.js","sourceRoot":"","sources":["../../src/analyze_helper.ts"],"names":[],"mappings":"AAAA,MAAM,oBAAoB,GAAG,CAAC,UAAkB,EAAE,EAAE;IAClD,0BAA0B;IAC1B,aAAa;IACb,aAAa;IACb,aAAa;IACb,aAAa;IACb,cAAc;IACd,mBAAmB;IACnB,SAAS;IACT,cAAc;IAEd,0EAA0E;IAC1E,IAAI,IAAI,GAAG,IAAI,CAAC;IAChB,IAAI,KAAK,GAAG,IAAI,CAAC;IACjB,IAAI,GAAG,GAAG,IAAI,CAAC;IACf,IAAI,UAAU,CAAC,KAAK,CAAC,qBAAqB,CAAC,EAAE;QAC3C,IAAI,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAClC,KAAK,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACnC,GAAG,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;KACnC;SAAM,IAAI,UAAU,CAAC,KAAK,CAAC,qBAAqB,CAAC,EAAE;QAClD,IAAI,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACnC,KAAK,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACnC,GAAG,GAAG,UAA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F,MAAM,iBAAiB,GAAG,CAAC,SAAiB,EAAE,EAAE;IAC9C,IAAI,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC3C,IAAI,UAAU,KAAK,CAAC,CAAC,EAAE;QACrB,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;KAC5C;IACD,IAAI,UAAU,KAAK,CAAC,CAAC,EAAE;QACrB,OAAO,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;KACpC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AACF,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,CAAC"}
|
package/lib/api.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { AxiosRequestConfig, AxiosResponse } from "axios";
|
|
3
|
+
interface Config {
|
|
4
|
+
url: string;
|
|
5
|
+
method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "OPTIONS" | "HEAD";
|
|
6
|
+
headers: {
|
|
7
|
+
key: string;
|
|
8
|
+
value: string;
|
|
9
|
+
enabled: boolean;
|
|
10
|
+
}[];
|
|
11
|
+
bodyType: "raw" | "none";
|
|
12
|
+
body: string;
|
|
13
|
+
queryParams: {
|
|
14
|
+
key: string;
|
|
15
|
+
value: string;
|
|
16
|
+
}[];
|
|
17
|
+
settings: {
|
|
18
|
+
removeRefererHeader: boolean;
|
|
19
|
+
strictHttpParser: boolean;
|
|
20
|
+
encodeUrl: boolean;
|
|
21
|
+
disableCookieJar: boolean;
|
|
22
|
+
useServerCipherSuite: boolean;
|
|
23
|
+
maxRedirects: number;
|
|
24
|
+
};
|
|
25
|
+
tests: {
|
|
26
|
+
pattern: string;
|
|
27
|
+
value: string | number | boolean;
|
|
28
|
+
operator: "eq" | "ne" | "gt" | "lt" | "gte" | "lte" | "mat";
|
|
29
|
+
pass: boolean;
|
|
30
|
+
fail?: boolean;
|
|
31
|
+
receivedValue?: any;
|
|
32
|
+
}[] | null | undefined;
|
|
33
|
+
tokens: {
|
|
34
|
+
token: string;
|
|
35
|
+
username: string;
|
|
36
|
+
password: string;
|
|
37
|
+
};
|
|
38
|
+
authType: "Bearer" | "Basic" | "None";
|
|
39
|
+
isStaticToken: boolean;
|
|
40
|
+
status: number;
|
|
41
|
+
}
|
|
42
|
+
interface Param {
|
|
43
|
+
[key: string]: string;
|
|
44
|
+
}
|
|
45
|
+
declare class Api {
|
|
46
|
+
logger: any;
|
|
47
|
+
private axiosClient;
|
|
48
|
+
constructor(logger: any);
|
|
49
|
+
getProxyObject(proxy?: string): import("http").Agent | null;
|
|
50
|
+
axiosClientRequest<T = any>(config: AxiosRequestConfig): Promise<AxiosResponse<T, any>>;
|
|
51
|
+
setProxy(proxy?: string): void;
|
|
52
|
+
request<T = any>(config: Config, params: Param, testData: any, world: any): Promise<AxiosResponse<T, any>>;
|
|
53
|
+
requestWithAuth(methodName: string, world: any, token: string, params: any): Promise<any>;
|
|
54
|
+
}
|
|
55
|
+
export { Api };
|