ff-automationv2 2.2.14 → 2.2.16

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.
Files changed (94) hide show
  1. package/dist/ai/llmprompts/systemPrompts/combinedActionExtractorPromptMob.js +4 -3
  2. package/dist/ai/llmprompts/systemPrompts/errorDescriptionPrompt.js +9 -11
  3. package/dist/ai/llmprompts/systemPrompts/fireflinkElementIndexExtactors.js +7 -7
  4. package/dist/ai/llmprompts/systemPrompts/fireflinkElementIndexExtractor_Mob.js +39 -0
  5. package/dist/ai/llmprompts/systemPrompts/mobileKeywordExtractor.js +2 -1
  6. package/dist/ai/llmprompts/systemPrompts/verifyActionExtractorPromptMob.js +2 -1
  7. package/dist/ai/llmprompts/systemPrompts/visionPrompt.js +3 -2
  8. package/dist/ai/llmprompts/systemPrompts/waitActionExtractorPrompt.js +1 -0
  9. package/dist/ai/llmprompts/systemPrompts/waitActionExtractorPromptMob.js +1 -0
  10. package/dist/automation/actions/executor.d.ts +19 -1
  11. package/dist/automation/actions/executor.js +303 -1
  12. package/dist/automation/actions/interaction/click/MOB_DoubleTapAtSpecifiedLocation.d.ts +2 -0
  13. package/dist/automation/actions/interaction/click/MOB_DoubleTapAtSpecifiedLocation.js +26 -0
  14. package/dist/automation/actions/interaction/elementLessAction/MobCheckIfAppIsClosed.d.ts +2 -0
  15. package/dist/automation/actions/interaction/elementLessAction/MobCheckIfAppIsClosed.js +20 -0
  16. package/dist/automation/actions/interaction/elementLessAction/MobRunAppInBackgroundInterface.d.ts +2 -0
  17. package/dist/automation/actions/interaction/elementLessAction/MobRunAppInBackgroundInterface.js +18 -0
  18. package/dist/automation/actions/interaction/enterActions/EnterInputIntoElementFromClipBoardInterface_mob.d.ts +2 -0
  19. package/dist/automation/actions/interaction/enterActions/EnterInputIntoElementFromClipBoardInterface_mob.js +26 -0
  20. package/dist/automation/actions/interaction/enterActions/enterInput.js +2 -2
  21. package/dist/automation/actions/interaction/enterActions/enterInputAndPress.js +1 -1
  22. package/dist/automation/actions/interaction/enterActions/enterusingJs.js +1 -1
  23. package/dist/automation/actions/interaction/enterActions/waitAndEnter.js +3 -3
  24. package/dist/automation/actions/interaction/find/MOB_FindElement.d.ts +2 -0
  25. package/dist/automation/actions/interaction/find/MOB_FindElement.js +34 -0
  26. package/dist/automation/actions/interaction/find/findElements.js +16 -2
  27. package/dist/automation/actions/interaction/get/getScreenshot.js +14 -16
  28. package/dist/automation/actions/interaction/get/getScreenshotAs.js +26 -16
  29. package/dist/automation/actions/interaction/pinch/PinchInByPercentMob.d.ts +2 -0
  30. package/dist/automation/actions/interaction/pinch/PinchInByPercentMob.js +27 -0
  31. package/dist/automation/actions/interaction/pinch/PinchOutByPercentMob.d.ts +2 -0
  32. package/dist/automation/actions/interaction/pinch/PinchOutByPercentMob.js +27 -0
  33. package/dist/automation/actions/interaction/press/mobPressBackSpaceKey.d.ts +2 -0
  34. package/dist/automation/actions/interaction/press/mobPressBackSpaceKey.js +16 -0
  35. package/dist/automation/actions/interaction/press/mobPressSpaceKey.d.ts +2 -0
  36. package/dist/automation/actions/interaction/press/mobPressSpaceKey.js +16 -0
  37. package/dist/automation/actions/interaction/swipe/swipeDirectionNTimes.d.ts +2 -0
  38. package/dist/automation/actions/interaction/swipe/swipeDirectionNTimes.js +27 -0
  39. package/dist/automation/actions/interaction/swipe/swipeDownToElement.d.ts +2 -0
  40. package/dist/automation/actions/interaction/swipe/swipeDownToElement.js +46 -0
  41. package/dist/automation/actions/interaction/swipe/swipeLeftToElement.d.ts +2 -0
  42. package/dist/automation/actions/interaction/swipe/swipeLeftToElement.js +46 -0
  43. package/dist/automation/actions/interaction/swipe/swipeRightToElement.d.ts +2 -0
  44. package/dist/automation/actions/interaction/swipe/swipeRightToElement.js +46 -0
  45. package/dist/automation/actions/interaction/swipe/swipeUpToElement.d.ts +2 -0
  46. package/dist/automation/actions/interaction/swipe/swipeUpToElement.js +49 -0
  47. package/dist/automation/actions/interaction/swipe/swipeUpToElementForMWeb.d.ts +2 -0
  48. package/dist/automation/actions/interaction/swipe/swipeUpToElementForMWeb.js +48 -0
  49. package/dist/automation/actions/interaction/swipe/swipeUsingReferenceElement.d.ts +2 -0
  50. package/dist/automation/actions/interaction/swipe/swipeUsingReferenceElement.js +140 -0
  51. package/dist/automation/actions/interaction/verify/VerifyElementNotContainsText.js +2 -2
  52. package/dist/automation/actions/interaction/wait/waitTillElementIsClickable.js +5 -1
  53. package/dist/automation/actions/interaction/wait/waitTillPresenceOfElement.js +1 -1
  54. package/dist/automation/actions/interface/clickActionInterface.d.ts +8 -0
  55. package/dist/automation/actions/interface/elelementLessActionInterface.d.ts +12 -0
  56. package/dist/automation/actions/interface/elelementLessActionInterface.js +1 -0
  57. package/dist/automation/actions/interface/findActionInterface.d.ts +10 -2
  58. package/dist/automation/actions/interface/interactionActionInterface.d.ts +8 -0
  59. package/dist/automation/actions/interface/pinchActionInterface.d.ts +19 -0
  60. package/dist/automation/actions/interface/pinchActionInterface.js +1 -0
  61. package/dist/automation/actions/interface/pressActionInterface.d.ts +10 -0
  62. package/dist/automation/actions/interface/swipeActionInterface.d.ts +89 -0
  63. package/dist/automation/actions/interface/swipeActionInterface.js +1 -0
  64. package/dist/automation/actions/interface/waitActionInterface.d.ts +1 -0
  65. package/dist/core/constants/allAction.js +1 -0
  66. package/dist/core/constants/supportedActions.js +9 -1
  67. package/dist/core/interfaces/actionInterface.d.ts +19 -1
  68. package/dist/core/interfaces/executionDetails.d.ts +1 -4
  69. package/dist/core/interfaces/fireflinkScriptPayloadInterface.d.ts +2 -3
  70. package/dist/core/main/actionHandlerFactory.js +62 -2
  71. package/dist/core/main/runAutomationScript.d.ts +0 -1
  72. package/dist/core/main/runAutomationScript.js +17 -13
  73. package/dist/service/fireflink.service.d.ts +2 -4
  74. package/dist/service/fireflink.service.js +4 -5
  75. package/dist/service/kafka/fireflinkKafka.service.d.ts +2 -2
  76. package/dist/service/kafka/fireflinkKafka.service.js +17 -3
  77. package/dist/tests/itertaion.d.ts +1 -0
  78. package/dist/tests/itertaion.js +43 -0
  79. package/dist/tests/start_iteration_suggestion.d.ts +6 -0
  80. package/dist/tests/start_iteration_suggestion.js +46 -0
  81. package/dist/tests/test1.js +0 -1
  82. package/dist/tests/test12.js +26 -75
  83. package/dist/tests/test254.d.ts +1 -0
  84. package/dist/tests/test254.js +82 -0
  85. package/dist/tests/test3.js +2 -1
  86. package/dist/tests/tests.data.d.ts +1 -0
  87. package/dist/tests/tests.data.js +5 -0
  88. package/dist/utils/logger/logData.d.ts +1 -0
  89. package/dist/utils/logger/logData.js +49 -22
  90. package/dist/utils/swipe/domSearchHelper.d.ts +5 -0
  91. package/dist/utils/swipe/domSearchHelper.js +42 -0
  92. package/dist/utils/swipe/swipeMovement.d.ts +1 -0
  93. package/dist/utils/swipe/swipeMovement.js +81 -0
  94. package/package.json +3 -4
