ff-automationv2 2.2.2 → 2.2.6
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/llmprompts/systemPrompts/combinedActionExtractorPromptMob.js +3 -2
- package/dist/ai/llmprompts/systemPrompts/fireflinkElementIndexExtractor_Mob.js +8 -2
- package/dist/ai/llmprompts/systemPrompts/getActionExtractorPromptMob.js +2 -2
- package/dist/ai/llmprompts/systemPrompts/mobileKeywordExtractor.js +6 -6
- package/dist/ai/llmprompts/systemPrompts/verifyActionExtractorPromptMob.js +2 -2
- package/dist/ai/llmprompts/systemPrompts/visionPromptMobile.js +1 -1
- package/dist/ai/llmprompts/systemPrompts/waitActionExtractorPromptMob.js +2 -2
- package/dist/automation/actions/executor.d.ts +29 -0
- package/dist/automation/actions/executor.js +419 -0
- package/dist/automation/actions/interaction/click/doubleClick.js +2 -2
- package/dist/automation/actions/interaction/click/tapOnSpecifiedLocation.d.ts +2 -0
- package/dist/automation/actions/interaction/click/tapOnSpecifiedLocation.js +29 -0
- package/dist/automation/actions/interaction/elementlessActions/activateAppUsingAppPackage.d.ts +5 -0
- package/dist/automation/actions/interaction/elementlessActions/activateAppUsingAppPackage.js +17 -0
- package/dist/automation/actions/interaction/elementlessActions/installAPK.d.ts +2 -0
- package/dist/automation/actions/interaction/elementlessActions/installAPK.js +40 -0
- package/dist/automation/actions/interaction/elementlessActions/isAppInstalled.d.ts +2 -0
- package/dist/automation/actions/interaction/elementlessActions/isAppInstalled.js +35 -0
- package/dist/automation/actions/interaction/elementlessActions/openAppWithApkFilePath.d.ts +2 -0
- package/dist/automation/actions/interaction/elementlessActions/openAppWithApkFilePath.js +93 -0
- package/dist/automation/actions/interaction/elementlessActions/openMobileApplication.d.ts +2 -0
- package/dist/automation/actions/interaction/elementlessActions/openMobileApplication.js +14 -0
- package/dist/automation/actions/interaction/elementlessActions/receiveMessageOnEmulator.d.ts +2 -0
- package/dist/automation/actions/interaction/elementlessActions/receiveMessageOnEmulator.js +17 -0
- package/dist/automation/actions/interaction/elementlessActions/terminateAppUsingAppPackage.d.ts +2 -0
- package/dist/automation/actions/interaction/elementlessActions/terminateAppUsingAppPackage.js +17 -0
- package/dist/automation/actions/interaction/elementlessActions/uninstallAPK.d.ts +2 -0
- package/dist/automation/actions/interaction/elementlessActions/uninstallAPK.js +44 -0
- package/dist/automation/actions/interaction/inputlessActions/AirplaneModeSwitchOff.d.ts +2 -0
- package/dist/automation/actions/interaction/inputlessActions/AirplaneModeSwitchOff.js +24 -0
- package/dist/automation/actions/interaction/inputlessActions/AirplaneModeSwitchOn.d.ts +2 -0
- package/dist/automation/actions/interaction/inputlessActions/AirplaneModeSwitchOn.js +25 -0
- package/dist/automation/actions/interaction/inputlessActions/Break.d.ts +2 -0
- package/dist/automation/actions/interaction/inputlessActions/Break.js +14 -0
- package/dist/automation/actions/interaction/inputlessActions/Continue.d.ts +2 -0
- package/dist/automation/actions/interaction/inputlessActions/Continue.js +14 -0
- package/dist/automation/actions/interaction/inputlessActions/GpsSwitchOff.d.ts +2 -0
- package/dist/automation/actions/interaction/inputlessActions/GpsSwitchOff.js +18 -0
- package/dist/automation/actions/interaction/inputlessActions/GpsSwitchOn.d.ts +2 -0
- package/dist/automation/actions/interaction/inputlessActions/GpsSwitchOn.js +18 -0
- package/dist/automation/actions/interaction/inputlessActions/HideKeyboard.d.ts +2 -0
- package/dist/automation/actions/interaction/inputlessActions/HideKeyboard.js +14 -0
- package/dist/automation/actions/interaction/inputlessActions/LockDevice.d.ts +2 -0
- package/dist/automation/actions/interaction/inputlessActions/LockDevice.js +14 -0
- package/dist/automation/actions/interaction/inputlessActions/OpenChromeBrowser.d.ts +2 -0
- package/dist/automation/actions/interaction/inputlessActions/OpenChromeBrowser.js +14 -0
- package/dist/automation/actions/interaction/inputlessActions/OpenNotification.d.ts +2 -0
- package/dist/automation/actions/interaction/inputlessActions/OpenNotification.js +14 -0
- package/dist/automation/actions/interaction/inputlessActions/ResetApp.d.ts +2 -0
- package/dist/automation/actions/interaction/inputlessActions/ResetApp.js +19 -0
- package/dist/automation/actions/interaction/inputlessActions/RestartCurrentDevice.d.ts +2 -0
- package/dist/automation/actions/interaction/inputlessActions/RestartCurrentDevice.js +23 -0
- package/dist/automation/actions/interaction/inputlessActions/SetDeviceOrientationAsLandscape.d.ts +2 -0
- package/dist/automation/actions/interaction/inputlessActions/SetDeviceOrientationAsLandscape.js +14 -0
- package/dist/automation/actions/interaction/inputlessActions/SetDeviceOrientationAsPortrait.d.ts +2 -0
- package/dist/automation/actions/interaction/inputlessActions/SetDeviceOrientationAsPortrait.js +14 -0
- package/dist/automation/actions/interaction/inputlessActions/SetEmulatorPowerStateOff.d.ts +2 -0
- package/dist/automation/actions/interaction/inputlessActions/SetEmulatorPowerStateOff.js +27 -0
- package/dist/automation/actions/interaction/inputlessActions/SetEmulatorPowerStateOn.d.ts +2 -0
- package/dist/automation/actions/interaction/inputlessActions/SetEmulatorPowerStateOn.js +27 -0
- package/dist/automation/actions/interaction/inputlessActions/WifiSwitchOff.d.ts +2 -0
- package/dist/automation/actions/interaction/inputlessActions/WifiSwitchOff.js +18 -0
- package/dist/automation/actions/interaction/inputlessActions/WifiSwitchOn.d.ts +2 -0
- package/dist/automation/actions/interaction/inputlessActions/WifiSwitchOn.js +18 -0
- package/dist/automation/actions/interaction/press/longPress.d.ts +2 -0
- package/dist/automation/actions/interaction/press/longPress.js +44 -0
- package/dist/automation/actions/interaction/press/pressHomeKey.d.ts +2 -0
- package/dist/automation/actions/interaction/press/pressHomeKey.js +20 -0
- package/dist/automation/actions/interaction/verify/VerifyAllBrokenImages.js +1 -1
- package/dist/automation/actions/interaction/verify/VerifyAllOptionsAreSelected.js +4 -3
- package/dist/automation/actions/interaction/verify/VerifyIfOptionWithIndexIsDeselectedInElement.js +2 -2
- package/dist/automation/actions/interaction/verify/VerifyIfOptionWithIndexIsSelectedInListBox.js +2 -2
- package/dist/automation/actions/interaction/verify/VerifyListBoxOptionsAreSorted.js +1 -1
- package/dist/automation/actions/interaction/verify/VerifyNumberOfElementsByTagName.js +2 -2
- package/dist/automation/actions/interaction/wait/waitTillPresenceOfAllElements.js +2 -2
- package/dist/automation/actions/interface/InputlessActionnterface.d.ts +91 -0
- package/dist/automation/actions/interface/InputlessActionnterface.js +1 -0
- package/dist/automation/actions/interface/clickActionInterface.d.ts +6 -0
- package/dist/automation/actions/interface/elementlessInterface.d.ts +55 -0
- package/dist/automation/actions/interface/elementlessInterface.js +1 -0
- package/dist/automation/actions/interface/pressActionInterface.d.ts +14 -0
- package/dist/automation/browserSession/initiateBrowserSession.d.ts +6 -2
- package/dist/automation/browserSession/initiateBrowserSession.js +16 -12
- package/dist/automation/cloudSession/initiateCloudSession.d.ts +9 -0
- package/dist/automation/cloudSession/initiateCloudSession.js +36 -0
- package/dist/automation/mobileSession/initiateMobileSession.d.ts +5 -2
- package/dist/automation/mobileSession/initiateMobileSession.js +37 -12
- package/dist/core/constants/allAction.js +2 -1
- package/dist/core/constants/defaultValues.d.ts +1 -1
- package/dist/core/constants/defaultValues.js +1 -1
- package/dist/core/constants/supportedActions.js +68 -1
- package/dist/core/interfaces/actionInterface.d.ts +29 -0
- package/dist/core/interfaces/browserCapabilitiesInterface.d.ts +19 -2
- package/dist/core/interfaces/browserCapabilitiesInterface.js +33 -1
- package/dist/core/interfaces/browserConfigurationInterface.d.ts +2 -1
- package/dist/core/interfaces/cloudConfigInterface.d.ts +9 -0
- package/dist/core/interfaces/cloudConfigInterface.js +1 -0
- package/dist/core/interfaces/executionDetails.d.ts +6 -2
- package/dist/core/interfaces/fireflinkScriptPayloadInterface.d.ts +1 -1
- package/dist/core/main/actionHandlerFactory.js +261 -15
- package/dist/core/main/executionContext.js +3 -3
- package/dist/core/main/runAutomationScript.js +33 -18
- package/dist/core/types/browserType.d.ts +1 -0
- package/dist/core/types/browserType.js +1 -0
- package/dist/core/types/cloudServerPortType.d.ts +4 -0
- package/dist/core/types/cloudServerPortType.js +4 -0
- package/dist/core/types/cloudprotocolType.d.ts +1 -0
- package/dist/core/types/cloudprotocolType.js +1 -0
- package/dist/fireflinkData/fireflinkScript/scriptGenrationData.d.ts +2 -0
- package/dist/fireflinkData/fireflinkScript/scriptGenrationData.js +4 -1
- package/dist/imageAnalysisMobile/annotatedScreenshotMobile.d.ts +4 -1
- package/dist/imageAnalysisMobile/annotatedScreenshotMobile.js +7 -4
- package/dist/index.js +0 -2
- package/dist/service/fireflink.service.d.ts +10 -0
- package/dist/service/fireflink.service.js +36 -0
- package/dist/service/kafka/fireflinkKafka.service.d.ts +1 -1
- package/dist/tests/test12.js +17 -4
- package/dist/tests/test3.d.ts +1 -2
- package/dist/tests/test3.js +23 -18
- package/dist/utils/DomExtraction/jsForAttributeInjection.js +3 -1
- package/dist/utils/browserCap/capability.d.ts +23 -0
- package/dist/utils/browserCap/capability.js +37 -0
- package/dist/utils/cloudConfig/cloudPath.d.ts +2 -0
- package/dist/utils/cloudConfig/cloudPath.js +3 -0
- package/dist/utils/helpers/enterActionHelper.js +48 -37
- package/dist/utils/helpers/xpathcreation.d.ts +6 -1
- package/dist/utils/helpers/xpathcreation.js +23 -6
- package/package.json +5 -2
package/dist/automation/actions/interaction/elementlessActions/activateAppUsingAppPackage.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { MOB_ActivateAppUsingAppPackageInterface } from "../../interface/elementlessInterface.js";
|
|
2
|
+
/**
|
|
3
|
+
* Reuses InstallAPK logic as per user's Python implementation
|
|
4
|
+
*/
|
|
5
|
+
export declare function ActivateAppUsingAppPackage(args: MOB_ActivateAppUsingAppPackageInterface): Promise<void>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reuses InstallAPK logic as per user's Python implementation
|
|
3
|
+
*/
|
|
4
|
+
export async function ActivateAppUsingAppPackage(args) {
|
|
5
|
+
try {
|
|
6
|
+
await args.driver.activateApp(args.value);
|
|
7
|
+
args.scriptDataAppender.add(async () => ({
|
|
8
|
+
nlpName: 'MOB_ActivateAppUsingAppPackage',
|
|
9
|
+
stepInputs: [args.value],
|
|
10
|
+
elementsData: []
|
|
11
|
+
}));
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
args.scriptDataAppender.setErrorNLP("MOB_ActivateAppUsingAppPackage");
|
|
15
|
+
throw new Error("MOB_ActivateAppUsingAppPackage action failed", { cause: error });
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { logger } from "../../../../utils/logger/logData.js";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
export async function InstallAPK(args) {
|
|
5
|
+
try {
|
|
6
|
+
const apkPath = args.value.trim();
|
|
7
|
+
logger.info(`Installing APK: ${apkPath}`);
|
|
8
|
+
let installed = false;
|
|
9
|
+
// 1. Direct install if it looks like a path
|
|
10
|
+
if (apkPath.toLowerCase().endsWith(".apk") || apkPath.includes("/") || apkPath.includes("\\")) {
|
|
11
|
+
await args.driver.execute("mobile: installApp", {
|
|
12
|
+
appPath: apkPath
|
|
13
|
+
});
|
|
14
|
+
installed = true;
|
|
15
|
+
}
|
|
16
|
+
// 2. Search for APK in current directory
|
|
17
|
+
if (!installed) {
|
|
18
|
+
const files = fs.readdirSync(process.cwd());
|
|
19
|
+
const apkFile = files.find(f => f.toLowerCase().includes(apkPath.toLowerCase()) && f.toLowerCase().endsWith(".apk"));
|
|
20
|
+
if (apkFile) {
|
|
21
|
+
const apkPath = path.resolve(process.cwd(), apkFile);
|
|
22
|
+
logger.info(`Found APK for installation: ${apkPath}`);
|
|
23
|
+
await args.driver.installApp(apkPath);
|
|
24
|
+
installed = true;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (!installed) {
|
|
28
|
+
throw new Error(`Could not find or install APK: ${apkPath}`);
|
|
29
|
+
}
|
|
30
|
+
args.scriptDataAppender.add(async () => ({
|
|
31
|
+
nlpName: 'MOB_InstallAPK',
|
|
32
|
+
stepInputs: [args.value],
|
|
33
|
+
elementsData: []
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
args.scriptDataAppender.setErrorNLP("MOB_InstallAPK");
|
|
38
|
+
throw new Error("MOB_InstallAPK action failed", { cause: error });
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { logger } from "../../../../utils/logger/logData.js";
|
|
2
|
+
import { execSync } from "child_process";
|
|
3
|
+
export async function IsAppInstalled(args) {
|
|
4
|
+
try {
|
|
5
|
+
const target = args.value.trim();
|
|
6
|
+
logger.info(`Checking if app is installed: ${target}`);
|
|
7
|
+
let isInstalled = false;
|
|
8
|
+
try {
|
|
9
|
+
isInstalled = await args.driver.isAppInstalled(target);
|
|
10
|
+
}
|
|
11
|
+
catch (e) {
|
|
12
|
+
throw new Error("MOB_IsAppInstalled action failed", { cause: e });
|
|
13
|
+
}
|
|
14
|
+
if (!isInstalled) {
|
|
15
|
+
const udid = args.driver.capabilities["appium:udid"] || args.driver.capabilities.udid;
|
|
16
|
+
const cmdPrefix = udid ? `adb -s ${udid} shell` : `adb shell`;
|
|
17
|
+
const result = execSync(`${cmdPrefix} pm list packages`).toString().toLowerCase();
|
|
18
|
+
if (result.includes(target.toLowerCase())) {
|
|
19
|
+
isInstalled = true;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if (!isInstalled) {
|
|
23
|
+
throw new Error(`Could not find or install APK: ${target}`);
|
|
24
|
+
}
|
|
25
|
+
args.scriptDataAppender.add(async () => ({
|
|
26
|
+
nlpName: 'MOB_IsAppInstalled',
|
|
27
|
+
stepInputs: [args.value, isInstalled],
|
|
28
|
+
elementsData: []
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
args.scriptDataAppender.setErrorNLP("MOB_IsAppInstalled");
|
|
33
|
+
throw new Error("MOB_IsAppInstalled action failed", { cause: error });
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { logger } from "../../../../utils/logger/logData.js";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import { execSync } from "child_process";
|
|
4
|
+
import path from "path";
|
|
5
|
+
function getLatestInstalledPackage(apkPath) {
|
|
6
|
+
// ✅ Step 1: Extract APK name
|
|
7
|
+
const apkName = path.basename(apkPath, ".apk").toLowerCase();
|
|
8
|
+
// Example:
|
|
9
|
+
// "/folder/MyApp-release.apk" → "myapp-release"
|
|
10
|
+
// Normalize name (remove special chars)
|
|
11
|
+
const normalizedApkName = apkName.replace(/[^a-z0-9]/g, "");
|
|
12
|
+
// ✅ Step 2: Get installed packages (3rd party only)
|
|
13
|
+
const output = execSync(`adb shell pm list packages -3`, {
|
|
14
|
+
maxBuffer: 1024 * 1024 * 5
|
|
15
|
+
}).toString();
|
|
16
|
+
const packages = output
|
|
17
|
+
.split("\n")
|
|
18
|
+
.map(line => line.replace("package:", "").trim())
|
|
19
|
+
.filter(Boolean);
|
|
20
|
+
let bestMatch = "";
|
|
21
|
+
let bestScore = 0;
|
|
22
|
+
// ✅ Step 3: Find most similar package
|
|
23
|
+
for (const pkg of packages) {
|
|
24
|
+
const normalizedPkg = pkg.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
25
|
+
let score = 0;
|
|
26
|
+
// 🔥 Simple similarity logic
|
|
27
|
+
if (normalizedPkg.includes(normalizedApkName)) {
|
|
28
|
+
score += 3;
|
|
29
|
+
}
|
|
30
|
+
if (normalizedApkName.includes(normalizedPkg)) {
|
|
31
|
+
score += 2;
|
|
32
|
+
}
|
|
33
|
+
// Partial match scoring
|
|
34
|
+
for (let i = 0; i < normalizedApkName.length; i++) {
|
|
35
|
+
if (normalizedPkg.includes(normalizedApkName[i])) {
|
|
36
|
+
score += 0.1;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (score > bestScore) {
|
|
40
|
+
bestScore = score;
|
|
41
|
+
bestMatch = pkg;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// ✅ Step 4: Fallback (if nothing matched well)
|
|
45
|
+
if (!bestMatch && packages.length > 0) {
|
|
46
|
+
bestMatch = packages[packages.length - 1];
|
|
47
|
+
}
|
|
48
|
+
return bestMatch;
|
|
49
|
+
}
|
|
50
|
+
export async function OpenAppWithApkFilePath(args) {
|
|
51
|
+
try {
|
|
52
|
+
const apkPath = args.value.trim();
|
|
53
|
+
logger.info(`Installing APK: ${apkPath}`);
|
|
54
|
+
let installed = false;
|
|
55
|
+
// 1. Direct install if it looks like a path
|
|
56
|
+
if (apkPath.toLowerCase().endsWith(".apk") || apkPath.includes("/") || apkPath.includes("\\")) {
|
|
57
|
+
await args.driver.execute("mobile: installApp", {
|
|
58
|
+
appPath: apkPath
|
|
59
|
+
});
|
|
60
|
+
installed = true;
|
|
61
|
+
}
|
|
62
|
+
// 2. Search for APK in current directory
|
|
63
|
+
if (!installed) {
|
|
64
|
+
const files = fs.readdirSync(process.cwd());
|
|
65
|
+
const apkFile = files.find(f => f.toLowerCase().includes(apkPath.toLowerCase()) && f.toLowerCase().endsWith(".apk"));
|
|
66
|
+
if (apkFile) {
|
|
67
|
+
const apkPath = path.resolve(process.cwd(), apkFile);
|
|
68
|
+
logger.info(`Found APK for installation: ${apkPath}`);
|
|
69
|
+
await args.driver.installApp(apkPath);
|
|
70
|
+
installed = true;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (!installed) {
|
|
74
|
+
throw new Error(`Could not find or install APK: ${apkPath}`);
|
|
75
|
+
}
|
|
76
|
+
// ✅ Step 5: Launch app
|
|
77
|
+
const appPackage = await getLatestInstalledPackage(apkPath);
|
|
78
|
+
logger.info(`Launching app: ${appPackage}`);
|
|
79
|
+
await args.driver.activateApp(appPackage);
|
|
80
|
+
// ✅ Script logging
|
|
81
|
+
args.scriptDataAppender.add(async () => ({
|
|
82
|
+
nlpName: "MOB_OpenAppWithApkFilePath",
|
|
83
|
+
stepInputs: [args.value],
|
|
84
|
+
elementsData: []
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
args.scriptDataAppender.setErrorNLP("MOB_OpenAppWithApkFilePath");
|
|
89
|
+
throw new Error("MOB_OpenAppWithApkFilePath action failed", {
|
|
90
|
+
cause: error
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export async function OpenMobileApplication(args) {
|
|
2
|
+
try {
|
|
3
|
+
await args.driver.activateApp(args.value);
|
|
4
|
+
args.scriptDataAppender.add(async () => ({
|
|
5
|
+
nlpName: 'MOB_OpenMobileApplication',
|
|
6
|
+
stepInputs: [args.value],
|
|
7
|
+
elementsData: []
|
|
8
|
+
}));
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
args.scriptDataAppender.setErrorNLP("MOB_OpenMobileApplication");
|
|
12
|
+
throw new Error("MOB_OpenMobileApplication action failed", { cause: error });
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { logger } from "../../../../utils/logger/logData.js";
|
|
2
|
+
export async function ReceiveMessageOnEmulator(args) {
|
|
3
|
+
try {
|
|
4
|
+
const [number, message] = args.value.split(",").map(s => s.trim());
|
|
5
|
+
logger.info(`Receiving message on emulator from ${number}: ${message}`);
|
|
6
|
+
await args.driver.sendSms(number, message);
|
|
7
|
+
args.scriptDataAppender.add(async () => ({
|
|
8
|
+
nlpName: 'MOB_ReceiveMessageOnEmulator',
|
|
9
|
+
stepInputs: [args.value],
|
|
10
|
+
elementsData: []
|
|
11
|
+
}));
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
args.scriptDataAppender.setErrorNLP("MOB_ReceiveMessageOnEmulator");
|
|
15
|
+
throw new Error("MOB_ReceiveMessageOnEmulator action failed", { cause: error });
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { logger } from "../../../../utils/logger/logData.js";
|
|
2
|
+
export async function TerminateAppUsingAppPackage(args) {
|
|
3
|
+
try {
|
|
4
|
+
const target = args.value.trim();
|
|
5
|
+
logger.info(`Terminating app: ${target}`);
|
|
6
|
+
await args.driver.terminateApp(target);
|
|
7
|
+
args.scriptDataAppender.add(async () => ({
|
|
8
|
+
nlpName: 'MOB_TerminateAppUsingAppPackage',
|
|
9
|
+
stepInputs: [args.value],
|
|
10
|
+
elementsData: []
|
|
11
|
+
}));
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
args.scriptDataAppender.setErrorNLP("MOB_TerminateAppUsingAppPackage");
|
|
15
|
+
throw new Error("MOB_TerminateAppUsingAppPackage action failed", { cause: error });
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { logger } from "../../../../utils/logger/logData.js";
|
|
2
|
+
import { execSync } from "child_process";
|
|
3
|
+
export async function UninstallAPK(args) {
|
|
4
|
+
try {
|
|
5
|
+
const target = args.value.trim();
|
|
6
|
+
logger.info(`Uninstalling APK: ${target}`);
|
|
7
|
+
let uninstalled = false;
|
|
8
|
+
if (target.includes(".")) {
|
|
9
|
+
try {
|
|
10
|
+
await args.driver.removeApp(target);
|
|
11
|
+
uninstalled = true;
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
throw new Error("MOB_UninstallAPK action failed", { cause: error });
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
if (!uninstalled) {
|
|
18
|
+
const udid = args.driver.capabilities["appium:udid"] || args.driver.capabilities.udid;
|
|
19
|
+
const cmdPrefix = udid ? `adb -s ${udid} shell` : `adb shell`;
|
|
20
|
+
const packagesResult = execSync(`${cmdPrefix} pm list packages`).toString().toLowerCase();
|
|
21
|
+
for (const line of packagesResult.split(/\r?\n/)) {
|
|
22
|
+
if (line.includes(target.toLowerCase())) {
|
|
23
|
+
const pkg = line.replace("package:", "").trim();
|
|
24
|
+
logger.info(`Uninstalling found package via ADB: ${pkg}`);
|
|
25
|
+
await args.driver.removeApp(pkg);
|
|
26
|
+
uninstalled = true;
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (!uninstalled) {
|
|
32
|
+
throw new Error(`Could not find or uninstall package: ${target}`);
|
|
33
|
+
}
|
|
34
|
+
args.scriptDataAppender.add(async () => ({
|
|
35
|
+
nlpName: 'MOB_UninstallAPK',
|
|
36
|
+
stepInputs: [args.value],
|
|
37
|
+
elementsData: []
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
args.scriptDataAppender.setErrorNLP("MOB_UninstallAPK");
|
|
42
|
+
throw new Error("MOB_UninstallAPK action failed", { cause: error });
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { logger } from "../../../../utils/logger/logData.js";
|
|
2
|
+
import { execSync } from "child_process";
|
|
3
|
+
export async function AirplaneModeSwitchOff(args) {
|
|
4
|
+
try {
|
|
5
|
+
const udid = args.driver.capabilities["appium:udid"] || args.driver.capabilities.udid;
|
|
6
|
+
const cmdPrefix = udid
|
|
7
|
+
? `adb -s ${udid} shell`
|
|
8
|
+
: `adb shell`;
|
|
9
|
+
logger.info("Attempting ADB fallback for AIRPLANE MODE OFF...");
|
|
10
|
+
// Android 10+
|
|
11
|
+
execSync(`${cmdPrefix} cmd connectivity airplane-mode disable`);
|
|
12
|
+
// Backup command
|
|
13
|
+
execSync(`${cmdPrefix} settings put global airplane_mode_on 0`);
|
|
14
|
+
args.scriptDataAppender.add(async () => ({
|
|
15
|
+
nlpName: "MOB_AirplaneModeSwitchOff",
|
|
16
|
+
stepInputs: [],
|
|
17
|
+
elementsData: []
|
|
18
|
+
}));
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
args.scriptDataAppender.setErrorNLP("MOB_AirplaneModeSwitchOff");
|
|
22
|
+
throw new Error("AirplaneModeSwitchOff action failed", { cause: error });
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { logger } from "../../../../utils/logger/logData.js";
|
|
2
|
+
import { execSync } from "child_process";
|
|
3
|
+
export async function AirplaneModeSwitchOn(args) {
|
|
4
|
+
try {
|
|
5
|
+
// ADB fallback
|
|
6
|
+
const udid = args.driver.capabilities["appium:udid"] || args.driver.capabilities.udid;
|
|
7
|
+
const cmdPrefix = udid
|
|
8
|
+
? `adb -s ${udid} shell`
|
|
9
|
+
: `adb shell`;
|
|
10
|
+
logger.info("Attempting ADB fallback for AIRPLANE MODE ON...");
|
|
11
|
+
// Android 10+
|
|
12
|
+
execSync(`${cmdPrefix} cmd connectivity airplane-mode enable`);
|
|
13
|
+
// Backup command
|
|
14
|
+
execSync(`${cmdPrefix} settings put global airplane_mode_on 1`);
|
|
15
|
+
args.scriptDataAppender.add(async () => ({
|
|
16
|
+
nlpName: "MOB_AirplaneModeSwitchOn",
|
|
17
|
+
stepInputs: [],
|
|
18
|
+
elementsData: []
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
args.scriptDataAppender.setErrorNLP("MOB_AirplaneModeSwitchOn");
|
|
23
|
+
throw new Error("AirplaneModeSwitchOn action failed", { cause: error });
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export async function Break(args) {
|
|
2
|
+
try {
|
|
3
|
+
// Break action usually does nothing or just logs
|
|
4
|
+
args.scriptDataAppender.add(async () => ({
|
|
5
|
+
nlpName: "Break",
|
|
6
|
+
stepInputs: [],
|
|
7
|
+
elementsData: []
|
|
8
|
+
}));
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
args.scriptDataAppender.setErrorNLP("Break");
|
|
12
|
+
throw new Error("Break action failed", { cause: error });
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export async function Continue(args) {
|
|
2
|
+
try {
|
|
3
|
+
// Continue action usually does nothing or just logs
|
|
4
|
+
args.scriptDataAppender.add(async () => ({
|
|
5
|
+
nlpName: "Continue",
|
|
6
|
+
stepInputs: [],
|
|
7
|
+
elementsData: []
|
|
8
|
+
}));
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
args.scriptDataAppender.setErrorNLP("Continue");
|
|
12
|
+
throw new Error("Continue action failed", { cause: error });
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export async function GpsSwitchOff(args) {
|
|
2
|
+
try {
|
|
3
|
+
const currentState = await args.driver.getNetworkConnection();
|
|
4
|
+
// If GPS is ON (state 6)
|
|
5
|
+
if (currentState === 6) {
|
|
6
|
+
await args.driver.toggleLocationServices();
|
|
7
|
+
}
|
|
8
|
+
args.scriptDataAppender.add(async () => ({
|
|
9
|
+
nlpName: "MOB_GpsSwitchOff",
|
|
10
|
+
stepInputs: [],
|
|
11
|
+
elementsData: []
|
|
12
|
+
}));
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
args.scriptDataAppender.setErrorNLP("MOB_GpsSwitchOff");
|
|
16
|
+
throw new Error("GpsSwitchOff action failed", { cause: error });
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export async function GpsSwitchOn(args) {
|
|
2
|
+
try {
|
|
3
|
+
const currentState = await args.driver.getNetworkConnection();
|
|
4
|
+
// If GPS is OFF (state 6 is ALL_NETWORK_ON which usually includes GPS)
|
|
5
|
+
if (currentState !== 6) {
|
|
6
|
+
await args.driver.toggleLocationServices();
|
|
7
|
+
}
|
|
8
|
+
args.scriptDataAppender.add(async () => ({
|
|
9
|
+
nlpName: "MOB_GpsSwitchOn",
|
|
10
|
+
stepInputs: [],
|
|
11
|
+
elementsData: []
|
|
12
|
+
}));
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
args.scriptDataAppender.setErrorNLP("MOB_GpsSwitchOn");
|
|
16
|
+
throw new Error("GpsSwitchOn action failed", { cause: error });
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export async function HideKeyboard(args) {
|
|
2
|
+
try {
|
|
3
|
+
await args.driver.hideKeyboard();
|
|
4
|
+
args.scriptDataAppender.add(async () => ({
|
|
5
|
+
nlpName: "MOB_HideKeyboard",
|
|
6
|
+
stepInputs: [],
|
|
7
|
+
elementsData: []
|
|
8
|
+
}));
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
args.scriptDataAppender.setErrorNLP("MOB_HideKeyboard");
|
|
12
|
+
throw new Error("HideKeyboard action failed", { cause: error });
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export async function LockDevice(args) {
|
|
2
|
+
try {
|
|
3
|
+
await args.driver.lock();
|
|
4
|
+
args.scriptDataAppender.add(async () => ({
|
|
5
|
+
nlpName: "MOB_LockDevice",
|
|
6
|
+
stepInputs: [],
|
|
7
|
+
elementsData: []
|
|
8
|
+
}));
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
args.scriptDataAppender.setErrorNLP("MOB_LockDevice");
|
|
12
|
+
throw new Error("LockDevice action failed", { cause: error });
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export async function OpenChromeBrowser(args) {
|
|
2
|
+
try {
|
|
3
|
+
await args.driver.activateApp("com.android.chrome");
|
|
4
|
+
args.scriptDataAppender.add(async () => ({
|
|
5
|
+
nlpName: "MOB_OpenChromeBrowser",
|
|
6
|
+
stepInputs: [],
|
|
7
|
+
elementsData: []
|
|
8
|
+
}));
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
args.scriptDataAppender.setErrorNLP("MOB_OpenChromeBrowser");
|
|
12
|
+
throw new Error("OpenChromeBrowser action failed", { cause: error });
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export async function OpenNotification(args) {
|
|
2
|
+
try {
|
|
3
|
+
await args.driver.openNotifications();
|
|
4
|
+
args.scriptDataAppender.add(async () => ({
|
|
5
|
+
nlpName: "MOB_OpenNotification",
|
|
6
|
+
stepInputs: [],
|
|
7
|
+
elementsData: []
|
|
8
|
+
}));
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
args.scriptDataAppender.setErrorNLP("MOB_OpenNotification");
|
|
12
|
+
throw new Error("OpenNotification action failed", { cause: error });
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export async function ResetApp(args) {
|
|
2
|
+
try {
|
|
3
|
+
const appPackage = await args.driver.getCurrentPackage();
|
|
4
|
+
if (!appPackage) {
|
|
5
|
+
throw new Error("Could not determine appPackage");
|
|
6
|
+
}
|
|
7
|
+
await args.driver.terminateApp(appPackage);
|
|
8
|
+
await args.driver.activateApp(appPackage);
|
|
9
|
+
args.scriptDataAppender.add(async () => ({
|
|
10
|
+
nlpName: "MOB_ResetApp",
|
|
11
|
+
stepInputs: [],
|
|
12
|
+
elementsData: []
|
|
13
|
+
}));
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
args.scriptDataAppender.setErrorNLP("MOB_ResetApp");
|
|
17
|
+
throw new Error("ResetApp action failed", { cause: error });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { logger } from "../../../../utils/logger/logData.js";
|
|
2
|
+
import { execSync } from "child_process";
|
|
3
|
+
export async function RestartCurrentDevice(args) {
|
|
4
|
+
try {
|
|
5
|
+
const udid = args.driver.capabilities["appium:udid"] || args.driver.capabilities.udid;
|
|
6
|
+
logger.info(`Attempting ADB reboot on ${udid || 'default device'}...`);
|
|
7
|
+
try {
|
|
8
|
+
execSync(`adb -s ${udid} reboot`);
|
|
9
|
+
}
|
|
10
|
+
catch (e) {
|
|
11
|
+
logger.info("ADB reboot is going", e);
|
|
12
|
+
}
|
|
13
|
+
args.scriptDataAppender.add(async () => ({
|
|
14
|
+
nlpName: "MOB_RestartCurrentDevice",
|
|
15
|
+
stepInputs: [],
|
|
16
|
+
elementsData: []
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
args.scriptDataAppender.setErrorNLP("MOB_RestartCurrentDevice");
|
|
21
|
+
throw new Error("RestartCurrentDevice action failed", { cause: error });
|
|
22
|
+
}
|
|
23
|
+
}
|
package/dist/automation/actions/interaction/inputlessActions/SetDeviceOrientationAsLandscape.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export async function SetDeviceOrientationAsLandscape(args) {
|
|
2
|
+
try {
|
|
3
|
+
await args.driver.setOrientation("LANDSCAPE");
|
|
4
|
+
args.scriptDataAppender.add(async () => ({
|
|
5
|
+
nlpName: "MOB_SetDeviceOrientationAsLandscape",
|
|
6
|
+
stepInputs: [],
|
|
7
|
+
elementsData: []
|
|
8
|
+
}));
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
args.scriptDataAppender.setErrorNLP("MOB_SetDeviceOrientationAsLandscape");
|
|
12
|
+
throw new Error("SetDeviceOrientationLandscape action failed", { cause: error });
|
|
13
|
+
}
|
|
14
|
+
}
|
package/dist/automation/actions/interaction/inputlessActions/SetDeviceOrientationAsPortrait.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export async function SetDeviceOrientationAsPortrait(args) {
|
|
2
|
+
try {
|
|
3
|
+
await args.driver.setOrientation("PORTRAIT");
|
|
4
|
+
args.scriptDataAppender.add(async () => ({
|
|
5
|
+
nlpName: "MOB_SetDeviceOrientationAsPortrait",
|
|
6
|
+
stepInputs: [],
|
|
7
|
+
elementsData: []
|
|
8
|
+
}));
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
args.scriptDataAppender.setErrorNLP("MOB_SetDeviceOrientationAsPortrait");
|
|
12
|
+
throw new Error("SetDeviceOrientationPortrait action failed", { cause: error });
|
|
13
|
+
}
|
|
14
|
+
}
|