ff-automationv2 2.2.15 โ†’ 2.2.17

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.
@@ -27,8 +27,10 @@ export interface AutomationRequest {
27
27
  appiumPort: number;
28
28
  realDeviceId: string;
29
29
  platformVersion: string;
30
+ broker: string[];
31
+ sslConfig: any;
32
+ isTerminate: boolean;
30
33
  isCloud?: boolean;
31
34
  capabilities?: Record<string, any>;
32
35
  cloudConfig?: CloudConfig;
33
- isTerminate: boolean;
34
36
  }
@@ -31,7 +31,7 @@ export interface IFireflinkService {
31
31
  }
32
32
  export interface IKafkaPayload {
33
33
  message: IPayload & {
34
- scriptGenerationData: IScriptGenerationData[];
34
+ stepData: IScriptGenerationData[];
35
35
  serverHost: string;
36
36
  };
37
37
  topic: string;
@@ -86,7 +86,7 @@ export class AutomationRunner {
86
86
  return AutomationRunner.updateSessionTerminationInfo(request.testCaseId);
87
87
  AutomationRunner.sessionTerminationDetails[request.testCaseId] = request.isTerminate;
88
88
  const apiService = new FireFlinkApiService();
89
- const fireflinkServiceInstance = new fireflinkService(apiService);
89
+ const fireflinkServiceInstance = new fireflinkService(apiService, request.broker, request.sslConfig);
90
90
  const instanceDetails = await fireflinkServiceInstance.runGetInstancesDetails(request.projectId, request.token, request.serverData);
91
91
  const aiInfo = getAiInstanceInfo(instanceDetails.responseObject);
92
92
  const context = new ExecutionContext(request);
@@ -559,11 +559,11 @@ export class AutomationRunner {
559
559
  };
560
560
  try {
561
561
  await context.scriptAppender.waitForAllSteps();
562
- // logger.info(context.scriptAppender.getData(), payload)
562
+ logger.info(context.scriptAppender.getData(), payload);
563
563
  this.KafkaPayload.topic = `Topic-FIREFLINK-api-requests-${request.serverHost}`;
564
564
  this.KafkaPayload.message = {
565
565
  ...payload,
566
- scriptGenerationData: context.scriptAppender.getData(),
566
+ stepData: context.scriptAppender.getData(),
567
567
  serverHost: request.serverHost
568
568
  };
569
569
  logger.info(this.KafkaPayload);
@@ -2,7 +2,7 @@ import { IFireflinkService, IFireFlinkApiService, IKafkaPayload } from "../core/
2
2
  export declare class fireflinkService implements IFireflinkService {
3
3
  private apiService;
4
4
  private kafkaProducer;
5
- constructor(apiService: IFireFlinkApiService);
5
+ constructor(apiService: IFireFlinkApiService, broker: string[], sslConfig: any);
6
6
  runGetInstancesDetails(projectId: string, token: string, serverData: string): Promise<any>;
7
7
  produceMessageToKafka(kafkaArgs: IKafkaPayload): Promise<void>;
8
8
  }
@@ -1,9 +1,9 @@
1
1
  import { KafkaProducerService } from "./kafka/fireflinkKafka.service.js";
2
2
  import { logger } from "../utils/logger/logData.js";
3
3
  export class fireflinkService {
4
- constructor(apiService) {
4
+ constructor(apiService, broker, sslConfig) {
5
5
  this.apiService = apiService;
6
- this.kafkaProducer = new KafkaProducerService();
6
+ this.kafkaProducer = new KafkaProducerService(broker, sslConfig);
7
7
  }
8
8
  async runGetInstancesDetails(projectId, token, serverData) {
9
9
  const headers = {
@@ -2,6 +2,6 @@ import { IKafkaPayload } from "../../core/interfaces/fireflinkScriptPayloadInter
2
2
  export declare class KafkaProducerService {
3
3
  private kafka;
4
4
  private kafkaProducer;
5
- constructor();
5
+ constructor(brokers: string[], sslConfig: any);
6
6
  produceMessage(kafkaArgs: IKafkaPayload): Promise<void>;
7
7
  }
@@ -1,18 +1,19 @@
1
- import { Kafka } from "kafkajs";
1
+ import { Kafka, logLevel } from "kafkajs";
2
2
  import { logger } from "../../utils/logger/logData.js";
3
- import fs from "fs";
4
3
  import dotenv from "dotenv";
5
4
  dotenv.config();
6
5
  export class KafkaProducerService {
7
- constructor() {
6
+ constructor(brokers, sslConfig) {
8
7
  this.kafka = new Kafka({
9
- clientId: process.env.KAFKA_CLIENT_ID,
10
- brokers: process.env.KAFKA_BROKERS.split(","),
11
- ssl: {
12
- ca: [fs.readFileSync(process.env.KAFKA_SSL_CA, "utf-8")],
13
- key: fs.readFileSync(process.env.KAFKA_SSL_KEY, "utf-8"),
14
- cert: fs.readFileSync(process.env.KAFKA_SSL_CERT, "utf-8"),
15
- rejectUnauthorized: true,
8
+ clientId: "FireFlinK-AI-Automation",
9
+ brokers: brokers,
10
+ ssl: sslConfig,
11
+ logLevel: logLevel.ERROR,
12
+ connectionTimeout: 10000,
13
+ requestTimeout: 60000,
14
+ retry: {
15
+ initialRetryTime: 300,
16
+ retries: 10,
16
17
  },
17
18
  });
18
19
  this.kafkaProducer = this.kafka.producer();
File without changes
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ // import { AutomationRunner } from "../core/main/runAutomationScript.js";
3
+ // import { RuntimePromptRegistry } from "../framework/promptRegistry.runtime.js";
4
+ // import { RuntimeActionRegistry } from "../framework/actionRegistry.runtime.js";
5
+ // import { createDefaultPromptRegistry, registerDefaultPrompts } from "../framework/registerDefaultPrompts.js";
6
+ // import { createDefaultActionRegistry, registerDefaultActions } from "../framework/registerDefaultActions.js";
7
+ // // export { AutomationRunner };
8
+ // // export { RuntimePromptRegistry };
9
+ // // export { RuntimeActionRegistry };
10
+ // // export { createDefaultPromptRegistry, registerDefaultPrompts };
11
+ // // export { createDefaultActionRegistry, registerDefaultActions };
12
+ // // import { AutomationRunner, RuntimeActionRegistry } from "ff-automationv2";
13
+ // const actionRegistry = new RuntimeActionRegistry();
14
+ // // actionRegistry.register("minimize", {
15
+ // // handler: async (context) => {
16
+ // // const browser = await context.session.getCurrentBrowser();
17
+ // // await browser.minimizeWindow();
18
+ // // context.scriptAppender.add({
19
+ // // nlpName: "Minimize",
20
+ // // elementsData: [],
21
+ // // stepInputs: []
22
+ // // });
23
+ // // },
24
+ // // requiresExecutor: true,
25
+ // // requiresElement: false,
26
+ // // requiresInput: false
27
+ // // });
28
+ // const runner = new AutomationRunner(20000, 15000, { actionRegistry });
29
+ // runner.run({
30
+ // userStory: "(open the browser ),( navigate to https://www.google.com/) ,(wait for 2 sec),(minimize the browser) ",
31
+ // platform: "android",
32
+ // pageDetails: {
33
+ // Web: {
34
+ // pageId: "PAG73a7a0ad-c092-4351-8a93-68647f60e343",
35
+ // pageName: "ai-Page"
36
+ // }
37
+ // },
38
+ // service_accounts: "",
39
+ // serverHost: "https://test3.fireflink.com",
40
+ // webSocketId: "",
41
+ // generatedBy: "",
42
+ // licenseType: "C-Professional",
43
+ // licenseId: "LIC3985",
44
+ // userId: "USR26935",
45
+ // topic: "Topic-FIREFLINK-aiAutomation-Updates-test3",
46
+ // projectType: "Web",
47
+ // browser: {
48
+ // browserName: "chrome",
49
+ // },
50
+ // serverData: {},
51
+ // scriptName: "url",
52
+ // scriptType: "android",
53
+ // projectId: "PJT1116",
54
+ // testCaseId: "SCR1208",
55
+ // promptId: "3f6e123c-8ec6-47c1-90e1-1a2f53b49251",
56
+ // userName: "default-user",
57
+ // visionApikey: "Z3NrX2VubE44UVI5bmNzMlg0TXVsNDJHV0dkeWIzRllEYmJRV0lremZYaTRkME5VTzBjODZ4eHY=",
58
+ // apiKey: "Z3NrX2VubE44UVI5bmNzMlg0TXVsNDJHV0dkeWIzRllEYmJRV0lremZYaTRkME5VTzBjODZ4eHY=",
59
+ // model: "llama-3.3-70b-versatile",
60
+ // serviceProvider: "Groq",
61
+ // token: "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJEeE5VelJXSGhLTUVkSTVKQnV6eERFM3NsczVHRkV5cmJNeHVHNWtmNnRZIn0.eyJleHAiOjE3NzUyMjI3OTAsImlhdCI6MTc3MjYzMDc5MCwianRpIjoib25ydHJvOmY2ZDcwNzg1LTk4ODQtNDgzNS04ZjE2LWNiNzk5NjhiNWQzYSIsImlzcyI6Imh0dHA6Ly8xMDMuMTgyLjIxMC4yMjY6MzAxMDcvcmVhbG1zL0ZpcmVGbGluay10ZXN0MyIsImF1ZCI6InRhcmdldC1jbGllbnQiLCJzdWIiOiJmOmNhMzBmNDk3LTY1Y2YtNGU4Zi1iZGE3LTE0ZjM1NTNiYzZmNTpqYWlha2FzaEB5b3BtYWlsLmNvbSIsInR5cCI6IkJlYXJlciIsImF6cCI6ImZsaW5rLXNlcnZpY2UiLCJzaWQiOiJhMzg0MTVkMS1hYWZkLTQ4MTYtOWNhYS01MGVmMGMxZWI0ODciLCJhY3IiOiIxIiwiYWxsb3dlZC1vcmlnaW5zIjpbIioiXSwicmVhbG1fYWNjZXNzIjp7InJvbGVzIjpbIm9mZmxpbmVfYWNjZXNzIiwidW1hX2F1dGhvcml6YXRpb24iXX0sInNjb3BlIjoiZW1haWwgcHJvZmlsZSIsImN1cnJlbnRMaWNlbnNlSWQiOiJMSUMzOTg1IiwiZW1haWxfdmVyaWZpZWQiOmZhbHNlLCJjdXJyZW50UHJpdmlsZWdlIjoiU3VwZXIgQWRtaW4iLCJmdWxsTmFtZSI6ImphaSIsImFjdGl2YXRpb25TdGF0dXMiOiJBQ1RJVkUiLCJwcml2aWxlZ2UiOiJTdXBlciBBZG1pbiIsImxpY2Vuc2VOYW1lIjoiRmlyZUZsaW5rIC0gTElDMzk4NSIsInByZWZlcnJlZF91c2VybmFtZSI6ImphaSIsInVzZXJOYW1lIjoiamFpYWthc2hAeW9wbWFpbC5jb20iLCJiaWxsaW5nQ3ljbGUiOiJRdWFydGVybHkiLCJpZCI6IlVTUjI2OTM1IiwibGljZW5zZUlkIjoiTElDMzk4NSIsImVtYWlsIjoiamFpYWthc2hAeW9wbWFpbC5jb20ifQ.NCu_Oo86ld4tHCjWqTC2YxeBOifhWqwqmh1K7Cz6v4XEhDQuUrdULzKCOBWbYXA86BqT8oqWLOg2lA88G-LRnayCiBEutlbTbPIYsbghyuJCeagA_E9VJnM0fcccJqRi16dKG1em3cuZ2nJTQ8s_Bq1211ovPGI-Jyy2IBTc-fTDI0C4o9x8O0jpT_mz8COzCDwbCAon2e1EKxYjnyU360ZMwmwcnJjWqB5vsr384fKdrq3zx_zLESvW81x2bRGxzGYoO2hS38PWSrZbiOANNXzjVU9nDSU4kx280oBZo251rVRE58jJ4kKDSxLqmshT0TP-PERMqhNps9U2envExg",
62
+ // })
@@ -0,0 +1 @@
1
+ declare let system_prompt: string;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ let system_prompt = `You are given a 2D array of test steps. Each step is an array where the first element is a string describing the action, and optional additional elements may contain variable references.
3
+
4
+ Your task is to extract structured data based on the following rules:
5
+
6
+ 1. Find the FIRST occurrence of a step whose text contains "start iteration" (case-insensitive).
7
+ 2. From that point, begin collecting all steps.
8
+ 3. Continue collecting until you encounter the FIRST occurrence of a step whose text contains "End iteration" (case-insensitive) AFTER the start.
9
+ 4. Include both the "start iteration" and "End iteration" steps.
10
+ 5. STOP immediately after the first "End iteration".
11
+ 6. Ignore all steps before and after this block.
12
+
13
+ Data extraction rules:
14
+ 7. From the "start iteration" step, extract the instance name inside single quotes.
15
+ Example: "start iteration using 'Data1' Dataprovider" โ†’ instanceName = "Data1"
16
+
17
+ 8. From each step, if a second element exists and contains text like "Dataprovider <variableName>", extract the variable name.
18
+ Example: "Dataprovider val1" โ†’ "val1"
19
+
20
+ 9. Collect all variable names into a list called "variables" (preserve order).
21
+
22
+ Output format (STRICT):
23
+
24
+ * Return ONLY valid JSON
25
+ * No explanations or extra text
26
+ * Use this exact structure:
27
+
28
+ {
29
+ "instanceName": "string",
30
+ "variables": ["var1", "var2"],
31
+ "steps": [ ...extracted steps... ]
32
+ }
33
+
34
+ Edge cases:
35
+
36
+ * If no valid block is found, return:
37
+ {
38
+ "instanceName": "",
39
+ "variables": [],
40
+ "steps": []
41
+ }
42
+
43
+ `;
@@ -0,0 +1,6 @@
1
+ declare function findMaxNonNestedPatterns<T>(arr: T[]): {
2
+ pattern: T[];
3
+ count: number;
4
+ startIndexes: number[];
5
+ }[];
6
+ declare const arr: number[];
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ function findMaxNonNestedPatterns(arr) {
3
+ const results = [];
4
+ let i = 0;
5
+ while (i < arr.length) {
6
+ let best = null;
7
+ for (let size = 1; size <= Math.floor((arr.length - i) / 2); size++) {
8
+ const pattern = arr.slice(i, i + size);
9
+ let j = i;
10
+ let count = 0;
11
+ const indexes = [];
12
+ while (j + size <= arr.length) {
13
+ let match = true;
14
+ for (let k = 0; k < size; k++) {
15
+ if (arr[j + k] !== pattern[k]) {
16
+ match = false;
17
+ break;
18
+ }
19
+ }
20
+ if (!match)
21
+ break;
22
+ indexes.push(j);
23
+ count++;
24
+ j += size;
25
+ }
26
+ if (count > 1) {
27
+ // ๐Ÿ”ฅ Keep ONLY longest pattern (removes nested duplicates)
28
+ if (!best || pattern.length > best.pattern.length) {
29
+ best = { pattern, count, startIndexes: indexes };
30
+ }
31
+ }
32
+ }
33
+ if (best) {
34
+ results.push(best);
35
+ // ๐Ÿ”ฅ Skip entire block (avoid re-detection)
36
+ const last = best.startIndexes[best.startIndexes.length - 1];
37
+ i = last + best.pattern.length;
38
+ }
39
+ else {
40
+ i++;
41
+ }
42
+ }
43
+ return results;
44
+ }
45
+ const arr = [1, 2, 1, 2, 1, 2, 1, 2, 3, 4, 3, 4, 1, 2, 1, 2, 1, 2, 1, 2];
46
+ console.log(findMaxNonNestedPatterns(arr));
@@ -0,0 +1,7 @@
1
+ type SessionState = {
2
+ testCase: string;
3
+ env: "local" | "cloud";
4
+ isTerminate: boolean;
5
+ };
6
+ declare let sessionList: SessionState[];
7
+ declare const founds1: boolean;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ let sessionList = [
3
+ { testCase: "A", env: "local", isTerminate: false },
4
+ { testCase: "B", env: "cloud", isTerminate: false },
5
+ { testCase: "B", env: "cloud", isTerminate: true },
6
+ { testCase: "C", env: "local", isTerminate: false }
7
+ ];
8
+ sessionList = sessionList.filter(item => !(item.testCase === "B" && item.env === "cloud" && item.isTerminate === true));
9
+ const founds1 = sessionList.some(item => item.testCase === "A" &&
10
+ item.env === "local" &&
11
+ item.isTerminate === false);
12
+ console.log(sessionList);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,79 @@
1
+ import { AutomationRunner } from "../index.js";
2
+ import path from "path";
3
+ const runner = new AutomationRunner();
4
+ runner.run({
5
+ userStory: [
6
+ ["Open browser"],
7
+ ["Navigate to https://www.google.com/"],
8
+ ["Maximize the browser"],
9
+ // ["Navigate to https://www.google.com/"],
10
+ // ["Maximize the browser"],
11
+ // ["Navigate to https://www.google.com/"],
12
+ // ["Maximize the browser"],
13
+ // ["click on Gmail link"],
14
+ ["Close browser"],
15
+ // ["start iteration using 'Data1' Dataprovider"],
16
+ // ["enter 'startIteration1' in search field"],
17
+ // ["enter level-A in search field"],
18
+ // ["start iteration using 'Data1' Dataprovider"],
19
+ // ["enter 'startIteration1' in search field"],
20
+ // ["enter level-B in search field"],
21
+ // ["End iteration"],
22
+ // ["End iteration"],
23
+ // ["click on Gmail link"],
24
+ // ["Close browser"],
25
+ ],
26
+ platform: "web",
27
+ pageDetails: {
28
+ Web: {
29
+ pageId: "PAG73a7a0ad-c092-4351-8a93-68647f60e343",
30
+ pageName: "ai-Page"
31
+ }
32
+ },
33
+ broker: ["test3.fireflink.com:9092"],
34
+ sslConfig: {
35
+ rejectUnauthorized: false,
36
+ ca: ["D:\Bitbucket\automationV2\Certificates\certificate.crt"]
37
+ },
38
+ sessionPath: path.join("D:", "Bitbucket", "automationV2"),
39
+ serverHost: "test3",
40
+ // topic: "",
41
+ // serviceAccounts: "",
42
+ webSocketId: "",
43
+ generatedBy: "",
44
+ licenseType: "C-Professional",
45
+ licenseId: "LIC3985",
46
+ userId: "USR26935",
47
+ projectType: "Web",
48
+ browser: {
49
+ browserName: "chrome",
50
+ },
51
+ serverData: "https://test3.fireflink.com",
52
+ version: "asdfg",
53
+ type: "sdfg",
54
+ scriptName: "url",
55
+ scriptType: "web",
56
+ projectId: "PJT1116",
57
+ testCaseId: "SCR1208",
58
+ promptId: "3f6e123c-8ec6-47c1-90e1-1a2f53b49251",
59
+ userName: "default-user",
60
+ appiumPort: 0,
61
+ platformVersion: "",
62
+ realDeviceId: "",
63
+ isCloud: false,
64
+ cloudConfig: {
65
+ accessKey: "yfAa_w199cJge2Gezsgb2Jnu7hKdqER1tExY5kKvgSvXfi1lRUelFsbTFI5pMq7zQuwwNXXnsLTkjKhvWcKDWsUoGLi9KjUV6gbUNDhqj0jWYFyW9h_0LIDEg5qXigwZdqzQqAvWwHin3gBhzGndeROtixv_VFhnseGSWRAHTajZzE-Zl0d8BP6gl0TEBUfoNgqBtAQVDLP6wAQzPfcyjjGFsdHkXWeHFkKmA78D7rKlnNuN2WgjIUlhYheDRDeqZ98Ig_PyS1GbUvjwJ73L38sr_cD4Y9lrKyWJV-m5RmtKhmkqRM8uk5gEfjzgwy30",
66
+ hostname: "devicefarm.fireflink.com",
67
+ licenseId: "LIC2026658",
68
+ projectName: "Project-6",
69
+ protocol: "https",
70
+ path: "backend/fireflinkcloud/wd/hub"
71
+ },
72
+ capabilities: {
73
+ browserName: "chrome",
74
+ platformName: "Windows 11",
75
+ browserVersion: "146"
76
+ },
77
+ isTerminate: false,
78
+ token: "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJRUFRfTnFuMkxxdDVmN09tOElWaW53dUJlR3ZVUUVBUkdxZkFuRHJxZU9NIn0.eyJleHAiOjE3NzUxMDczODIsImlhdCI6MTc3NTAyMDk4MiwianRpIjoib25ydHJvOmVkOGU3NzA4LTQ0OGUtNDdhZi05OTU0LWNjMWZkMzNlN2E1OCIsImlzcyI6Imh0dHA6Ly8xMDMuMTgyLjIxMC4yMjY6MzAxMDcvcmVhbG1zL0ZpcmVGbGluay10ZXN0MyIsImF1ZCI6InRhcmdldC1jbGllbnQiLCJzdWIiOiJmOmNhMzBmNDk3LTY1Y2YtNGU4Zi1iZGE3LTE0ZjM1NTNiYzZmNTpqYWlha2FzaEB5b3BtYWlsLmNvbSIsInR5cCI6IkJlYXJlciIsImF6cCI6ImZsaW5rLXNlcnZpY2UiLCJzaWQiOiIxOGExYWFiYy0xYzA5LTQ4YTMtOGJhMi01OThhYTc2MDkyZjYiLCJhY3IiOiIxIiwiYWxsb3dlZC1vcmlnaW5zIjpbIioiXSwicmVhbG1fYWNjZXNzIjp7InJvbGVzIjpbIm9mZmxpbmVfYWNjZXNzIiwidW1hX2F1dGhvcml6YXRpb24iXX0sInNjb3BlIjoiZW1haWwgcHJvZmlsZSIsImN1cnJlbnRMaWNlbnNlSWQiOiJMSUMzOTg1IiwiZW1haWxfdmVyaWZpZWQiOmZhbHNlLCJjdXJyZW50UHJpdmlsZWdlIjoiU3VwZXIgQWRtaW4iLCJmdWxsTmFtZSI6ImphaSIsImFjdGl2YXRpb25TdGF0dXMiOiJBQ1RJVkUiLCJwcml2aWxlZ2UiOiJTdXBlciBBZG1pbiIsImxpY2Vuc2VOYW1lIjoiRmlyZUZsaW5rIC0gTElDMzk4NSIsInByZWZlcnJlZF91c2VybmFtZSI6ImphaSIsInVzZXJOYW1lIjoiamFpYWthc2hAeW9wbWFpbC5jb20iLCJiaWxsaW5nQ3ljbGUiOiJRdWFydGVybHkiLCJpZCI6IlVTUjI2OTM1IiwibGljZW5zZUlkIjoiTElDMzk4NSIsImVtYWlsIjoiamFpYWthc2hAeW9wbWFpbC5jb20ifQ.HxaDrSYbsIjz0u0_Kmg3rEy4y4-tFuDWhbWYHllWUQnXD9-yQQEx1u2dE_nzc-wRHkwtKf3nieO1HjQ-rmm0wy7P9vCpSTQg8Z8EY7G1GpxObHdLgqoRe1JvXbMXJu9LSWI80Kt0EgdTEdN93MwfhRTyHNEkdr4X8q0bvbkkYNu9r5PZs-NZnsQaAeHygsx85CSuYfXq43_LgMC6qPVpRS0y0V36hzEJVylwSg2z3xP9znAWHohL_F5gQ9Er8r1t3xUgy6_ob-0t_q7Bha5iaYOq0vl2P51DkT87C7NIzm5TjiiSUWZwIdLBKUKXSWNUG1RX89mrTZyuYyocO1yNng"
79
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,82 @@
1
+ import { remote } from 'webdriverio';
2
+ import { encode } from '@toon-format/toon';
3
+ import * as cheerio from 'cheerio';
4
+ import fs from 'fs';
5
+ import { encoding_for_model } from "@dqbd/tiktoken";
6
+ // ๐Ÿ”„ HTML โ†’ JSON
7
+ function htmlToJson(html) {
8
+ const $ = cheerio.load(html);
9
+ // ๐Ÿงน remove useless elements
10
+ $('script, style, noscript, iframe').remove();
11
+ function parseElement(elem, depth = 0) {
12
+ if (!elem || depth > 6)
13
+ return null;
14
+ const node = {
15
+ tag: elem.name,
16
+ attrs: elem.attribs || {},
17
+ children: [] // โœ… FIX
18
+ };
19
+ for (const child of elem.children || []) {
20
+ if (child.type === 'text') {
21
+ const text = child.data.trim();
22
+ if (text) {
23
+ node.children.push({ text });
24
+ }
25
+ }
26
+ else if (child.type === 'tag') {
27
+ const parsed = parseElement(child, depth + 1);
28
+ if (parsed) {
29
+ node.children.push(parsed);
30
+ }
31
+ }
32
+ }
33
+ return node;
34
+ }
35
+ return parseElement($('body')[0]);
36
+ }
37
+ // ๐Ÿš€ Main runner
38
+ async function run() {
39
+ const browser = await remote({
40
+ capabilities: {
41
+ browserName: 'chrome'
42
+ }
43
+ });
44
+ try {
45
+ // ๐ŸŒ Open Amazon
46
+ await browser.url('https://www.amzon.in/');
47
+ // โณ wait for search box
48
+ const searchBox = await browser.$('#twotabsearchtextbox');
49
+ await searchBox.waitForDisplayed({ timeout: 10000 });
50
+ // ๐Ÿ“„ Get HTML
51
+ const html = await browser.getPageSource();
52
+ // ๐Ÿ”„ Convert HTML โ†’ JSON
53
+ const json = htmlToJson(html);
54
+ // ๐Ÿ”„ JSON โ†’ TOON
55
+ const start = performance.now();
56
+ const encoded = encode({ data: json });
57
+ const end = performance.now();
58
+ console.log('HTML :', html.length);
59
+ console.log('json size:', JSON.stringify(json).length);
60
+ console.log('Encoded length:', encoded.length);
61
+ console.log(`Time taken: ${(end - start).toFixed(2)} ms`);
62
+ // ๐Ÿ’พ Save outputs (optional but useful)
63
+ fs.writeFileSync('output.json', JSON.stringify(json, null, 2));
64
+ fs.writeFileSync('output.toon', encoded);
65
+ const enc = encoding_for_model("gpt-4"); // closest available
66
+ function countTokens(text) {
67
+ return enc.encode(text).length;
68
+ }
69
+ const jsonString = JSON.stringify(json);
70
+ console.log("Token JSON count:", countTokens(jsonString));
71
+ const jsonStringencoded = JSON.stringify(encoded);
72
+ console.log("Token TOON count:", countTokens(jsonStringencoded));
73
+ }
74
+ catch (err) {
75
+ console.error(err);
76
+ }
77
+ finally {
78
+ await browser.deleteSession();
79
+ }
80
+ }
81
+ run();
82
+ console.log("hi");
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,25 @@
1
+ import { remote } from "webdriverio";
2
+ async function runTest() {
3
+ const browser = await remote({
4
+ logLevel: "debug",
5
+ protocol: "https",
6
+ hostname: "devicefarm.fireflink.com",
7
+ port: 443,
8
+ path: "/backend/fireflinkcloud/wd/hub",
9
+ capabilities: {
10
+ browserName: "chrome",
11
+ platformName: "Windows 11",
12
+ browserVersion: "146",
13
+ "devicefarm:networkLogEnable": false,
14
+ "fireflink:deviceType": "public",
15
+ // ๐Ÿ”น Query params moved here
16
+ "fireflink:accessKey": "yfAa_w199cJge2Gezsgb2Jnu7hKdqER1tExY5kKvgSvXfi1lRUelFsbTFI5pMq7zQuwwNXXnsLTkjKhvWcKDWsUoGLi9KjUV6gbUNDhqj0jWYFyW9h_0LIDEg5qXigwZdqzQqAvWwHin3gBhzGndeROtixv_VFhnseGSWRAHTajZzE-Zl0d8BP6gl0TEBUfoNgqBtAQVDLP6wAQzPfcyjjGFsdHkXWeHFkKmA78D7rKlnNuN2WgjIUlhYheDRDeqZ98Ig_PyS1GbUvjwJ73L38sr_cD4Y9lrKyWJV-m5RmtKhmkqRM8uk5gEfjzgwy30",
17
+ "fireflink:licenseId": "LIC2026658",
18
+ "fireflink:projectName": "Project-6",
19
+ },
20
+ });
21
+ await browser.url("https://www.google.com");
22
+ await browser.deleteSession();
23
+ }
24
+ runTest();
25
+ console.log("hi");
@@ -0,0 +1 @@
1
+ export declare const testdata: Record<string, any>;
@@ -0,0 +1,5 @@
1
+ export const testdata = {
2
+ Data1: {
3
+ startIteration1: [1, 2, 3],
4
+ }
5
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ff-automationv2",
3
- "version": "2.2.15",
3
+ "version": "2.2.17",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "This lib is used to automate the manual testcase",