@@ -1,37 +1,53 @@
1
1
  import fs from "fs/promises";
2
2
  import path from "path";
3
3
  import beautify from "js-beautify";
4
- const logsDir = path.resolve(process.cwd(), "logs");
5
- const domDir = path.resolve(process.cwd(), "dom");
6
- const screenshotsDir = path.resolve(process.cwd(), "screenshots");
7
- const now = new Date();
8
- const istDate = new Intl.DateTimeFormat("sv-SE", {
9
- timeZone: "Asia/Kolkata",
10
- year: "numeric",
11
- month: "2-digit",
12
- day: "2-digit",
13
- hour: "2-digit",
14
- minute: "2-digit",
15
- second: "2-digit",
16
- fractionalSecondDigits: 3,
17
- hour12: false,
18
- })
19
- .format(now)
20
- .replace(" ", "T");
21
- const logFilePath = path.join(logsDir, "ai-execution-logs.txt");
4
+ let sessionPath;
5
+ let logsDir;
6
+ let domDir;
7
+ let screenshotsDir;
8
+ let logFilePath;
9
+ export function initLogger(basePath) {
10
+ sessionPath = basePath;
11
+ logsDir = path.resolve(sessionPath, "logs");
12
+ domDir = path.resolve(sessionPath, "dom");
13
+ screenshotsDir = path.resolve(sessionPath, "screenshots");
14
+ logFilePath = path.join(logsDir, "ai-execution-logs.txt");
15
+ }
22
16
  async function ensureDirs() {
17
+ if (!logsDir)
18
+ throw new Error("Logger not initialized");
23
19
  await fs.mkdir(logsDir, { recursive: true });
24
20
  await fs.mkdir(domDir, { recursive: true });
25
21
  await fs.mkdir(screenshotsDir, { recursive: true });
26
22
  }
