ff-automationv2 2.2.13 → 2.2.15
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 +4 -3
- package/dist/ai/llmprompts/systemPrompts/errorDescriptionPrompt.js +9 -11
- package/dist/ai/llmprompts/systemPrompts/fireflinkElementIndexExtactors.js +7 -7
- package/dist/ai/llmprompts/systemPrompts/fireflinkElementIndexExtractor_Mob.js +39 -0
- package/dist/ai/llmprompts/systemPrompts/mobileKeywordExtractor.js +2 -1
- package/dist/ai/llmprompts/systemPrompts/verifyActionExtractorPromptMob.js +2 -1
- package/dist/ai/llmprompts/systemPrompts/visionPrompt.js +3 -2
- package/dist/ai/llmprompts/systemPrompts/waitActionExtractorPrompt.js +1 -0
- package/dist/ai/llmprompts/systemPrompts/waitActionExtractorPromptMob.js +1 -0
- package/dist/automation/actions/executor.d.ts +19 -1
- package/dist/automation/actions/executor.js +303 -1
- package/dist/automation/actions/interaction/click/MOB_DoubleTapAtSpecifiedLocation.d.ts +2 -0
- package/dist/automation/actions/interaction/click/MOB_DoubleTapAtSpecifiedLocation.js +26 -0
- package/dist/automation/actions/interaction/elementLessAction/MobCheckIfAppIsClosed.d.ts +2 -0
- package/dist/automation/actions/interaction/elementLessAction/MobCheckIfAppIsClosed.js +20 -0
- package/dist/automation/actions/interaction/elementLessAction/MobRunAppInBackgroundInterface.d.ts +2 -0
- package/dist/automation/actions/interaction/elementLessAction/MobRunAppInBackgroundInterface.js +18 -0
- package/dist/automation/actions/interaction/enterActions/EnterInputIntoElementFromClipBoardInterface_mob.d.ts +2 -0
- package/dist/automation/actions/interaction/enterActions/EnterInputIntoElementFromClipBoardInterface_mob.js +26 -0
- package/dist/automation/actions/interaction/enterActions/enterInput.js +2 -2
- package/dist/automation/actions/interaction/enterActions/enterInputAndPress.js +1 -1
- package/dist/automation/actions/interaction/enterActions/enterusingJs.js +1 -1
- package/dist/automation/actions/interaction/enterActions/waitAndEnter.js +3 -3
- package/dist/automation/actions/interaction/find/MOB_FindElement.d.ts +2 -0
- package/dist/automation/actions/interaction/find/MOB_FindElement.js +34 -0
- package/dist/automation/actions/interaction/find/findElements.js +16 -2
- package/dist/automation/actions/interaction/get/getScreenshot.js +14 -16
- package/dist/automation/actions/interaction/get/getScreenshotAs.js +26 -16
- package/dist/automation/actions/interaction/pinch/PinchInByPercentMob.d.ts +2 -0
- package/dist/automation/actions/interaction/pinch/PinchInByPercentMob.js +27 -0
- package/dist/automation/actions/interaction/pinch/PinchOutByPercentMob.d.ts +2 -0
- package/dist/automation/actions/interaction/pinch/PinchOutByPercentMob.js +27 -0
- package/dist/automation/actions/interaction/press/mobPressBackSpaceKey.d.ts +2 -0
- package/dist/automation/actions/interaction/press/mobPressBackSpaceKey.js +16 -0
- package/dist/automation/actions/interaction/press/mobPressSpaceKey.d.ts +2 -0
- package/dist/automation/actions/interaction/press/mobPressSpaceKey.js +16 -0
- package/dist/automation/actions/interaction/swipe/swipeDirectionNTimes.d.ts +2 -0
- package/dist/automation/actions/interaction/swipe/swipeDirectionNTimes.js +27 -0
- package/dist/automation/actions/interaction/swipe/swipeDownToElement.d.ts +2 -0
- package/dist/automation/actions/interaction/swipe/swipeDownToElement.js +46 -0
- package/dist/automation/actions/interaction/swipe/swipeLeftToElement.d.ts +2 -0
- package/dist/automation/actions/interaction/swipe/swipeLeftToElement.js +46 -0
- package/dist/automation/actions/interaction/swipe/swipeRightToElement.d.ts +2 -0
- package/dist/automation/actions/interaction/swipe/swipeRightToElement.js +46 -0
- package/dist/automation/actions/interaction/swipe/swipeUpToElement.d.ts +2 -0
- package/dist/automation/actions/interaction/swipe/swipeUpToElement.js +49 -0
- package/dist/automation/actions/interaction/swipe/swipeUpToElementForMWeb.d.ts +2 -0
- package/dist/automation/actions/interaction/swipe/swipeUpToElementForMWeb.js +48 -0
- package/dist/automation/actions/interaction/swipe/swipeUsingReferenceElement.d.ts +2 -0
- package/dist/automation/actions/interaction/swipe/swipeUsingReferenceElement.js +140 -0
- package/dist/automation/actions/interaction/verify/VerifyElementNotContainsText.js +2 -2
- package/dist/automation/actions/interaction/wait/waitTillElementIsClickable.js +5 -1
- package/dist/automation/actions/interaction/wait/waitTillPresenceOfElement.js +1 -1
- package/dist/automation/actions/interface/clickActionInterface.d.ts +8 -0
- package/dist/automation/actions/interface/elelementLessActionInterface.d.ts +12 -0
- package/dist/automation/actions/interface/findActionInterface.d.ts +10 -2
- package/dist/automation/actions/interface/interactionActionInterface.d.ts +8 -0
- package/dist/automation/actions/interface/pinchActionInterface.d.ts +19 -0
- package/dist/automation/actions/interface/pressActionInterface.d.ts +10 -0
- package/dist/automation/actions/interface/swipeActionInterface.d.ts +89 -0
- package/dist/automation/actions/interface/swipeActionInterface.js +1 -0
- package/dist/automation/actions/interface/waitActionInterface.d.ts +1 -0
- package/dist/core/constants/allAction.js +1 -0
- package/dist/core/constants/supportedActions.js +9 -1
- package/dist/core/interfaces/actionInterface.d.ts +19 -1
- package/dist/core/interfaces/executionDetails.d.ts +1 -4
- package/dist/core/interfaces/fireflinkScriptPayloadInterface.d.ts +2 -3
- package/dist/core/main/actionHandlerFactory.js +62 -2
- package/dist/core/main/runAutomationScript.d.ts +0 -1
- package/dist/core/main/runAutomationScript.js +33 -23
- package/dist/service/fireflink.service.d.ts +2 -4
- package/dist/service/fireflink.service.js +4 -5
- package/dist/service/kafka/fireflinkKafka.service.d.ts +2 -2
- package/dist/service/kafka/fireflinkKafka.service.js +17 -3
- package/dist/utils/logger/logData.d.ts +1 -0
- package/dist/utils/logger/logData.js +49 -22
- package/dist/utils/swipe/domSearchHelper.d.ts +5 -0
- package/dist/utils/swipe/domSearchHelper.js +42 -0
- package/dist/utils/swipe/swipeMovement.d.ts +1 -0
- package/dist/utils/swipe/swipeMovement.js +81 -0
- package/package.json +3 -4
- package/dist/tests/Framework.d.ts +0 -0
- package/dist/tests/Framework.js +0 -62
- package/dist/tests/test1.d.ts +0 -7
- package/dist/tests/test1.js +0 -13
- package/dist/tests/test12.js +0 -123
- package/dist/tests/test3.js +0 -24
- /package/dist/{tests/test12.d.ts → automation/actions/interface/elelementLessActionInterface.js} +0 -0
- /package/dist/{tests/test3.d.ts → automation/actions/interface/pinchActionInterface.js} +0 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export async function MOB_CheckIfAppIsClosed(args) {
|
|
2
|
+
try {
|
|
3
|
+
const state = await args.driver.queryAppState(await args.driver.getCurrentPackage());
|
|
4
|
+
const isClosed = state !== 4;
|
|
5
|
+
if (!isClosed) {
|
|
6
|
+
throw new Error("App is not closed");
|
|
7
|
+
}
|
|
8
|
+
args.scriptDataAppender.add(async () => {
|
|
9
|
+
return {
|
|
10
|
+
nlpName: 'MOB_CheckIfAppIsClosed',
|
|
11
|
+
stepInputs: [],
|
|
12
|
+
elementsData: []
|
|
13
|
+
};
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
args.scriptDataAppender.setErrorNLP("MOB_CheckIfAppIsClosed");
|
|
18
|
+
throw new Error(`enter action failed:`, { cause: error });
|
|
19
|
+
}
|
|
20
|
+
}
|
package/dist/automation/actions/interaction/elementLessAction/MobRunAppInBackgroundInterface.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export async function MOB_RunAppInBackground(args) {
|
|
2
|
+
try {
|
|
3
|
+
await args.driver.execute('mobile: backgroundApp', {
|
|
4
|
+
seconds: Number(args.value)
|
|
5
|
+
});
|
|
6
|
+
args.scriptDataAppender.add(async () => {
|
|
7
|
+
return {
|
|
8
|
+
nlpName: 'MOB_RunAppInBackground',
|
|
9
|
+
stepInputs: [args.value],
|
|
10
|
+
elementsData: []
|
|
11
|
+
};
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
args.scriptDataAppender.setErrorNLP("MOB_RunAppInBackground");
|
|
16
|
+
throw new Error("MOB_RunAppInBackground failed", { cause: error });
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { logger } from "../../../../utils/logger/logData.js";
|
|
2
|
+
export async function MOB_EnterInputIntoElementFromClipBoard(args) {
|
|
3
|
+
try {
|
|
4
|
+
const element = await args.driver.$(args.selector);
|
|
5
|
+
const base64Value = await args.driver.getClipboard('plaintext');
|
|
6
|
+
const value = Buffer.from(base64Value, 'base64').toString('utf-8');
|
|
7
|
+
logger.info(`Value from clipboard: ${value}`);
|
|
8
|
+
await element.addValue(value);
|
|
9
|
+
args.scriptDataAppender.add(async () => {
|
|
10
|
+
return {
|
|
11
|
+
nlpName: 'MOB_EnterInputIntoElementFromClipBoard',
|
|
12
|
+
stepInputs: [],
|
|
13
|
+
elementsData: [{
|
|
14
|
+
name: args.elementName,
|
|
15
|
+
type: args.elementType,
|
|
16
|
+
locators: [{ "xpath": args.selector }],
|
|
17
|
+
platform: args.platform
|
|
18
|
+
}]
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
args.scriptDataAppender.setErrorNLP("MOB_EnterInputIntoElementFromClipBoard");
|
|
24
|
+
throw new Error(`enter action failed:`, { cause: error });
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -5,7 +5,7 @@ export async function enterInput(args) {
|
|
|
5
5
|
try {
|
|
6
6
|
const { xpathPath } = enterActionHelperMob(args.pageDOM, args.fireflinkIndex);
|
|
7
7
|
const element = await args.driver.$(xpathPath);
|
|
8
|
-
await element.
|
|
8
|
+
await element.addValue(args.value);
|
|
9
9
|
const text = await element.getAttribute("text");
|
|
10
10
|
if (text !== args.value) {
|
|
11
11
|
const { execSync } = await import("child_process");
|
|
@@ -34,7 +34,7 @@ export async function enterInput(args) {
|
|
|
34
34
|
try {
|
|
35
35
|
const { ffNumber, xpathPath } = enterActionHelper(args.pageDOM, args.fireflinkIndex);
|
|
36
36
|
const element = await args.driver.$(xpathPath);
|
|
37
|
-
await element.
|
|
37
|
+
await element.addValue(args.value);
|
|
38
38
|
args.scriptDataAppender.add(async () => {
|
|
39
39
|
const ffElement = await args.elementGetter.getFireFlinkElement(args.pageDOM, `[ff-inspect="Fire-Flink-${ffNumber}"]`);
|
|
40
40
|
return {
|
|
@@ -9,7 +9,7 @@ export async function enterInputAndPress(args) {
|
|
|
9
9
|
const inputValue = parts[0]?.trim() || "";
|
|
10
10
|
const keyValue = parts[1]?.trim().toLowerCase() || "";
|
|
11
11
|
if (inputValue) {
|
|
12
|
-
await element.
|
|
12
|
+
await element.addValue(inputValue);
|
|
13
13
|
}
|
|
14
14
|
if (keyValue) {
|
|
15
15
|
switch (keyValue) {
|
|
@@ -6,7 +6,7 @@ export async function enterInputUsingJs(args) {
|
|
|
6
6
|
logger.info(`Enter input using JS for element with ffNumber: ${ffNumber}, xpathPath: ${xpathPath}`);
|
|
7
7
|
const element = await args.driver.$(xpathPath);
|
|
8
8
|
await element.scrollIntoView({ block: 'center', inline: 'center' });
|
|
9
|
-
await element.
|
|
9
|
+
await element.addValue(args.value);
|
|
10
10
|
args.scriptDataAppender.add(async () => {
|
|
11
11
|
const ffElement = await args.elementGetter.getFireFlinkElement(args.pageDOM, `[ff-inspect="Fire-Flink-${ffNumber}"]`);
|
|
12
12
|
return {
|
|
@@ -19,7 +19,7 @@ export async function waitAndEnter(args) {
|
|
|
19
19
|
const element = await args.driver.$(xpathPath);
|
|
20
20
|
// Wait before typing
|
|
21
21
|
await args.driver.pause(waitTimeSeconds * 1000);
|
|
22
|
-
await element.
|
|
22
|
+
await element.addValue(inputValue);
|
|
23
23
|
args.scriptDataAppender.add(async () => {
|
|
24
24
|
return {
|
|
25
25
|
nlpName: "MOB_WaitAndSendKeys",
|
|
@@ -47,8 +47,8 @@ export async function waitAndEnter(args) {
|
|
|
47
47
|
const element = await args.driver.$(xpathPath);
|
|
48
48
|
// Wait before typing
|
|
49
49
|
await args.driver.pause(waitTimeSeconds * 1000);
|
|
50
|
-
await element.scrollIntoView({ block:
|
|
51
|
-
await element.
|
|
50
|
+
await element.scrollIntoView({ block: 'center', inline: 'center' });
|
|
51
|
+
await element.addValue(inputValue);
|
|
52
52
|
args.scriptDataAppender.add(async () => {
|
|
53
53
|
const ffElement = await args.elementGetter.getFireFlinkElement(args.pageDOM, `[ff-inspect="Fire-Flink-${ffNumber}"]`);
|
|
54
54
|
return {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export async function MOB_FindElement(args) {
|
|
2
|
+
try {
|
|
3
|
+
const parentElement = await args.driver.$(args.selector);
|
|
4
|
+
const children = await parentElement.$$("./*");
|
|
5
|
+
const childInfo = [];
|
|
6
|
+
for (const el of children) {
|
|
7
|
+
childInfo.push({
|
|
8
|
+
class: await el.getAttribute("class"),
|
|
9
|
+
resource_id: await el.getAttribute("resource-id"),
|
|
10
|
+
text: await el.getAttribute("text"),
|
|
11
|
+
content_desc: await el.getAttribute("content-desc"),
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
args.scriptDataAppender.add(async () => {
|
|
15
|
+
return {
|
|
16
|
+
nlpName: "MOB_FindElement",
|
|
17
|
+
stepInputs: [],
|
|
18
|
+
elementsData: [{
|
|
19
|
+
name: args.elementName,
|
|
20
|
+
type: args.elementType,
|
|
21
|
+
locators: [{
|
|
22
|
+
"locatorType": "xpath",
|
|
23
|
+
"locatorValue": args.selector
|
|
24
|
+
}],
|
|
25
|
+
platform: args.platform
|
|
26
|
+
}]
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
args.scriptDataAppender.setErrorNLP("MOB_FindElements");
|
|
32
|
+
throw new Error("find elements action failed", { cause: error });
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -2,14 +2,28 @@ export async function findElements(args) {
|
|
|
2
2
|
switch (args.platform) {
|
|
3
3
|
case "android":
|
|
4
4
|
try {
|
|
5
|
+
const parentElement = await args.driver.$(args.selector);
|
|
6
|
+
const children = await parentElement.$$(".//*");
|
|
7
|
+
const childInfo = [];
|
|
8
|
+
for (const el of children) {
|
|
9
|
+
childInfo.push({
|
|
10
|
+
class: await el.getAttribute("class"),
|
|
11
|
+
resource_id: await el.getAttribute("resource-id"),
|
|
12
|
+
text: await el.getAttribute("text"),
|
|
13
|
+
content_desc: await el.getAttribute("content-desc"),
|
|
14
|
+
});
|
|
15
|
+
}
|
|
5
16
|
args.scriptDataAppender.add(async () => {
|
|
6
17
|
return {
|
|
7
18
|
nlpName: "MOB_FindElements",
|
|
8
|
-
stepInputs: [
|
|
19
|
+
stepInputs: [],
|
|
9
20
|
elementsData: [{
|
|
10
21
|
name: args.elementName,
|
|
11
22
|
type: args.elementType,
|
|
12
|
-
locators: [{
|
|
23
|
+
locators: [{
|
|
24
|
+
locatorType: "xpath",
|
|
25
|
+
locatorValue: args.value
|
|
26
|
+
}],
|
|
13
27
|
platform: args.platform
|
|
14
28
|
}]
|
|
15
29
|
};
|
|
@@ -1,38 +1,36 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
1
|
export const getScreenshot = async (args) => {
|
|
4
2
|
const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
|
|
5
3
|
let fileName = args.value
|
|
6
4
|
? args.value.trim().replace(/\s+/g, "_")
|
|
7
5
|
: `Screenshot_${timestamp}`;
|
|
8
|
-
// Ensure .png extension
|
|
9
6
|
if (!fileName.toLowerCase().endsWith(".png")) {
|
|
10
7
|
fileName += ".png";
|
|
11
8
|
}
|
|
12
|
-
const folderPath = path.resolve("./screenshots");
|
|
13
|
-
if (!fs.existsSync(folderPath)) {
|
|
14
|
-
fs.mkdirSync(folderPath);
|
|
15
|
-
}
|
|
16
|
-
const filePath = path.join(folderPath, fileName);
|
|
17
9
|
switch (args.platform) {
|
|
18
10
|
case "android":
|
|
11
|
+
try {
|
|
12
|
+
args.scriptDataAppender.add(async () => ({
|
|
13
|
+
nlpName: "MOB_GetScreenshot",
|
|
14
|
+
stepInputs: [fileName],
|
|
15
|
+
elementsData: []
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
args.scriptDataAppender.setErrorNLP("MOB_GetScreenshot");
|
|
20
|
+
throw new Error("GetScreenshot action failed", { cause: error });
|
|
21
|
+
}
|
|
22
|
+
break;
|
|
19
23
|
case "web":
|
|
20
24
|
default:
|
|
21
25
|
try {
|
|
22
|
-
// ACTUAL SCREENSHOT
|
|
23
|
-
await args.driver.saveScreenshot(filePath);
|
|
24
26
|
args.scriptDataAppender.add(async () => ({
|
|
25
|
-
nlpName:
|
|
26
|
-
? "MOB_GetScreenshot"
|
|
27
|
-
: "GetScreenshot",
|
|
27
|
+
nlpName: "GetScreenshot",
|
|
28
28
|
stepInputs: [fileName],
|
|
29
29
|
elementsData: []
|
|
30
30
|
}));
|
|
31
31
|
}
|
|
32
32
|
catch (error) {
|
|
33
|
-
args.scriptDataAppender.setErrorNLP(
|
|
34
|
-
? "MOB_GetScreenshot"
|
|
35
|
-
: "GetScreenshot");
|
|
33
|
+
args.scriptDataAppender.setErrorNLP("GetScreenshot");
|
|
36
34
|
throw new Error("GetScreenshot action failed", { cause: error });
|
|
37
35
|
}
|
|
38
36
|
break;
|
|
@@ -1,30 +1,16 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
1
|
export const getScreenshotAs = async (args) => {
|
|
4
2
|
const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
|
|
5
|
-
let fileName = args.
|
|
6
|
-
// ✅ Ensure .png extension
|
|
3
|
+
let fileName = args.elementName ? args.elementName : `Screenshot_${timestamp}.png`;
|
|
7
4
|
if (!fileName.endsWith(".png")) {
|
|
8
5
|
fileName += ".png";
|
|
9
6
|
}
|
|
10
|
-
const folderPath = path.resolve("./screenshots");
|
|
11
|
-
if (!fs.existsSync(folderPath)) {
|
|
12
|
-
fs.mkdirSync(folderPath);
|
|
13
|
-
}
|
|
14
|
-
const filePath = path.join(folderPath, fileName);
|
|
15
7
|
switch (args.platform) {
|
|
16
8
|
case "android":
|
|
17
|
-
case "web":
|
|
18
|
-
default:
|
|
19
9
|
try {
|
|
20
10
|
const element = await args.driver.$(args.selector);
|
|
21
11
|
await element.waitForDisplayed({ timeout: 10000 });
|
|
22
|
-
// ✅ Screenshot capture
|
|
23
|
-
await element.saveScreenshot(filePath);
|
|
24
12
|
args.scriptDataAppender.add(async () => ({
|
|
25
|
-
nlpName:
|
|
26
|
-
? "MOB_GetScreenshotAs"
|
|
27
|
-
: "GetScreenshotAs",
|
|
13
|
+
nlpName: "MOB_GetScreenshotAs",
|
|
28
14
|
stepInputs: [fileName],
|
|
29
15
|
elementsData: [{
|
|
30
16
|
name: args.elementName,
|
|
@@ -39,5 +25,29 @@ export const getScreenshotAs = async (args) => {
|
|
|
39
25
|
throw new Error("GetScreenshotAs action failed", { cause: error });
|
|
40
26
|
}
|
|
41
27
|
break;
|
|
28
|
+
case "web":
|
|
29
|
+
default:
|
|
30
|
+
try {
|
|
31
|
+
const element = await args.driver.$(args.selector);
|
|
32
|
+
await element.waitForDisplayed({ timeout: 10000 });
|
|
33
|
+
args.scriptDataAppender.add(async () => {
|
|
34
|
+
const ffElement = await args.elementGetter.getFireFlinkElement(args.pageDOM, `[ff-inspect="${args.fireflinkIndex}"]`);
|
|
35
|
+
return {
|
|
36
|
+
nlpName: "GetScreenshotAs",
|
|
37
|
+
stepInputs: [fileName],
|
|
38
|
+
elementsData: [{
|
|
39
|
+
name: args.elementName,
|
|
40
|
+
type: args.elementType,
|
|
41
|
+
locators: ffElement.locators,
|
|
42
|
+
platform: args.platform
|
|
43
|
+
}]
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
args.scriptDataAppender.setErrorNLP("GetScreenshotAs");
|
|
49
|
+
throw new Error("GetScreenshotAs action failed", { cause: error });
|
|
50
|
+
}
|
|
51
|
+
break;
|
|
42
52
|
}
|
|
43
53
|
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export async function MOB_PinchInByPercent(args) {
|
|
2
|
+
try {
|
|
3
|
+
const element = await args.driver.$(args.selector);
|
|
4
|
+
await args.driver.execute('mobile: pinchOpenGesture', {
|
|
5
|
+
elementId: element.elementId,
|
|
6
|
+
percent: Number(args.value) / 100
|
|
7
|
+
});
|
|
8
|
+
args.scriptDataAppender.add(async () => {
|
|
9
|
+
return {
|
|
10
|
+
nlpName: 'MOB_PinchInByPercent',
|
|
11
|
+
stepInputs: [args.value],
|
|
12
|
+
elementsData: [{
|
|
13
|
+
name: args.elementName,
|
|
14
|
+
type: args.elementType,
|
|
15
|
+
locators: [{
|
|
16
|
+
xpath: args.selector
|
|
17
|
+
}],
|
|
18
|
+
platform: args.platform
|
|
19
|
+
}]
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
args.scriptDataAppender.setErrorNLP("MOB_PinchInByPercent");
|
|
25
|
+
throw new Error("MOB_PinchInByPercent failed", { cause: error });
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export async function MOB_PinchOutByPercent(args) {
|
|
2
|
+
try {
|
|
3
|
+
const element = await args.driver.$(args.selector);
|
|
4
|
+
await args.driver.execute('mobile: pinchCloseGesture', {
|
|
5
|
+
elementId: element.elementId,
|
|
6
|
+
percent: Number(args.value) / 100
|
|
7
|
+
});
|
|
8
|
+
args.scriptDataAppender.add(async () => {
|
|
9
|
+
return {
|
|
10
|
+
nlpName: 'MOB_PinchOutByPercent',
|
|
11
|
+
stepInputs: [args.value],
|
|
12
|
+
elementsData: [{
|
|
13
|
+
name: args.elementName,
|
|
14
|
+
type: args.elementType,
|
|
15
|
+
locators: [{
|
|
16
|
+
xpath: args.selector
|
|
17
|
+
}],
|
|
18
|
+
platform: args.platform
|
|
19
|
+
}]
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
args.scriptDataAppender.setErrorNLP("MOB_PinchOutByPercent");
|
|
25
|
+
throw new Error("MOB_PinchOutByPercent failed", { cause: error });
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export async function pressBackSpaceKey(args) {
|
|
2
|
+
try {
|
|
3
|
+
await args.driver.pressKeyCode(67);
|
|
4
|
+
args.scriptDataAppender.add(async () => {
|
|
5
|
+
return {
|
|
6
|
+
nlpName: 'MOB_PressBackSpaceKey',
|
|
7
|
+
stepInputs: [],
|
|
8
|
+
elementsData: []
|
|
9
|
+
};
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
args.scriptDataAppender.setErrorNLP("MOB_PressBackSpaceKey");
|
|
14
|
+
throw new Error(`PressBackSpaceKey action failed :`, { cause: error });
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export async function pressSpaceKey(args) {
|
|
2
|
+
try {
|
|
3
|
+
await args.driver.pressKeyCode(62);
|
|
4
|
+
args.scriptDataAppender.add(async () => {
|
|
5
|
+
return {
|
|
6
|
+
nlpName: 'MOB_PressSpaceKey',
|
|
7
|
+
stepInputs: [],
|
|
8
|
+
elementsData: []
|
|
9
|
+
};
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
args.scriptDataAppender.setErrorNLP("MOB_PressSpaceKey");
|
|
14
|
+
throw new Error(`PressSpaceKey action failed :`, { cause: error });
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { executeSwipeMovement } from "../../../../utils/swipe/swipeMovement.js";
|
|
2
|
+
export async function swipeDirectionNTimes(args) {
|
|
3
|
+
try {
|
|
4
|
+
const count = Number(args.num_of_scrolls) || 30;
|
|
5
|
+
const direction = args.direction || "down";
|
|
6
|
+
let previousDom = "";
|
|
7
|
+
for (let i = 0; i < count; i++) {
|
|
8
|
+
await executeSwipeMovement(args.driver, direction);
|
|
9
|
+
const currentDom = await args.driver.getPageSource();
|
|
10
|
+
if (currentDom === previousDom) {
|
|
11
|
+
throw new Error("End of page reached. Stopping swipe.");
|
|
12
|
+
}
|
|
13
|
+
previousDom = currentDom;
|
|
14
|
+
}
|
|
15
|
+
args.scriptDataAppender.add(async () => {
|
|
16
|
+
return {
|
|
17
|
+
nlpName: 'MOB_SwipeDirectionNTimes',
|
|
18
|
+
stepInputs: [direction, count.toString()],
|
|
19
|
+
elementsData: []
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
args.scriptDataAppender.setErrorNLP("MOB_SwipeDirectionNTimes");
|
|
25
|
+
throw new Error("MOB_SwipeDirectionNTimes action failed", { cause: error });
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { executeSwipeMovement } from "../../../../utils/swipe/swipeMovement.js";
|
|
2
|
+
import { findElementInDom } from "../../../../utils/swipe/domSearchHelper.js";
|
|
3
|
+
export async function swipeDownToElement(args) {
|
|
4
|
+
try {
|
|
5
|
+
const maxScrolls = Number(args.num_of_scrolls) || 30;
|
|
6
|
+
const direction = "down";
|
|
7
|
+
const searchText = args.value;
|
|
8
|
+
if (!searchText.trim()) {
|
|
9
|
+
throw new Error("SwipeDownToElement requires search text");
|
|
10
|
+
}
|
|
11
|
+
let found = false;
|
|
12
|
+
let discoveredXPath = "";
|
|
13
|
+
let previousDom = "";
|
|
14
|
+
for (let attempt = 1; attempt <= maxScrolls; attempt++) {
|
|
15
|
+
await executeSwipeMovement(args.driver, direction);
|
|
16
|
+
const currentDom = await args.driver.getPageSource();
|
|
17
|
+
if (currentDom === previousDom) {
|
|
18
|
+
throw new Error("End of page reached. Stopping swipe.");
|
|
19
|
+
}
|
|
20
|
+
previousDom = currentDom;
|
|
21
|
+
const result = await findElementInDom(args.driver, searchText);
|
|
22
|
+
if (result) {
|
|
23
|
+
discoveredXPath = result.xpath;
|
|
24
|
+
found = true;
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (!found) {
|
|
29
|
+
throw new Error(`Element "${searchText}" not found after ${maxScrolls} attempts`);
|
|
30
|
+
}
|
|
31
|
+
args.scriptDataAppender.add(async () => ({
|
|
32
|
+
nlpName: "MOB_SwipeDownToElement",
|
|
33
|
+
stepInputs: [],
|
|
34
|
+
elementsData: [{
|
|
35
|
+
name: args.elementName || searchText,
|
|
36
|
+
type: args.elementType,
|
|
37
|
+
locators: [{ xpath: discoveredXPath }],
|
|
38
|
+
platform: args.platform
|
|
39
|
+
}]
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
args.scriptDataAppender.setErrorNLP("MOB_SwipeDownToElement");
|
|
44
|
+
throw new Error("MOB_SwipeDownToElement action failed", { cause: error });
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { executeSwipeMovement } from "../../../../utils/swipe/swipeMovement.js";
|
|
2
|
+
import { findElementInDom } from "../../../../utils/swipe/domSearchHelper.js";
|
|
3
|
+
export async function swipeLeftToElement(args) {
|
|
4
|
+
try {
|
|
5
|
+
const maxScrolls = Number(args.num_of_scrolls) || 30;
|
|
6
|
+
const direction = "left";
|
|
7
|
+
const searchText = args.value || args.elementName || "";
|
|
8
|
+
if (!searchText.trim()) {
|
|
9
|
+
throw new Error("SwipeLeftToElement requires search text");
|
|
10
|
+
}
|
|
11
|
+
let found = false;
|
|
12
|
+
let discoveredXPath = "";
|
|
13
|
+
let previousDom = "";
|
|
14
|
+
for (let attempt = 1; attempt <= maxScrolls; attempt++) {
|
|
15
|
+
await executeSwipeMovement(args.driver, direction);
|
|
16
|
+
const currentDom = await args.driver.getPageSource();
|
|
17
|
+
if (currentDom === previousDom) {
|
|
18
|
+
throw new Error("End of page reached. Stopping swipe.");
|
|
19
|
+
}
|
|
20
|
+
previousDom = currentDom;
|
|
21
|
+
const result = await findElementInDom(args.driver, searchText);
|
|
22
|
+
if (result) {
|
|
23
|
+
discoveredXPath = result.xpath;
|
|
24
|
+
found = true;
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (!found) {
|
|
29
|
+
throw new Error(`Element "${searchText}" not found after ${maxScrolls} swipes`);
|
|
30
|
+
}
|
|
31
|
+
args.scriptDataAppender.add(async () => ({
|
|
32
|
+
nlpName: "MOB_SwipeLeftToElement",
|
|
33
|
+
stepInputs: [],
|
|
34
|
+
elementsData: [{
|
|
35
|
+
name: args.elementName || searchText,
|
|
36
|
+
type: args.elementType,
|
|
37
|
+
locators: [{ xpath: discoveredXPath }],
|
|
38
|
+
platform: args.platform
|
|
39
|
+
}]
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
args.scriptDataAppender.setErrorNLP("MOB_SwipeLeftToElement");
|
|
44
|
+
throw new Error("MOB_SwipeLeftToElement action failed", { cause: error });
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { executeSwipeMovement } from "../../../../utils/swipe/swipeMovement.js";
|
|
2
|
+
import { findElementInDom } from "../../../../utils/swipe/domSearchHelper.js";
|
|
3
|
+
export async function swipeRightToElement(args) {
|
|
4
|
+
try {
|
|
5
|
+
const maxScrolls = Number(args.num_of_scrolls) || 30;
|
|
6
|
+
const direction = "right";
|
|
7
|
+
const searchText = args.value;
|
|
8
|
+
if (!searchText.trim()) {
|
|
9
|
+
throw new Error("SwipeRightToElement requires search text");
|
|
10
|
+
}
|
|
11
|
+
let found = false;
|
|
12
|
+
let discoveredXPath = "";
|
|
13
|
+
let previousDom = "";
|
|
14
|
+
for (let attempt = 1; attempt <= maxScrolls; attempt++) {
|
|
15
|
+
await executeSwipeMovement(args.driver, direction);
|
|
16
|
+
const currentDom = await args.driver.getPageSource();
|
|
17
|
+
if (currentDom === previousDom) {
|
|
18
|
+
throw new Error("End of page reached. Stopping swipe.");
|
|
19
|
+
}
|
|
20
|
+
previousDom = currentDom;
|
|
21
|
+
const result = await findElementInDom(args.driver, searchText);
|
|
22
|
+
if (result) {
|
|
23
|
+
discoveredXPath = result.xpath;
|
|
24
|
+
found = true;
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (!found) {
|
|
29
|
+
throw new Error(`Element "${searchText}" not found after ${maxScrolls} attempts`);
|
|
30
|
+
}
|
|
31
|
+
args.scriptDataAppender.add(async () => ({
|
|
32
|
+
nlpName: "MOB_SwipeRightToElement",
|
|
33
|
+
stepInputs: [],
|
|
34
|
+
elementsData: [{
|
|
35
|
+
name: args.elementName || searchText,
|
|
36
|
+
type: args.elementType,
|
|
37
|
+
locators: [{ xpath: discoveredXPath }],
|
|
38
|
+
platform: args.platform
|
|
39
|
+
}]
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
args.scriptDataAppender.setErrorNLP("MOB_SwipeRightToElement");
|
|
44
|
+
throw new Error("MOB_SwipeRightToElement action failed", { cause: error });
|
|
45
|
+
}
|
|
46
|
+
}
|