ff-automationv2 2.2.29 → 2.2.30
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/dist/ai/llmcalls/llmAction.js +49 -13
- package/dist/ai/llmcalls/parseLlmOputput.js +5 -5
- package/dist/ai/llmprompts/promptRegistry.js +4 -0
- package/dist/ai/llmprompts/systemPrompts/actionExtractorPrompt.js +39 -11
- package/dist/ai/llmprompts/systemPrompts/fireflinkElementIndexExtactors.js +6 -6
- package/dist/ai/llmprompts/systemPrompts/fireflinkElementIndexExtractor_Mob.js +32 -0
- package/dist/ai/llmprompts/systemPrompts/mobileKeywordExtractor.js +17 -8
- package/dist/ai/llmprompts/systemPrompts/otpExtractorPrompt.d.ts +1 -0
- package/dist/ai/llmprompts/systemPrompts/otpExtractorPrompt.js +22 -0
- package/dist/ai/llmprompts/systemPrompts/verifyActionExtractorPrompt.js +3 -1
- package/dist/ai/llmprompts/systemPrompts/visionPrompt.js +14 -6
- package/dist/ai/llmprompts/systemPrompts/visionPromptMobile.js +3 -0
- package/dist/ai/llmprompts/userPrompts/userPrompt.js +1 -0
- package/dist/automation/actions/executor.d.ts +4 -0
- package/dist/automation/actions/executor.js +20 -0
- package/dist/automation/actions/interaction/clear/clear.js +1 -1
- package/dist/automation/actions/interaction/clear/clearAndEnter.js +1 -1
- package/dist/automation/actions/interaction/click/click.js +10 -3
- package/dist/automation/actions/interaction/click/clickNtimes.js +1 -1
- package/dist/automation/actions/interaction/click/doubleClick.js +1 -1
- package/dist/automation/actions/interaction/click/rightClick.js +1 -1
- package/dist/automation/actions/interaction/elementlessActions/getOtp.d.ts +2 -0
- package/dist/automation/actions/interaction/elementlessActions/getOtp.js +101 -0
- package/dist/automation/actions/interaction/enterActions/enterInput.js +11 -6
- package/dist/automation/actions/interaction/enterActions/enterInputAndPress.js +2 -2
- package/dist/automation/actions/interaction/enterActions/enterusingJs.js +2 -2
- package/dist/automation/actions/interaction/enterActions/waitAndEnter.js +1 -1
- package/dist/automation/actions/interaction/upload/uploadfile.js +1 -1
- package/dist/automation/actions/interaction/verify/VerifyNavigateURL.js +38 -11
- package/dist/automation/actions/interface/FireFlinkResponseSchema.d.ts +12 -0
- package/dist/automation/actions/interface/FireFlinkResponseSchema.js +19 -3
- package/dist/automation/actions/interface/getOtpInterface.d.ts +15 -0
- package/dist/automation/actions/interface/getOtpInterface.js +2 -0
- package/dist/automation/browserSession/initiateBrowserSession.d.ts +1 -1
- package/dist/automation/browserSession/initiateBrowserSession.js +15 -7
- package/dist/automation/driverState.d.ts +2 -0
- package/dist/automation/driverState.js +4 -0
- package/dist/automation/mobileSession/initiateMobileSession.d.ts +4 -5
- package/dist/automation/mobileSession/initiateMobileSession.js +83 -19
- package/dist/core/constants/allAction.js +5 -1
- package/dist/core/constants/supportedActions.js +5 -2
- package/dist/core/interfaces/actionInterface.d.ts +4 -0
- package/dist/core/interfaces/browserConfigurationInterface.d.ts +0 -4
- package/dist/core/interfaces/browserConfigurationInterface.js +0 -1
- package/dist/core/interfaces/executionDetails.d.ts +6 -3
- package/dist/core/interfaces/fireflinkScriptPayloadInterface.d.ts +22 -16
- package/dist/core/interfaces/llmResponseInterface.d.ts +1 -0
- package/dist/core/interfaces/promptInterface.d.ts +1 -0
- package/dist/core/main/SessionManager.d.ts +9 -0
- package/dist/core/main/SessionManager.js +23 -0
- package/dist/core/main/actionHandlerFactory.js +261 -64
- package/dist/core/main/executionContext.d.ts +7 -1
- package/dist/core/main/executionContext.js +93 -3
- package/dist/core/main/runAutomationScript.d.ts +1 -0
- package/dist/core/main/runAutomationScript.js +912 -304
- package/dist/core/main/stepProcessor.js +7 -2
- package/dist/core/types/browserType.d.ts +3 -3
- package/dist/core/types/browserType.js +2 -2
- package/dist/core/types/messageType.d.ts +13 -0
- package/dist/core/types/messageType.js +15 -0
- package/dist/core/types/promptType.d.ts +2 -1
- package/dist/core/types/promptType.js +1 -0
- package/dist/domAnalysis/searchBest.js +15 -16
- package/dist/domAnalysis/simplifyAndFlatten.js +6 -4
- package/dist/fireflinkData/fireflinkLocators/getListOfLocators.d.ts +3 -0
- package/dist/fireflinkData/fireflinkLocators/getListOfLocators.js +23 -15
- package/dist/fireflinkData/fireflinkLocators/parser/getElementsFromHTML.d.ts +3 -3
- package/dist/fireflinkData/fireflinkLocators/parser/getElementsFromHTML.js +134 -118
- package/dist/fireflinkData/fireflinkLocators/types/locator.d.ts +11 -1
- package/dist/fireflinkData/fireflinkLocators/utils/androidSelector.d.ts +1 -1
- package/dist/fireflinkData/fireflinkLocators/utils/androidSelector.js +35 -9
- package/dist/fireflinkData/fireflinkLocators/utils/cssSelector.d.ts +10 -10
- package/dist/fireflinkData/fireflinkLocators/utils/cssSelector.js +56 -59
- package/dist/fireflinkData/fireflinkLocators/utils/iosSelector.d.ts +1 -1
- package/dist/fireflinkData/fireflinkLocators/utils/iosSelector.js +53 -29
- package/dist/fireflinkData/fireflinkLocators/utils/referenceXpath.d.ts +8 -8
- package/dist/fireflinkData/fireflinkLocators/utils/referenceXpath.js +113 -190
- package/dist/fireflinkData/fireflinkLocators/utils/xpath.d.ts +17 -26
- package/dist/fireflinkData/fireflinkLocators/utils/xpath.js +314 -786
- package/dist/fireflinkData/fireflinkLocators/utils/xpathHelpers.d.ts +68 -70
- package/dist/fireflinkData/fireflinkLocators/utils/xpathHelpers.js +498 -517
- package/dist/fireflinkData/fireflinkScript/appendScriptData.d.ts +1 -1
- package/dist/fireflinkData/fireflinkScript/appendScriptData.js +5 -8
- package/dist/fireflinkData/fireflinkScript/scriptGenrationData.d.ts +2 -2
- package/dist/fireflinkData/fireflinkScript/scriptGenrationData.js +17 -27
- package/dist/llmConfig/llmConfiguration.js +13 -6
- package/dist/service/api/fireflinkApi.service.d.ts +1 -1
- package/dist/service/api/fireflinkApi.service.js +1 -2
- package/dist/service/fireflink.service.d.ts +3 -3
- package/dist/service/fireflink.service.js +23 -21
- package/dist/service/kafka/fireflinkKafka.service.d.ts +1 -2
- package/dist/service/kafka/fireflinkKafka.service.js +6 -4
- package/dist/tests/test12.d.ts +0 -1
- package/dist/tests/test12.js +65 -78
- package/dist/tests/testkaf.d.ts +0 -1
- package/dist/tests/testkaf.js +51 -55
- package/dist/utils/InstancesDetails/getInstancesInfo.js +1 -1
- package/dist/utils/browserCap/capability.d.ts +5 -1
- package/dist/utils/browserCap/capability.js +91 -15
- package/dist/utils/helpers/domSanitizer.d.ts +1 -0
- package/dist/utils/helpers/domSanitizer.js +9 -0
- package/dist/utils/helpers/enterActionHelper.js +23 -4
- package/dist/utils/helpers/xpathcreation.js +2 -2
- package/dist/utils/javascript/jsFindElement.d.ts +1 -1
- package/dist/utils/javascript/jsFindElement.js +2 -2
- package/dist/utils/newTab/newTabTracker.js +18 -6
- package/dist/utils/workers/LocatorWorkerInterface.d.ts +22 -0
- package/dist/utils/workers/LocatorWorkerInterface.js +2 -0
- package/dist/utils/workers/LocatorWorkerPool.d.ts +13 -0
- package/dist/utils/workers/LocatorWorkerPool.js +89 -0
- package/dist/utils/workers/locatorWorker.d.ts +1 -0
- package/dist/utils/workers/locatorWorker.js +44 -0
- package/package.json +3 -1
|
@@ -1,4 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
37
|
};
|
|
@@ -6,8 +39,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
39
|
exports.createActionHandlers = createActionHandlers;
|
|
7
40
|
const executor_js_1 = require("../../automation/actions/executor.js");
|
|
8
41
|
const logData_js_1 = require("../../utils/logger/logData.js");
|
|
42
|
+
const capability_js_1 = require("../../utils/browserCap/capability.js");
|
|
9
43
|
const path_1 = __importDefault(require("path"));
|
|
10
44
|
function createActionHandlers(context) {
|
|
45
|
+
let isAndroidInitialized = false;
|
|
11
46
|
const requireExecutor = () => {
|
|
12
47
|
if (!context.executor) {
|
|
13
48
|
throw new Error("Browser not initialized.");
|
|
@@ -27,85 +62,244 @@ function createActionHandlers(context) {
|
|
|
27
62
|
return {
|
|
28
63
|
open: async (result) => {
|
|
29
64
|
try {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
65
|
+
const keywords = result?.keywords || [];
|
|
66
|
+
const pathKeyword = keywords.find((k) => k.startsWith("path:"));
|
|
67
|
+
const profileKeyword = keywords.find((k) => k.startsWith("profile:"));
|
|
68
|
+
const capsKeywords = keywords
|
|
69
|
+
.filter((k) => k.startsWith("caps:"))
|
|
70
|
+
.map((k) => k.replace(/^caps:/, ""));
|
|
71
|
+
let pathValue;
|
|
72
|
+
let profileValue;
|
|
73
|
+
if (pathKeyword) {
|
|
74
|
+
const rawPath = pathKeyword.replace(/^path:/, "");
|
|
75
|
+
const pathParts = rawPath.split(/[\\/]+/);
|
|
34
76
|
pathValue = path_1.default.join(...pathParts);
|
|
35
|
-
|
|
77
|
+
}
|
|
78
|
+
if (profileKeyword) {
|
|
79
|
+
profileValue = profileKeyword.replace(/^profile:/, "");
|
|
80
|
+
}
|
|
81
|
+
await context.session.open(pathValue, profileValue, capsKeywords);
|
|
82
|
+
context.executor = new executor_js_1.ActionExecutor(await context.session.getCurrentDriver(), context.scriptAppender, context.locator, context.activePlatform, context.adbPath);
|
|
83
|
+
const rawBrowserName = context.request.browserName.toLowerCase();
|
|
84
|
+
let resolvedBrowserName = "chrome";
|
|
85
|
+
if (rawBrowserName.includes("firefox")) {
|
|
86
|
+
resolvedBrowserName = "firefox";
|
|
87
|
+
}
|
|
88
|
+
else if (rawBrowserName.includes("edge")) {
|
|
89
|
+
resolvedBrowserName = "edge";
|
|
90
|
+
}
|
|
91
|
+
else if (rawBrowserName.includes("safari")) {
|
|
92
|
+
resolvedBrowserName = "safari";
|
|
93
|
+
}
|
|
94
|
+
const capsObj = (0, capability_js_1.getCapabilities)(resolvedBrowserName, pathValue, profileValue, capsKeywords);
|
|
95
|
+
let exactCommands = [];
|
|
96
|
+
let exactPrefs = {};
|
|
97
|
+
if (resolvedBrowserName === "chrome") {
|
|
98
|
+
exactCommands = capsObj["goog:chromeOptions"]?.args || [];
|
|
99
|
+
exactPrefs = capsObj["goog:chromeOptions"]?.prefs || {};
|
|
100
|
+
}
|
|
101
|
+
else if (resolvedBrowserName === "edge") {
|
|
102
|
+
exactCommands = capsObj["ms:edgeOptions"]?.args || [];
|
|
103
|
+
exactPrefs = capsObj["ms:edgeOptions"]?.prefs || {};
|
|
104
|
+
}
|
|
105
|
+
else if (resolvedBrowserName === "firefox") {
|
|
106
|
+
exactCommands = capsObj["moz:firefoxOptions"]?.args || [];
|
|
107
|
+
exactPrefs = capsObj["moz:firefoxOptions"]?.prefs || {};
|
|
108
|
+
}
|
|
109
|
+
const prefKeys = Object.keys(exactPrefs);
|
|
110
|
+
const hasArgs = exactCommands.length > 0;
|
|
111
|
+
const hasPrefs = prefKeys.length > 0;
|
|
112
|
+
const isLinux = process.platform === 'linux';
|
|
113
|
+
if (isLinux && exactCommands.length === 1) {
|
|
114
|
+
context.scriptAppender.add(async () => ({
|
|
115
|
+
nlpName: "Open Browser",
|
|
116
|
+
elementsData: [],
|
|
117
|
+
stepInputs: []
|
|
118
|
+
}));
|
|
36
119
|
}
|
|
37
120
|
else {
|
|
38
|
-
|
|
121
|
+
if (hasArgs || hasPrefs) {
|
|
122
|
+
context.scriptAppender.add(async () => ({
|
|
123
|
+
nlpName: "BrowserOptionsCreateInstance",
|
|
124
|
+
elementsData: [],
|
|
125
|
+
stepInputs: []
|
|
126
|
+
}));
|
|
127
|
+
if (hasArgs) {
|
|
128
|
+
for (const command of exactCommands) {
|
|
129
|
+
if (process.platform === 'linux' && /--ozone-platform\b/.test(command)) {
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
context.scriptAppender.add(async () => ({
|
|
133
|
+
nlpName: "BrowserOptionsAddArguments",
|
|
134
|
+
elementsData: [],
|
|
135
|
+
stepInputs: [command]
|
|
136
|
+
}));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (hasPrefs) {
|
|
140
|
+
context.scriptAppender.add(async () => ({
|
|
141
|
+
nlpName: "MapCreateEmptyMap",
|
|
142
|
+
elementsData: [],
|
|
143
|
+
stepInputs: []
|
|
144
|
+
}));
|
|
145
|
+
for (const key of prefKeys) {
|
|
146
|
+
const value = exactPrefs[key];
|
|
147
|
+
context.scriptAppender.add(async () => ({
|
|
148
|
+
nlpName: "MapPut",
|
|
149
|
+
elementsData: [],
|
|
150
|
+
stepInputs: [key, String(value)]
|
|
151
|
+
}));
|
|
152
|
+
}
|
|
153
|
+
context.scriptAppender.add(async () => ({
|
|
154
|
+
nlpName: "BrowserOptionsSetExperimentalOption",
|
|
155
|
+
elementsData: [],
|
|
156
|
+
stepInputs: ["prefs"]
|
|
157
|
+
}));
|
|
158
|
+
}
|
|
159
|
+
context.scriptAppender.add(async () => ({
|
|
160
|
+
nlpName: "OpenBrowser",
|
|
161
|
+
elementsData: [],
|
|
162
|
+
stepInputs: []
|
|
163
|
+
}));
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
context.scriptAppender.add(async () => ({
|
|
167
|
+
nlpName: "Open Browser",
|
|
168
|
+
elementsData: [],
|
|
169
|
+
stepInputs: []
|
|
170
|
+
}));
|
|
171
|
+
}
|
|
39
172
|
}
|
|
40
|
-
context.executor = new executor_js_1.ActionExecutor(await context.session.getCurrentDriver(), context.scriptAppender, context.locator, context.request.platform, context.adbPath);
|
|
41
|
-
context.scriptAppender.add(async () => ({
|
|
42
|
-
nlpName: "OpenBrowser",
|
|
43
|
-
elementsData: [],
|
|
44
|
-
stepInputs: []
|
|
45
|
-
}));
|
|
46
173
|
}
|
|
47
174
|
catch (error) {
|
|
48
175
|
logData_js_1.logger.error("Error in createActionHandlers", error);
|
|
49
176
|
throw error;
|
|
50
177
|
}
|
|
51
178
|
},
|
|
179
|
+
switchToAndroid: async (result) => {
|
|
180
|
+
try {
|
|
181
|
+
let androidDriver;
|
|
182
|
+
try {
|
|
183
|
+
androidDriver = await context.mobileSession.getCurrentDriver();
|
|
184
|
+
}
|
|
185
|
+
catch {
|
|
186
|
+
if (!context.request.isCloud) {
|
|
187
|
+
let deviceId = context.request.realDeviceId;
|
|
188
|
+
if (!deviceId) {
|
|
189
|
+
const { execFileSync } = await Promise.resolve().then(() => __importStar(require("child_process")));
|
|
190
|
+
const output = execFileSync(context.adbPath, ["devices"], {
|
|
191
|
+
encoding: "utf8",
|
|
192
|
+
});
|
|
193
|
+
const devices = output
|
|
194
|
+
.split("\n")
|
|
195
|
+
.slice(1) // Skip "List of devices attached"
|
|
196
|
+
.map(line => line.trim())
|
|
197
|
+
.filter(line => line.endsWith("\tdevice"));
|
|
198
|
+
if (devices.length === 0) {
|
|
199
|
+
throw new Error("No Android device connected.");
|
|
200
|
+
}
|
|
201
|
+
if (devices.length > 1) {
|
|
202
|
+
throw new Error("Multiple Android devices connected. Please specify a realDeviceId.");
|
|
203
|
+
}
|
|
204
|
+
deviceId = devices[0].split("\t")[0];
|
|
205
|
+
context.request.realDeviceId = deviceId;
|
|
206
|
+
}
|
|
207
|
+
logData_js_1.logger.info("Using device:", deviceId);
|
|
208
|
+
}
|
|
209
|
+
await context.initializeMobileDriver(result.keywords);
|
|
210
|
+
androidDriver = await context.mobileSession.getCurrentDriver();
|
|
211
|
+
}
|
|
212
|
+
context.executor = new executor_js_1.ActionExecutor(androidDriver, context.scriptAppender, context.locator, "android", context.adbPath);
|
|
213
|
+
context.activePlatform = "android";
|
|
214
|
+
if (!isAndroidInitialized) {
|
|
215
|
+
isAndroidInitialized = true;
|
|
216
|
+
// context.scriptAppender.add(async () => ({
|
|
217
|
+
// nlpName: "CreateCapabilitiesInstance",
|
|
218
|
+
// elementsData: [],
|
|
219
|
+
// stepInputs: []
|
|
220
|
+
// }));
|
|
221
|
+
// context.scriptAppender.add(async () => ({
|
|
222
|
+
// nlpName: "MOB_OpenMobileApplication",
|
|
223
|
+
// elementsData: [],
|
|
224
|
+
// stepInputs: ["http://localhost:4723/wd/hub", "10", JSON.stringify(capability)]
|
|
225
|
+
// }));
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
catch (error) {
|
|
229
|
+
logData_js_1.logger.error("Unable to switch to Android", error);
|
|
230
|
+
throw error;
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
switchToWeb: async () => {
|
|
234
|
+
try {
|
|
235
|
+
try {
|
|
236
|
+
const webDriver = await context.session.getCurrentDriver();
|
|
237
|
+
context.executor = new executor_js_1.ActionExecutor(webDriver, context.scriptAppender, context.locator, "web", context.adbPath);
|
|
238
|
+
}
|
|
239
|
+
catch {
|
|
240
|
+
logData_js_1.logger.info("Web driver not initialized. Skipping executor creation.");
|
|
241
|
+
}
|
|
242
|
+
context.activePlatform = "web";
|
|
243
|
+
}
|
|
244
|
+
catch (error) {
|
|
245
|
+
logData_js_1.logger.error("Unable to switch to web", error);
|
|
246
|
+
throw error;
|
|
247
|
+
}
|
|
248
|
+
},
|
|
52
249
|
openApp: async (result) => {
|
|
53
250
|
try {
|
|
54
251
|
const isIOS = context.request.platform?.toLowerCase() === "ios";
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
252
|
+
const appPackage = result.keywords
|
|
253
|
+
.find((item) => item.startsWith("appPackage:"))
|
|
254
|
+
?.substring("appPackage:".length);
|
|
255
|
+
const appActivity = result.keywords
|
|
256
|
+
.find((item) => item.startsWith("appActivity:"))
|
|
257
|
+
?.substring("appActivity:".length);
|
|
258
|
+
await context.mobileSession.launchApp(appPackage, appActivity);
|
|
259
|
+
// Check whether there is any capability other than appPackage/appActivity
|
|
260
|
+
const hasAdditionalCapabilities = result.keywords.some((item) => !item.startsWith("appPackage:") &&
|
|
261
|
+
!item.startsWith("appActivity:"));
|
|
262
|
+
if (!isIOS && hasAdditionalCapabilities) {
|
|
263
|
+
// Create capabilities instance
|
|
264
|
+
context.scriptAppender.add(async () => ({
|
|
265
|
+
nlpName: "MOB_CreateCapabilitiesInstance",
|
|
266
|
+
elementsData: [],
|
|
267
|
+
stepInputs: []
|
|
268
|
+
}));
|
|
269
|
+
// Add every capability, including appPackage and appActivity
|
|
270
|
+
for (const capability of result.keywords) {
|
|
271
|
+
const [key, ...valueParts] = capability.split(":");
|
|
272
|
+
const value = valueParts.join(":");
|
|
273
|
+
context.scriptAppender.add(async () => ({
|
|
274
|
+
nlpName: "MOB_SetCapability",
|
|
275
|
+
elementsData: [],
|
|
276
|
+
stepInputs: [key, value]
|
|
277
|
+
}));
|
|
278
|
+
}
|
|
279
|
+
// Open mobile application
|
|
280
|
+
context.scriptAppender.add(async () => ({
|
|
281
|
+
nlpName: "MOB_OpenMobileApplication",
|
|
282
|
+
elementsData: [],
|
|
283
|
+
stepInputs: [10]
|
|
284
|
+
}));
|
|
79
285
|
}
|
|
80
286
|
else {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
"appium:waitForSelectorTimeout": 0,
|
|
97
|
-
};
|
|
287
|
+
// Normal flow
|
|
288
|
+
context.scriptAppender.add(async () => ({
|
|
289
|
+
nlpName: isIOS ? "Open iOS App" : "Open Android App",
|
|
290
|
+
elementsData: [],
|
|
291
|
+
stepInputs: isIOS
|
|
292
|
+
? [
|
|
293
|
+
context.request.realDeviceId,
|
|
294
|
+
context.request.platformVersion,
|
|
295
|
+
appPackage
|
|
296
|
+
]
|
|
297
|
+
: [
|
|
298
|
+
appPackage,
|
|
299
|
+
appActivity
|
|
300
|
+
]
|
|
301
|
+
}));
|
|
98
302
|
}
|
|
99
|
-
await context.mobileSession.open({
|
|
100
|
-
capabilities: capabilities,
|
|
101
|
-
keywords: result.keywords
|
|
102
|
-
});
|
|
103
|
-
context.executor = new executor_js_1.ActionExecutor(await context.mobileSession.getCurrentDriver(), context.scriptAppender, context.locator, context.request.platform, context.request.adbPath || "");
|
|
104
|
-
context.scriptAppender.add(async () => ({
|
|
105
|
-
nlpName: isIOS ? "Open iOS App" : "Open Android App",
|
|
106
|
-
elementsData: [],
|
|
107
|
-
stepInputs: isIOS ? [context.request.realDeviceId, context.request.platformVersion, result.keywords[0]] : [result.keywords[0], result.keywords[1]]
|
|
108
|
-
}));
|
|
109
303
|
}
|
|
110
304
|
catch (error) {
|
|
111
305
|
logData_js_1.logger.error("Error in createActionHandlers", error);
|
|
@@ -116,7 +310,7 @@ function createActionHandlers(context) {
|
|
|
116
310
|
try {
|
|
117
311
|
await context.session.close();
|
|
118
312
|
context.scriptAppender.add(async () => ({
|
|
119
|
-
nlpName: "
|
|
313
|
+
nlpName: "Close Browser",
|
|
120
314
|
elementsData: [],
|
|
121
315
|
stepInputs: []
|
|
122
316
|
}));
|
|
@@ -1243,6 +1437,9 @@ function createActionHandlers(context) {
|
|
|
1243
1437
|
}),
|
|
1244
1438
|
MouseClickOnCurrentCursorPointNTimes: withExecutor(async (executor, result) => {
|
|
1245
1439
|
await executor.MouseClickOnCurrentCursorPointNTimes(result.value);
|
|
1440
|
+
}),
|
|
1441
|
+
getOtp: withExecutor(async (executor, result) => {
|
|
1442
|
+
await executor.getOtp(result.selector, result.timeFrom, result.waitTime, result.activity, result.otpExtractor);
|
|
1246
1443
|
})
|
|
1247
1444
|
};
|
|
1248
1445
|
}
|
|
@@ -4,13 +4,19 @@ import { ActionExecutor } from "../../automation/actions/executor.js";
|
|
|
4
4
|
import { ElementGetter } from "../../fireflinkData/fireflinkLocators/getListOfLocators.js";
|
|
5
5
|
import { ScriptDataAppender } from "../../fireflinkData/fireflinkScript/scriptGenrationData.js";
|
|
6
6
|
import { AutomationRequest } from "../interfaces/executionDetails.js";
|
|
7
|
+
import { platform } from "../types/scriptTypesType.js";
|
|
8
|
+
import { LocatorWorkerPool } from "../../utils/workers/LocatorWorkerPool.js";
|
|
7
9
|
export declare class ExecutionContext {
|
|
8
10
|
request: AutomationRequest;
|
|
11
|
+
workerPool: LocatorWorkerPool;
|
|
9
12
|
session: BrowserSession;
|
|
10
13
|
mobileSession: MobileSession;
|
|
11
14
|
executor: ActionExecutor | null;
|
|
12
15
|
locator: ElementGetter;
|
|
13
16
|
scriptAppender: ScriptDataAppender;
|
|
14
17
|
adbPath: string;
|
|
15
|
-
|
|
18
|
+
activePlatform: platform;
|
|
19
|
+
extractedOtp: string | null;
|
|
20
|
+
constructor(request: AutomationRequest, workerPool: LocatorWorkerPool);
|
|
21
|
+
initializeMobileDriver(caps: any): Promise<void>;
|
|
16
22
|
}
|
|
@@ -3,19 +3,109 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ExecutionContext = void 0;
|
|
4
4
|
const initiateBrowserSession_js_1 = require("../../automation/browserSession/initiateBrowserSession.js");
|
|
5
5
|
const initiateMobileSession_js_1 = require("../../automation/mobileSession/initiateMobileSession.js");
|
|
6
|
+
const executor_js_1 = require("../../automation/actions/executor.js");
|
|
6
7
|
const getListOfLocators_js_1 = require("../../fireflinkData/fireflinkLocators/getListOfLocators.js");
|
|
7
8
|
const scriptGenrationData_js_1 = require("../../fireflinkData/fireflinkScript/scriptGenrationData.js");
|
|
8
9
|
const defaultValues_js_1 = require("../constants/defaultValues.js");
|
|
9
10
|
const browserType_js_1 = require("../../core/types/browserType.js");
|
|
10
11
|
class ExecutionContext {
|
|
11
|
-
constructor(request) {
|
|
12
|
+
constructor(request, workerPool) {
|
|
12
13
|
this.request = request;
|
|
14
|
+
this.workerPool = workerPool;
|
|
13
15
|
this.executor = null;
|
|
14
|
-
this.
|
|
15
|
-
this.
|
|
16
|
+
this.extractedOtp = null;
|
|
17
|
+
this.session = new initiateBrowserSession_js_1.BrowserSession(browserType_js_1.browserName[request.browserName], request.isCloud, request.capabilities, defaultValues_js_1.DEFAULT_PAGE_LOAD, request.cloudConfig);
|
|
18
|
+
this.locator = new getListOfLocators_js_1.ElementGetter(workerPool);
|
|
16
19
|
this.scriptAppender = new scriptGenrationData_js_1.ScriptDataAppender();
|
|
17
20
|
this.mobileSession = new initiateMobileSession_js_1.MobileSession(request.appiumPort, request.isCloud, request.capabilities, request.cloudConfig, request.adbPath);
|
|
18
21
|
this.adbPath = request.adbPath || "";
|
|
22
|
+
this.activePlatform = request.platform.toLowerCase();
|
|
23
|
+
}
|
|
24
|
+
async initializeMobileDriver(caps) {
|
|
25
|
+
const isIOS = this.request.platform.toLowerCase() === "ios";
|
|
26
|
+
const appiumCaps = {};
|
|
27
|
+
const allowedCapabilities = [
|
|
28
|
+
"app",
|
|
29
|
+
"appPackage",
|
|
30
|
+
"appActivity",
|
|
31
|
+
"noReset",
|
|
32
|
+
"fullReset",
|
|
33
|
+
"autoGrantPermissions"
|
|
34
|
+
];
|
|
35
|
+
let hasAppPackage = false;
|
|
36
|
+
if (Array.isArray(caps)) {
|
|
37
|
+
for (const cap of caps) {
|
|
38
|
+
if (typeof cap !== "string") {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
const [key, ...valueParts] = cap.split(":");
|
|
42
|
+
const value = valueParts.join(":");
|
|
43
|
+
if (!allowedCapabilities.includes(key)) {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (key === "appActivity" || !value.trim()) {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (key === "appPackage") {
|
|
50
|
+
hasAppPackage = true;
|
|
51
|
+
}
|
|
52
|
+
if (value === "true") {
|
|
53
|
+
appiumCaps[`appium:${key}`] = true;
|
|
54
|
+
}
|
|
55
|
+
else if (value === "false") {
|
|
56
|
+
appiumCaps[`appium:${key}`] = false;
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
appiumCaps[`appium:${key}`] = value;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const capabilities = isIOS
|
|
64
|
+
? {
|
|
65
|
+
platformName: "iOS",
|
|
66
|
+
"appium:platformVersion": this.request.platformVersion,
|
|
67
|
+
"appium:deviceName": "iphone",
|
|
68
|
+
"appium:udid": this.request.realDeviceId,
|
|
69
|
+
"appium:automationName": "XCUITest",
|
|
70
|
+
"appium:autoLaunch": false,
|
|
71
|
+
"appium:shouldUseCompactResponses": true,
|
|
72
|
+
"appium:waitForQuiescence": false,
|
|
73
|
+
"appium:wdaLaunchTimeout": 300000,
|
|
74
|
+
"appium:wdaConnectionTimeout": 300000,
|
|
75
|
+
"appium:agentPath": "/Applications/FireFlinkClient.app/Contents/Resources/flinko-client/exec/appium-webdriveragent/WebDriverAgent.xcodeproj",
|
|
76
|
+
"appium:bootstrapPath": "/Applications/FireFlinkClient.app/Contents/Resources/flinko-client/exec/appium-webdriveragent",
|
|
77
|
+
"appium:noReset": false,
|
|
78
|
+
"appium:showXcodeLog": true,
|
|
79
|
+
"appium:useNewWDA": true,
|
|
80
|
+
"appium:unicodeKeyboard": true,
|
|
81
|
+
"appium:resetKeyboard": true,
|
|
82
|
+
"appium:ignoreUnimportantViews": true,
|
|
83
|
+
"appium:disableWindowAnimation": true,
|
|
84
|
+
"appium:newCommandTimeout": 300,
|
|
85
|
+
}
|
|
86
|
+
: {
|
|
87
|
+
platformName: "Android",
|
|
88
|
+
"appium:platformVersion": this.request.platformVersion,
|
|
89
|
+
"appium:deviceName": "AndroidDevice",
|
|
90
|
+
"appium:udid": this.request.realDeviceId,
|
|
91
|
+
"appium:autoLaunch": !hasAppPackage,
|
|
92
|
+
"appium:automationName": "UiAutomator2",
|
|
93
|
+
"appium:ignoreHiddenApiPolicyError": true,
|
|
94
|
+
"appium:shouldUseCompactResponses": true,
|
|
95
|
+
"appium:ignoreUnimportantViews": false,
|
|
96
|
+
"appium:disableAndroidWatcher": true,
|
|
97
|
+
"appium:disableWindowAnimation": true,
|
|
98
|
+
"appium:uiautomator2ServerLaunchTimeout": 60000,
|
|
99
|
+
"appium:uiautomator2ServerReadTimeout": 60000,
|
|
100
|
+
"appium:waitForIdleTimeout": 0,
|
|
101
|
+
"appium:waitForIdlePollingInterval": 0,
|
|
102
|
+
"appium:waitForSelectorTimeout": 0,
|
|
103
|
+
"appium:newCommandTimeout": 600,
|
|
104
|
+
"appium:noReset": false,
|
|
105
|
+
...appiumCaps
|
|
106
|
+
};
|
|
107
|
+
await this.mobileSession.createDriver(capabilities);
|
|
108
|
+
this.executor = new executor_js_1.ActionExecutor(await this.mobileSession.getCurrentDriver(), this.scriptAppender, this.locator, this.request.platform, this.adbPath);
|
|
19
109
|
}
|
|
20
110
|
}
|
|
21
111
|
exports.ExecutionContext = ExecutionContext;
|
|
@@ -6,6 +6,7 @@ export declare class AutomationRunner implements IAutomationRunner {
|
|
|
6
6
|
private KafkaPayload;
|
|
7
7
|
static getSessionTerminationInfo(testCaseId: string): boolean;
|
|
8
8
|
static updateSessionTerminationInfo(testCaseId: string): void;
|
|
9
|
+
static normalizeScriptType(scriptType?: string): string;
|
|
9
10
|
private cleanup;
|
|
10
11
|
run(request: AutomationRequest): Promise<void>;
|
|
11
12
|
}
|