27
- ensureDirs();
23
+ function getISTDate() {
24
+ return new Intl.DateTimeFormat("sv-SE", {
25
+ timeZone: "Asia/Kolkata",
26
+ year: "numeric",
27
+ month: "2-digit",
28
+ day: "2-digit",
29
+ hour: "2-digit",
30
+ minute: "2-digit",
31
+ second: "2-digit",
32
+ fractionalSecondDigits: 3,
33
+ hour12: false,
34
+ })
35
+ .format(new Date())
36
+ .replace(" ", "T");
37
+ }
28
38
  export const logger = {
29
39
  info: async (...args) => {
40
+ if (!logFilePath)
41
+ throw new Error("Logger not initialized");
42
+ await ensureDirs();
30
43
  const formattedArgs = args.map((arg) => typeof arg === "object" ? JSON.stringify(arg, null, 2) : arg);
31
- const message = `[INFO] ${istDate}+05:30 - ${formattedArgs.join(" ")}\n`;
44
+ const message = `[INFO] ${getISTDate()}+05:30 - ${formattedArgs.join(" ")}\n`;
32
45
  await fs.appendFile(logFilePath, message, "utf-8");
33
46
  },
34
47
  error: async (...args) => {
48
+ if (!logFilePath)
49
+ throw new Error("Logger not initialized");
50
+ await ensureDirs();
35
51
  const formatted = args.map((arg) => {
36
52
  if (arg instanceof Error) {
37
53
  let output = arg.stack || `${arg.name}: ${arg.message}`;
@@ -71,6 +87,9 @@ export const logger = {
71
87
  return formatted.join(" ");
72
88
  },
73
89
  saveDOM: async (domContent, fileName) => {
90
+ if (!domDir)
91
+ throw new Error("Logger not initialized");
92
+ await ensureDirs();
74
93
  const timestamp = new Date().toLocaleString().replace(/[:.]/g, "-");
75
94
  let finalFileName;
76
95
  let formattedContent;
@@ -90,17 +109,25 @@ export const logger = {
90
109
  await fs.writeFile(filePath, formattedContent, "utf-8");
91
110
  },
92
111
  saveJSON: async (data, fileName) => {
112
+ if (!domDir)
113
+ throw new Error("Logger not initialized");
114
+ await ensureDirs();
93
115
  const timestamp = new Date().toLocaleString().replace(/[:.]/g, "-");
94
- const finalFileName = fileName ? `${fileName}.json` : `data-${timestamp}.json`;
116
+ const finalFileName = fileName
117
+ ? `${fileName}.json`
118
+ : `data-${timestamp}.json`;
95
119
  const filePath = path.join(domDir, finalFileName);
96
120
  const safeData = JSON.stringify(data, (key, value) => {
97
121
  if (key === "element")
98
- return undefined; // remove DOM node
122
+ return undefined;
99
123
  return value;
100
124
  }, 2);
101
125
  await fs.writeFile(filePath, safeData, "utf-8");
102
126
  },
103
127
  saveImage: async (imageBuffer, fileName) => {
128
+ if (!screenshotsDir)
129
+ throw new Error("Logger not initialized");
130
+ await ensureDirs();
104
131
  const filePath = path.join(screenshotsDir, fileName);
105
132
  await fs.writeFile(filePath, imageBuffer);
106
133
  },
@@ -0,0 +1,5 @@
1
+ export declare function findElementInDom(driver: WebdriverIO.Browser, text: string): Promise<{
2
+ element: import("webdriverio").ChainablePromiseElement;
3
+ xpath: string;
4
+ annotatedDom: string;
5
+ } | null>;
@@ -0,0 +1,42 @@
1
+ import { getAnnotatedDOMForMobile } from "../DomExtraction/jsForAttributeInjection.js";
2
+ import { DomSimplifier } from "../../domAnalysis/simplifyAndFlatten.js";
3
+ import { getFFIndexAndXPath } from "../helpers/xpathcreation.js";
4
+ export async function findElementInDom(driver, text) {
5
+ const simplifier = new DomSimplifier();
6
+ const keywords = text
7
+ .toLowerCase()
8
+ .split(/\s+/)
9
+ .filter(Boolean);
10
+ const { dom: annotatedDom } = await getAnnotatedDOMForMobile(driver);
11
+ const { flatNodes } = simplifier.simplifyMobile(annotatedDom);
12
+ const sequenceMatch = (value, words) => {
13
+ const v = value.toLowerCase();
14
+ const pattern = new RegExp("\\b" + words.join("\\s*") + "\\b", "i");
15
+ return pattern.test(v);
16
+ };
17
+ for (const nodeObj of flatNodes) {
18
+ const node = nodeObj.node;
19
+ const textVal = (node["text"] || "").toLowerCase();
20
+ const descVal = (node["content-desc"] || "").toLowerCase();
21
+ const ridVal = (node["resource-id"] || "").toLowerCase();
22
+ if (sequenceMatch(textVal, keywords) ||
23
+ sequenceMatch(descVal, keywords) ||
24
+ sequenceMatch(ridVal, keywords)) {
25
+ const ffIndex = node["FF-inspecter"];
26
+ if (!ffIndex)
27
+ continue;
28
+ const xpath = getFFIndexAndXPath(annotatedDom, ffIndex);
29
+ if (!xpath)
30
+ continue;
31
+ const element = await driver.$(xpath.xpathPath);
32
+ if (await element.isExisting()) {
33
+ return {
34
+ element,
35
+ xpath: xpath.xpathPath,
36
+ annotatedDom
37
+ };
38
+ }
39
+ }
40
+ }
41
+ return null;
42
+ }
@@ -0,0 +1 @@
1
+ export declare function executeSwipeMovement(driver: WebdriverIO.Browser, direction: string): Promise<void>;
@@ -0,0 +1,81 @@
1
+ export async function executeSwipeMovement(driver, direction) {
2
+ if (direction === 'left' || direction === 'right') {
3
+ const horizontalContainers = [
4
+ '//android.widget.HorizontalScrollView',
5
+ '//androidx.recyclerview.widget.RecyclerView'
6
+ ];
7
+ let hsv = null;
8
+ for (const selector of horizontalContainers) {
9
+ const el = await driver.$(selector);
10
+ if (await el.isExisting()) {
11
+ hsv = el;
12
+ break;
13
+ }
14
+ }
15
+ if (hsv && typeof hsv.getRect === "function") {
16
+ const rect = await hsv.getRect();
17
+ const y = rect.y + Math.floor(rect.height / 2);
18
+ let startX, endX;
19
+ if (direction === 'left') {
20
+ startX = rect.x + Math.floor(rect.width * 0.8);
21
+ endX = rect.x + Math.floor(rect.width * 0.2);
22
+ }
23
+ else {
24
+ startX = rect.x + Math.floor(rect.width * 0.2);
25
+ endX = rect.x + Math.floor(rect.width * 0.8);
26
+ }
27
+ await performW3CSwipe(driver, startX, y, endX, y);
28
+ return;
29
+ }
30
+ }
31
+ const size = await driver.getWindowSize();
32
+ const midX = size.width / 2;
33
+ let startX, startY, endX, endY;
34
+ if (direction === 'up') {
35
+ startX = midX;
36
+ startY = size.height * 0.6;
37
+ endX = midX;
38
+ endY = size.height * 0.1;
39
+ }
40
+ else if (direction === 'down') {
41
+ startX = midX;
42
+ startY = size.height * 0.4;
43
+ endX = midX;
44
+ endY = size.height * 0.8;
45
+ }
46
+ else if (direction === 'left') {
47
+ startX = size.width * 0.8;
48
+ startY = size.height * 0.5;
49
+ endX = size.width * 0.2;
50
+ endY = size.height * 0.5;
51
+ }
52
+ else if (direction === 'right') {
53
+ startX = size.width * 0.2;
54
+ startY = size.height * 0.5;
55
+ endX = size.width * 0.8;
56
+ endY = size.height * 0.5;
57
+ }
58
+ else {
59
+ startX = midX;
60
+ startY = size.height * 0.8;
61
+ endX = midX;
62
+ endY = size.height * 0.2;
63
+ }
64
+ await performW3CSwipe(driver, startX, startY, endX, endY);
65
+ }
66
+ async function performW3CSwipe(driver, startX, startY, endX, endY) {
67
+ await driver.performActions([
68
+ {
69
+ type: 'pointer',
70
+ id: 'finger1',
71
+ parameters: { pointerType: 'touch' },
72
+ actions: [
73
+ { type: 'pointerMove', duration: 0, x: Math.floor(startX), y: Math.floor(startY) },
74
+ { type: 'pointerDown', button: 0 },
75
+ { type: 'pointerMove', duration: 800, x: Math.floor(endX), y: Math.floor(endY) },
76
+ { type: 'pointerUp', button: 0 }
77
+ ]
78
+ }
79
+ ]);
80
+ await driver.pause(1000);
81
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ff-automationv2",
3
- "version": "2.2.14",
3
+ "version": "2.2.16",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "This lib is used to automate the manual testcase",
@@ -23,7 +23,6 @@
23
23
  "prepare": "husky",
24
24
  "lint": "eslint src --max-warnings=0",
25
25
  "test": "npm run build && node dist/tests/test12.js",
26
- "test1": "npm run build && node dist/tests/test.js",
27
26
  "llm": "npm run build && node dist/tests/testllm.js",
28
27
  "dev": "npm run build && node dist/index.js",
29
28
  "start": "node dist/index.js",
@@ -50,8 +49,8 @@
50
49
  "nodemon": "3.1.11",
51
50
  "ts-node": "10.9.2",
52
51
  "typescript": "^5.9.3",
53
- "typescript-eslint": "8.56.0",
54
- "webdriverio": "9.26.1"
52
+ "webdriverio": "9.26.1",
53
+ "typescript-eslint": "8.56.0"
55
54
  },
56
55
  "dependencies": {
57
56
  "@xmldom/xmldom": "^0.8.11",