ff-automationv2 2.2.32 → 2.2.34-beta.0
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/llmPromptTypes/systemPromptTypes.d.ts +3 -0
- package/dist/ai/llmprompts/promptRegistry.js +4 -0
- package/dist/ai/llmprompts/systemPrompts/actionExtractorPrompt.js +16 -12
- package/dist/ai/llmprompts/systemPrompts/arithmeticPrompt.d.ts +2 -0
- package/dist/ai/llmprompts/systemPrompts/arithmeticPrompt.js +48 -0
- package/dist/ai/llmprompts/systemPrompts/getActionExtractorPrompt.js +1 -1
- package/dist/ai/llmprompts/systemPrompts/getActionExtractorPromptMob.js +1 -1
- package/dist/ai/llmprompts/systemPrompts/inputContextPrompt.js +2 -0
- package/dist/ai/llmprompts/systemPrompts/mobileKeywordExtractor.js +2 -2
- package/dist/ai/llmprompts/userPrompts/userPrompt.js +1 -0
- package/dist/automation/actions/executor.d.ts +1 -0
- package/dist/automation/actions/executor.js +25 -0
- package/dist/automation/actions/interaction/alert/enterDataToAlert.js +2 -2
- package/dist/automation/actions/interaction/alert/getTextPresentOnAlertPopup.js +2 -2
- package/dist/automation/actions/interaction/arithmetic/arithmeticOperations.d.ts +2 -0
- package/dist/automation/actions/interaction/arithmetic/arithmeticOperations.js +61 -0
- package/dist/automation/actions/interaction/clear/clear.js +4 -1
- package/dist/automation/actions/interaction/clear/clearAndEnter.js +7 -4
- package/dist/automation/actions/interaction/elementlessActions/getOtp.js +7 -7
- package/dist/automation/actions/interaction/enterActions/EnterInputIntoElementFromClipBoardInterface_mob.js +6 -3
- package/dist/automation/actions/interaction/enterActions/enterInput.js +8 -5
- package/dist/automation/actions/interaction/enterActions/enterInputAndPress.js +7 -4
- package/dist/automation/actions/interaction/enterActions/enterUrl.js +3 -3
- package/dist/automation/actions/interaction/enterActions/enterusingJs.js +2 -2
- package/dist/automation/actions/interaction/enterActions/waitAndEnter.js +7 -4
- package/dist/automation/actions/interaction/get/MOB_GetADBLogsForGivenAppPackage.js +2 -2
- package/dist/automation/actions/interaction/get/MOB_GetAllContexts.js +2 -2
- package/dist/automation/actions/interaction/get/MOB_GetAllWindowHandles.js +3 -3
- package/dist/automation/actions/interaction/get/MOB_GetAltitude.js +2 -2
- package/dist/automation/actions/interaction/get/MOB_GetBatteryPercentage.js +2 -2
- package/dist/automation/actions/interaction/get/MOB_GetBatteryStatus.js +2 -2
- package/dist/automation/actions/interaction/get/MOB_GetClipBoardText.js +2 -2
- package/dist/automation/actions/interaction/get/MOB_GetCurrentActivity.js +2 -2
- package/dist/automation/actions/interaction/get/MOB_GetCurrentAppPackage.js +2 -2
- package/dist/automation/actions/interaction/get/MOB_GetCurrentContext.js +2 -2
- package/dist/automation/actions/interaction/get/MOB_GetCurrentDeviceDate.js +2 -2
- package/dist/automation/actions/interaction/get/MOB_GetCurrentDeviceSettings.js +2 -2
- package/dist/automation/actions/interaction/get/MOB_GetCurrentDeviceStatus.js +2 -2
- package/dist/automation/actions/interaction/get/MOB_GetCurrentDeviceSystemBars.js +2 -2
- package/dist/automation/actions/interaction/get/MOB_GetCurrentDeviceTime.js +2 -2
- package/dist/automation/actions/interaction/get/MOB_GetCurrentOrientation.js +2 -2
- package/dist/automation/actions/interaction/get/MOB_GetCurrentSessionId.js +2 -2
- package/dist/automation/actions/interaction/get/MOB_GetDeviceLocation.js +2 -2
- package/dist/automation/actions/interaction/get/MOB_GetDeviceName.js +2 -2
- package/dist/automation/actions/interaction/get/MOB_GetDeviceOsVersion.js +2 -2
- package/dist/automation/actions/interaction/get/MOB_GetDeviceUdid.js +2 -2
- package/dist/automation/actions/interaction/get/MOB_GetHeightOfElement.js +2 -2
- package/dist/automation/actions/interaction/get/MOB_GetHeightOfScreen.js +2 -2
- package/dist/automation/actions/interaction/get/MOB_GetHourFromCurrentDeviceTime.js +2 -2
- package/dist/automation/actions/interaction/get/MOB_GetLatitude.js +2 -2
- package/dist/automation/actions/interaction/get/MOB_GetLongitude.js +2 -2
- package/dist/automation/actions/interaction/get/MOB_GetMinuteFromCurrentDeviceTime.js +2 -2
- package/dist/automation/actions/interaction/get/MOB_GetSecondFromCurrentDeviceTime.js +2 -2
- package/dist/automation/actions/interaction/get/MOB_GetSizeOfScreen.js +2 -2
- package/dist/automation/actions/interaction/get/MOB_GetSupportedPerformanceDataTypes.js +2 -2
- package/dist/automation/actions/interaction/get/MOB_GetTextFromElementAndSetToClipBoard.js +2 -2
- package/dist/automation/actions/interaction/get/MOB_GetWidthOfElement.js +2 -2
- package/dist/automation/actions/interaction/get/MOB_GetWidthOfScreen.js +2 -2
- package/dist/automation/actions/interaction/get/browserWindowGetPosition.js +2 -2
- package/dist/automation/actions/interaction/get/getAllBrokenImages.js +2 -2
- package/dist/automation/actions/interaction/get/getAllBrokenLinkCount.js +2 -2
- package/dist/automation/actions/interaction/get/getAllBrokenLinks.js +2 -2
- package/dist/automation/actions/interaction/get/getAllConsoleErrors.js +2 -2
- package/dist/automation/actions/interaction/get/getAllConsoleInformation.js +2 -2
- package/dist/automation/actions/interaction/get/getAllConsoleLogs.js +2 -2
- package/dist/automation/actions/interaction/get/getAllConsoleWarnings.js +2 -2
- package/dist/automation/actions/interaction/get/getAllCookieNames.js +2 -2
- package/dist/automation/actions/interaction/get/getAllCookieValues.js +2 -2
- package/dist/automation/actions/interaction/get/getAllSelectedOptions.js +2 -2
- package/dist/automation/actions/interaction/get/getAllTheOptionsFromListBoxAsText.js +2 -2
- package/dist/automation/actions/interaction/get/getAllTheOptionsFromListBoxAsTextInSortedOrder.js +2 -2
- package/dist/automation/actions/interaction/get/getAllTheSelectedOptionsFromListBoxAsText.js +2 -2
- package/dist/automation/actions/interaction/get/getAllWindowHandles.js +2 -2
- package/dist/automation/actions/interaction/get/getAttribute.js +3 -3
- package/dist/automation/actions/interaction/get/getAudioCurrentPlaybackRate.js +2 -2
- package/dist/automation/actions/interaction/get/getAudioCurrentSeekTime.js +2 -2
- package/dist/automation/actions/interaction/get/getAudioCurrentVolume.js +2 -2
- package/dist/automation/actions/interaction/get/getAudioDecodedByte.js +2 -2
- package/dist/automation/actions/interaction/get/getAudioDefaultPlaybackRate.js +2 -2
- package/dist/automation/actions/interaction/get/getAudioMediaLength.js +2 -2
- package/dist/automation/actions/interaction/get/getAudioMediaSource.js +2 -2
- package/dist/automation/actions/interaction/get/getBestPracticesScore.js +2 -2
- package/dist/automation/actions/interaction/get/getBrowserCount.js +2 -2
- package/dist/automation/actions/interaction/get/getBrowserVersion.js +2 -2
- package/dist/automation/actions/interaction/get/getCapabilityNames.js +2 -2
- package/dist/automation/actions/interaction/get/getClipBoardText.js +2 -2
- package/dist/automation/actions/interaction/get/getCollectiveApiResponseTime.js +2 -2
- package/dist/automation/actions/interaction/get/getCollectiveApiStatusCode.js +2 -2
- package/dist/automation/actions/interaction/get/getCssValue.js +2 -2
- package/dist/automation/actions/interaction/get/getCurrentDayOfTheWeek.js +2 -2
- package/dist/automation/actions/interaction/get/getCurrentSecondsFromCurrentSystemTime.js +2 -2
- package/dist/automation/actions/interaction/get/getCurrentSystemDate.js +2 -2
- package/dist/automation/actions/interaction/get/getCurrentSystemDay.js +2 -2
- package/dist/automation/actions/interaction/get/getCurrentSystemMonth.js +2 -2
- package/dist/automation/actions/interaction/get/getCurrentSystemTime.js +2 -2
- package/dist/automation/actions/interaction/get/getCurrentSystemYear.js +2 -2
- package/dist/automation/actions/interaction/get/getCurrentWindowHandle.js +2 -2
- package/dist/automation/actions/interaction/get/getDataFromApiRequestHeaderForJsonPath.js +2 -2
- package/dist/automation/actions/interaction/get/getDataFromApiResponseForJsonPath.js +2 -2
- package/dist/automation/actions/interaction/get/getDateWithGivenFormat.js +2 -2
- package/dist/automation/actions/interaction/get/getDriverInstance.js +2 -2
- package/dist/automation/actions/interaction/get/getFirstContentfulPaint.js +2 -2
- package/dist/automation/actions/interaction/get/getFirstSelectedOption.js +2 -2
- package/dist/automation/actions/interaction/get/getFullPaintTime.js +2 -2
- package/dist/automation/actions/interaction/get/getHTMLCodeOfPage.js +2 -2
- package/dist/automation/actions/interaction/get/getHeightOfBrowserWindow.js +2 -2
- package/dist/automation/actions/interaction/get/getHeightOfWebElement.js +2 -2
- package/dist/automation/actions/interaction/get/getHourFromCurrentSystemTime.js +2 -2
- package/dist/automation/actions/interaction/get/getImplicitTimeOut.js +2 -2
- package/dist/automation/actions/interaction/get/getLargestContentfulPaint.js +2 -2
- package/dist/automation/actions/interaction/get/getListBoxSize.js +2 -2
- package/dist/automation/actions/interaction/get/getListOfElementsFromLocatorTypeLocatorValue.js +3 -3
- package/dist/automation/actions/interaction/get/getLocation.js +3 -3
- package/dist/automation/actions/interaction/get/getMinuteFromCurrentSystemTime.js +2 -2
- package/dist/automation/actions/interaction/get/getNetworkRouteTime.js +2 -2
- package/dist/automation/actions/interaction/get/getNumberOfBrokenImages.js +2 -2
- package/dist/automation/actions/interaction/get/getNumberOfLinksPresentInCurrentPage.js +2 -2
- package/dist/automation/actions/interaction/get/getNumberOfWorkingLinksFromCurrentPage.js +2 -2
- package/dist/automation/actions/interaction/get/getOptions.js +2 -2
- package/dist/automation/actions/interaction/get/getPageTitle.js +2 -2
- package/dist/automation/actions/interaction/get/getPerformanceMetrics.js +2 -2
- package/dist/automation/actions/interaction/get/getPwaScore.js +2 -2
- package/dist/automation/actions/interaction/get/getRect.js +3 -3
- package/dist/automation/actions/interaction/get/getScreenshot.js +2 -2
- package/dist/automation/actions/interaction/get/getScreenshotAs.js +2 -2
- package/dist/automation/actions/interaction/get/getSeoScore.js +2 -2
- package/dist/automation/actions/interaction/get/getSingleApiRequestPayload.js +2 -2
- package/dist/automation/actions/interaction/get/getSingleApiResponse.js +2 -2
- package/dist/automation/actions/interaction/get/getSingleApiResponseTime.js +2 -2
- package/dist/automation/actions/interaction/get/getSingleApiStatusCode.js +2 -2
- package/dist/automation/actions/interaction/get/getSize.js +3 -3
- package/dist/automation/actions/interaction/get/getSizeOfBrowserWindow.js +2 -2
- package/dist/automation/actions/interaction/get/getStringDataFromLocalFile.js +2 -2
- package/dist/automation/actions/interaction/get/getSystemProperty.js +2 -2
- package/dist/automation/actions/interaction/get/getTagName.js +3 -3
- package/dist/automation/actions/interaction/get/getText.js +12 -5
- package/dist/automation/actions/interaction/get/getTheFirstSelectedOptionFromListBoxAsText.js +2 -2
- package/dist/automation/actions/interaction/get/getTotalNumberOfCookies.js +2 -2
- package/dist/automation/actions/interaction/get/getTunnelIdentifier.js +2 -2
- package/dist/automation/actions/interaction/get/getURLPresentInAddressBar.js +2 -2
- package/dist/automation/actions/interaction/get/getUserHomeDirectory.js +2 -2
- package/dist/automation/actions/interaction/get/getValueByCookieName.js +2 -2
- package/dist/automation/actions/interaction/get/getValueFromLocalStorage.js +2 -2
- package/dist/automation/actions/interaction/get/getValueOfSystemVariable.js +2 -2
- package/dist/automation/actions/interaction/get/getVideoCurrentPlaybackRate.js +2 -2
- package/dist/automation/actions/interaction/get/getVideoCurrentSeekTime.js +2 -2
- package/dist/automation/actions/interaction/get/getVideoCurrentVolume.js +2 -2
- package/dist/automation/actions/interaction/get/getVideoDecodedByte.js +2 -2
- package/dist/automation/actions/interaction/get/getVideoDefaultPlaybackRate.js +2 -2
- package/dist/automation/actions/interaction/get/getVideoMediaLength.js +2 -2
- package/dist/automation/actions/interaction/get/getVideoMediaSource.js +2 -2
- package/dist/automation/actions/interaction/get/getWidthOfBrowser.js +2 -2
- package/dist/automation/actions/interaction/get/getWidthOfWebElement.js +2 -2
- package/dist/automation/actions/interaction/get/getWorkingLinksFromCurrentPage.js +2 -2
- package/dist/automation/actions/interaction/get/getWrappedElement.js +2 -2
- package/dist/automation/actions/interaction/get/getWrappedOptionFromListBoxAsText.js +2 -2
- package/dist/automation/actions/interaction/get/getXLocationOfBrowserWindow.js +2 -2
- package/dist/automation/actions/interaction/get/getXLocationOfWebElement.js +3 -3
- package/dist/automation/actions/interaction/get/getYLocationOfBrowserWindow.js +2 -2
- package/dist/automation/actions/interaction/get/getYLocationOfWebElement.js +3 -3
- package/dist/automation/actions/interaction/iframe/switchToDefaultContent.js +1 -1
- package/dist/automation/actions/interaction/shadowDom/shadowDomEnter.js +2 -2
- package/dist/automation/actions/interaction/shadowDom/shadowDomGetText.js +2 -2
- package/dist/automation/actions/interaction/verify/VerifyElementNotContainsText.js +4 -1
- package/dist/automation/actions/interaction/verify/verifypartialtext.js +9 -2
- package/dist/automation/actions/interaction/verify/verifytext.js +9 -2
- package/dist/automation/actions/interface/FireFlinkResponseSchema.d.ts +13 -0
- package/dist/automation/actions/interface/FireFlinkResponseSchema.js +10 -1
- package/dist/automation/actions/interface/arithmeticActionInterface.d.ts +18 -0
- package/dist/automation/actions/interface/arithmeticActionInterface.js +2 -0
- package/dist/core/constants/allAction.js +2 -1
- package/dist/core/constants/supportedActions.js +2 -1
- package/dist/core/helpers/elementSelectorResolver.d.ts +1 -1
- package/dist/core/helpers/elementSelectorResolver.js +3 -2
- package/dist/core/helpers/runnerDomPipeline.d.ts +2 -2
- package/dist/core/helpers/runnerDomPipeline.js +20 -9
- package/dist/core/helpers/visionFallbackHandler.js +4 -4
- package/dist/core/interfaces/actionInterface.d.ts +2 -0
- package/dist/core/interfaces/automationRunnerInterface.d.ts +1 -0
- package/dist/core/interfaces/promptInterface.d.ts +3 -0
- package/dist/core/main/actionHandlerFactory.js +3 -0
- package/dist/core/main/runAutomationScript.js +53 -8
- package/dist/core/types/promptType.d.ts +2 -1
- package/dist/core/types/promptType.js +1 -0
- package/dist/fireflinkData/fireflinkLocators/getListOfLocators.d.ts +2 -1
- package/dist/fireflinkData/fireflinkLocators/getListOfLocators.js +2 -2
- package/dist/fireflinkData/fireflinkScript/appendScriptData.js +42 -6
- package/dist/fireflinkData/fireflinkScript/scriptGenrationData.d.ts +1 -0
- package/dist/fireflinkData/fireflinkScript/scriptGenrationData.js +1 -0
- package/dist/imageAnalysisWeb/annotateScreenshot.d.ts +1 -1
- package/dist/imageAnalysisWeb/annotateScreenshot.js +24 -10
- package/dist/imageAnalysisWeb/generateAnnotatedScreenshots.js +5 -2
- package/dist/tests/senario.d.ts +0 -0
- package/dist/tests/senario.js +1120 -0
- package/dist/tests/test12.d.ts +1 -0
- package/dist/tests/test12.js +34 -65
- package/dist/utils/DomExtraction/jsForAttributeInjection.js +23 -0
- package/dist/utils/helpers/xpathcreation.js +3 -0
- package/dist/utils/iframesExtraction/findElementUsingFF.js +1 -2
- package/dist/utils/iframesExtraction/switchToIframeByMeta.js +1 -1
- package/dist/utils/workers/locatorWorker.js +3 -1
- package/package.json +1 -1
- /package/dist/utils/helpers/{getHelper.d.ts → saveStepInputData.d.ts} +0 -0
- /package/dist/utils/helpers/{getHelper.js → saveStepInputData.js} +0 -0
|
@@ -205,6 +205,7 @@ class AutomationRunner {
|
|
|
205
205
|
currentPlatform = context.activePlatform;
|
|
206
206
|
(0, platformContext_js_1.setPlatform)(currentPlatform);
|
|
207
207
|
let stepResult;
|
|
208
|
+
let driverContext = null;
|
|
208
209
|
let stepAction;
|
|
209
210
|
let fireflinkIndex;
|
|
210
211
|
let selector;
|
|
@@ -266,7 +267,7 @@ class AutomationRunner {
|
|
|
266
267
|
stepsInputData.currentStepIndex = currentStepIndex;
|
|
267
268
|
context.executor?.setStepContext(currentStepIndex, currentStep, stepsInputData, step);
|
|
268
269
|
logData_js_1.logger.info("stepsInputData", stepsInputData);
|
|
269
|
-
const inputContextPromise = isStepValueDependable && stepsInputData.length > 0
|
|
270
|
+
const inputContextPromise = action !== "arithmetic" && isStepValueDependable && stepsInputData.length > 0
|
|
270
271
|
? stepProcessor.getLLMResponse({
|
|
271
272
|
platform: currentPlatform,
|
|
272
273
|
type: promptType_js_1.PromptType.INPUT_CONTEXT_PROMPT,
|
|
@@ -297,6 +298,36 @@ class AutomationRunner {
|
|
|
297
298
|
stepCount++;
|
|
298
299
|
continue;
|
|
299
300
|
}
|
|
301
|
+
if (action === "arithmetic") {
|
|
302
|
+
const arithmeticResult = await stepProcessor.getLLMResponse({
|
|
303
|
+
platform: currentPlatform,
|
|
304
|
+
type: promptType_js_1.PromptType.ARITHMETIC_PROMPT,
|
|
305
|
+
args: {
|
|
306
|
+
inputStepsContext: isStepValueDependable ? stepsInputData : [],
|
|
307
|
+
},
|
|
308
|
+
input: { currentStep },
|
|
309
|
+
});
|
|
310
|
+
let targetVarName = arithmeticResult?.response?.variableName?.trim() || "";
|
|
311
|
+
if (targetVarName) {
|
|
312
|
+
targetVarName = (0, elementSelectorResolver_js_1.generateUniqueName)(targetVarName, usedVariableNames);
|
|
313
|
+
}
|
|
314
|
+
handler = actionHandlers["arithmetic"];
|
|
315
|
+
await handler({
|
|
316
|
+
operandOne: arithmeticResult?.response?.operandOne,
|
|
317
|
+
operandTwo: arithmeticResult?.response?.operandTwo,
|
|
318
|
+
operandOneVariableName: arithmeticResult?.response?.operandOneVariableName,
|
|
319
|
+
operandTwoVariableName: arithmeticResult?.response?.operandTwoVariableName,
|
|
320
|
+
operation: arithmeticResult?.response?.operation,
|
|
321
|
+
variableName: targetVarName,
|
|
322
|
+
returnTypeVariableName: targetVarName,
|
|
323
|
+
stepIndex: currentStepIndex,
|
|
324
|
+
currentStep,
|
|
325
|
+
manualStep: step,
|
|
326
|
+
stepsInputData,
|
|
327
|
+
});
|
|
328
|
+
stepCount++;
|
|
329
|
+
continue;
|
|
330
|
+
}
|
|
300
331
|
if (action === "getOtp") {
|
|
301
332
|
if (!isWebMobile) {
|
|
302
333
|
throw new Error(`Selected platform is invalid for the step: ${step}`);
|
|
@@ -353,6 +384,8 @@ class AutomationRunner {
|
|
|
353
384
|
}
|
|
354
385
|
else {
|
|
355
386
|
driver = await context.mobileSession.getCurrentDriver();
|
|
387
|
+
const contexts = await driver.getContexts();
|
|
388
|
+
driverContext = contexts.find((context) => String(context).startsWith("WEBVIEW")) || null;
|
|
356
389
|
}
|
|
357
390
|
}
|
|
358
391
|
catch (error) {
|
|
@@ -410,10 +443,15 @@ class AutomationRunner {
|
|
|
410
443
|
if (inputContextResult?.response?.variableName && inputContextResult.response.variableName.trim() !== "") {
|
|
411
444
|
currentVariableName = inputContextResult.response.variableName.trim();
|
|
412
445
|
}
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
446
|
+
if (action === "verify") {
|
|
447
|
+
inputValue = stepResult?.response?.inputText;
|
|
448
|
+
}
|
|
449
|
+
else {
|
|
450
|
+
inputValue =
|
|
451
|
+
inputText && inputText.trim().length > 0
|
|
452
|
+
? inputText
|
|
453
|
+
: stepResult?.response?.inputText;
|
|
454
|
+
}
|
|
417
455
|
if (supportedActions_js_1.SKIPPED_ACTIONS.includes(stepAction)) {
|
|
418
456
|
handler = actionHandlers[stepAction];
|
|
419
457
|
await handler();
|
|
@@ -483,10 +521,10 @@ class AutomationRunner {
|
|
|
483
521
|
selector = "";
|
|
484
522
|
iframeDomHtml = null;
|
|
485
523
|
beforeHandles = null;
|
|
486
|
-
const retryDomResult = await runnerDomPipeline_js_1.RunnerDomPipeline.captureAndParseDom(driver, currentPlatform, stepCount, action, true);
|
|
524
|
+
const retryDomResult = await runnerDomPipeline_js_1.RunnerDomPipeline.captureAndParseDom(driver, currentPlatform, stepCount, action, true, driverContext);
|
|
487
525
|
domInfo = retryDomResult.domInfo;
|
|
488
526
|
doc = retryDomResult.doc;
|
|
489
|
-
const retryRelevantResult = await runnerDomPipeline_js_1.RunnerDomPipeline.processRelevantDom(domProcessor, domInfo, keywords, stepCount, action, currentStep, currentPlatform, driver, true);
|
|
527
|
+
const retryRelevantResult = await runnerDomPipeline_js_1.RunnerDomPipeline.processRelevantDom(domProcessor, domInfo, keywords, stepCount, action, currentStep, currentPlatform, driver, true, driverContext);
|
|
490
528
|
extractedRelevantDom = retryRelevantResult.extractedRelevantDom;
|
|
491
529
|
const retryToonDom = retryRelevantResult.toonDom;
|
|
492
530
|
const retryActionResolution = await (0, stepActionInspector_js_1.resolveStepActionFromDom)(stepProcessor, currentPlatform, action, retryToonDom, priorAndNextSteps, currentStep, null);
|
|
@@ -525,7 +563,7 @@ class AutomationRunner {
|
|
|
525
563
|
logData_js_1.logger.error(`element not found for step "${step}"`);
|
|
526
564
|
throw new Error(`element not found for step "${step}"`);
|
|
527
565
|
}
|
|
528
|
-
const selectorResult = await (0, elementSelectorResolver_js_1.resolveElementSelector)(doc, domInfo, fireflinkIndex, currentPlatform, driver);
|
|
566
|
+
const selectorResult = await (0, elementSelectorResolver_js_1.resolveElementSelector)(doc, domInfo, fireflinkIndex, currentPlatform, driver, fallbackAttempt, driverContext);
|
|
529
567
|
selector = selectorResult.selector;
|
|
530
568
|
doc = selectorResult.doc;
|
|
531
569
|
domInfo = selectorResult.domInfo;
|
|
@@ -563,6 +601,9 @@ class AutomationRunner {
|
|
|
563
601
|
});
|
|
564
602
|
preCapturedDomInfo = await (0, runnerPostActionHelper_js_1.handlePostActionWeb)(currentPlatform, driver, action, beforeHandles, context.scriptAppender, stepCount);
|
|
565
603
|
if (fallbackAttempt === 2) {
|
|
604
|
+
if (driverContext) {
|
|
605
|
+
await driver.switchContext("NATIVE_APP");
|
|
606
|
+
}
|
|
566
607
|
await reporter.sendRetry("Retry successful. Moving on to the next step.");
|
|
567
608
|
}
|
|
568
609
|
break;
|
|
@@ -597,11 +638,15 @@ class AutomationRunner {
|
|
|
597
638
|
actionHandlers,
|
|
598
639
|
reporter,
|
|
599
640
|
causeError: error,
|
|
641
|
+
driverContext,
|
|
600
642
|
});
|
|
601
643
|
if (visionResult.retryNeeded) {
|
|
602
644
|
continue;
|
|
603
645
|
}
|
|
604
646
|
preCapturedDomInfo = visionResult.preCapturedDomInfo;
|
|
647
|
+
if (driverContext) {
|
|
648
|
+
await driver.switchContext("NATIVE_APP");
|
|
649
|
+
}
|
|
605
650
|
break;
|
|
606
651
|
}
|
|
607
652
|
}
|
|
@@ -10,5 +10,6 @@ export declare enum PromptType {
|
|
|
10
10
|
COMBINED_ACTION_EXTRACTOR_PROMPT = "combinedActionExtractorPrompt",
|
|
11
11
|
OTP_EXTRACTOR = "otpExtractorPrompt",
|
|
12
12
|
FILE_VERIFY_PROMPT = "fileVerifyActionExtractorPrompt",
|
|
13
|
-
INPUT_CONTEXT_PROMPT = "inputContextPrompt"
|
|
13
|
+
INPUT_CONTEXT_PROMPT = "inputContextPrompt",
|
|
14
|
+
ARITHMETIC_PROMPT = "arithmeticPrompt"
|
|
14
15
|
}
|
|
@@ -15,4 +15,5 @@ var PromptType;
|
|
|
15
15
|
PromptType["OTP_EXTRACTOR"] = "otpExtractorPrompt";
|
|
16
16
|
PromptType["FILE_VERIFY_PROMPT"] = "fileVerifyActionExtractorPrompt";
|
|
17
17
|
PromptType["INPUT_CONTEXT_PROMPT"] = "inputContextPrompt";
|
|
18
|
+
PromptType["ARITHMETIC_PROMPT"] = "arithmeticPrompt";
|
|
18
19
|
})(PromptType || (exports.PromptType = PromptType = {}));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { platform } from "../../core/types/scriptTypesType.js";
|
|
1
2
|
import { LocatorWorkerPool } from "../../utils/workers/LocatorWorkerPool.js";
|
|
2
3
|
export declare class ElementGetter {
|
|
3
4
|
private readonly workerPool;
|
|
4
5
|
constructor(workerPool: LocatorWorkerPool);
|
|
5
|
-
getFireFlinkElement(html: string, attribute: string): Promise<any>;
|
|
6
|
+
getFireFlinkElement(html: string, attribute: string, targetPlatform?: platform): Promise<any>;
|
|
6
7
|
}
|
|
@@ -8,8 +8,8 @@ class ElementGetter {
|
|
|
8
8
|
constructor(workerPool) {
|
|
9
9
|
this.workerPool = workerPool;
|
|
10
10
|
}
|
|
11
|
-
async getFireFlinkElement(html, attribute) {
|
|
12
|
-
const platform = (0, platformContext_js_1.getPlatform)();
|
|
11
|
+
async getFireFlinkElement(html, attribute, targetPlatform) {
|
|
12
|
+
const platform = targetPlatform || (html?.includes("ff-inspect") ? "web" : (0, platformContext_js_1.getPlatform)());
|
|
13
13
|
// const formattedAttribute = attribute.replace('[', '//*[@');
|
|
14
14
|
try {
|
|
15
15
|
const result = await this.workerPool.getFireFlinkElement(html, attribute, platform);
|
|
@@ -3,10 +3,37 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.appendScriptData = appendScriptData;
|
|
4
4
|
const logData_js_1 = require("../../utils/logger/logData.js");
|
|
5
5
|
async function appendScriptData(args) {
|
|
6
|
+
const isMobile = args.platform === "android" || args.platform === "ios";
|
|
7
|
+
const isWebView = args.pageDOM?.includes("ff-inspect");
|
|
8
|
+
if (isMobile) {
|
|
9
|
+
if (args.scriptDataAppender.currentMobileView === undefined) {
|
|
10
|
+
args.scriptDataAppender.currentMobileView = "NATIVE";
|
|
11
|
+
}
|
|
12
|
+
if (isWebView && args.scriptDataAppender.currentMobileView !== "WEBVIEW") {
|
|
13
|
+
args.scriptDataAppender.add(async () => ({
|
|
14
|
+
nlpName: "MOB_SwitchToView",
|
|
15
|
+
stepInputs: ["WEBVIEW"],
|
|
16
|
+
elementsData: []
|
|
17
|
+
}));
|
|
18
|
+
args.scriptDataAppender.currentMobileView = "WEBVIEW";
|
|
19
|
+
}
|
|
20
|
+
else if (args.pageDOM && !isWebView && args.scriptDataAppender.currentMobileView === "WEBVIEW") {
|
|
21
|
+
args.scriptDataAppender.add(async () => ({
|
|
22
|
+
nlpName: "MOB_SwitchToNativeView",
|
|
23
|
+
stepInputs: [],
|
|
24
|
+
elementsData: []
|
|
25
|
+
}));
|
|
26
|
+
args.scriptDataAppender.currentMobileView = "NATIVE";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
6
29
|
args.scriptDataAppender.add(async () => {
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
30
|
+
const isWebView = args.pageDOM?.includes("ff-inspect");
|
|
31
|
+
const effectivePlatform = isWebView ? "web" : args.platform;
|
|
32
|
+
const searchAttribute = args.ffNumber
|
|
33
|
+
? (effectivePlatform === "web"
|
|
34
|
+
? `[ff-inspect="${args.ffNumber}"]`
|
|
35
|
+
: `[FF-inspecter="${args.ffNumber}"]`)
|
|
36
|
+
: args.selector;
|
|
10
37
|
const data = {
|
|
11
38
|
nlpName: args.nlpName
|
|
12
39
|
};
|
|
@@ -19,9 +46,12 @@ async function appendScriptData(args) {
|
|
|
19
46
|
if (args.elementName) {
|
|
20
47
|
let locators;
|
|
21
48
|
try {
|
|
22
|
-
|
|
49
|
+
if (!searchAttribute) {
|
|
50
|
+
throw new Error("searchAttribute is not found");
|
|
51
|
+
}
|
|
52
|
+
const ffElement = await args.elementGetter.getFireFlinkElement(args.pageDOM, searchAttribute, effectivePlatform);
|
|
23
53
|
// locators = [{ name: "xpath", value: args.selector }];
|
|
24
|
-
if (ffElement?.locators
|
|
54
|
+
if (!ffElement?.locators || ffElement.locators.length === 0) {
|
|
25
55
|
throw new Error("locators is not found");
|
|
26
56
|
}
|
|
27
57
|
else {
|
|
@@ -30,7 +60,13 @@ async function appendScriptData(args) {
|
|
|
30
60
|
}
|
|
31
61
|
catch (error) {
|
|
32
62
|
logData_js_1.logger.info(`Element is not found ${error.message}`);
|
|
33
|
-
locators = [{
|
|
63
|
+
locators = [{
|
|
64
|
+
name: "xpath",
|
|
65
|
+
type: "static",
|
|
66
|
+
value: args.selector,
|
|
67
|
+
isRecorded: "N",
|
|
68
|
+
isAiRecorded: "Y"
|
|
69
|
+
}];
|
|
34
70
|
}
|
|
35
71
|
data.elementsData = [{
|
|
36
72
|
name: args.elementName,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { NodeItem } from "./screenshotInterface.js";
|
|
2
|
-
export declare function annotateScreenshot(screenshotBase64: string, nodes: NodeItem[]): Promise<Buffer>;
|
|
2
|
+
export declare function annotateScreenshot(screenshotBase64: string, deviceWidth: number, deviceHeight: number, nodes: NodeItem[]): Promise<Buffer>;
|
|
@@ -59,10 +59,16 @@ function findFreeTagPosition(box, tagW, tagH, elementBoxes, usedTagRects, imgWid
|
|
|
59
59
|
usedTagRects.push([fallbackX, fallbackY, fallbackX + tagW, fallbackY + tagH]);
|
|
60
60
|
return { x: fallbackX, y: fallbackY };
|
|
61
61
|
}
|
|
62
|
-
async function annotateScreenshot(screenshotBase64, nodes) {
|
|
62
|
+
async function annotateScreenshot(screenshotBase64, deviceWidth, deviceHeight, nodes) {
|
|
63
63
|
const buffer = Buffer.from(screenshotBase64, "base64");
|
|
64
64
|
const image = await (0, canvas_1.loadImage)(buffer);
|
|
65
|
-
|
|
65
|
+
// Actual screenshot resolution
|
|
66
|
+
const screenshotWidth = image.width;
|
|
67
|
+
const screenshotHeight = image.height;
|
|
68
|
+
// Device / WebView resolution from which bbox coordinates are coming
|
|
69
|
+
const scaleX = screenshotWidth / deviceWidth;
|
|
70
|
+
const scaleY = screenshotHeight / deviceHeight;
|
|
71
|
+
const scale = Math.min(scaleX, scaleY);
|
|
66
72
|
const fontSize = Math.max(16, Math.floor(20 * scale));
|
|
67
73
|
const canvas = (0, canvas_1.createCanvas)(image.width, image.height);
|
|
68
74
|
const ctx = canvas.getContext("2d");
|
|
@@ -71,20 +77,28 @@ async function annotateScreenshot(screenshotBase64, nodes) {
|
|
|
71
77
|
ctx.textBaseline = "middle";
|
|
72
78
|
ctx.textAlign = "center";
|
|
73
79
|
const usedTagRects = [];
|
|
80
|
+
/*
|
|
81
|
+
* Convert all bounding boxes from device/WebView
|
|
82
|
+
* coordinates to screenshot coordinates.
|
|
83
|
+
*/
|
|
74
84
|
const elementBoxes = nodes.map((n) => [
|
|
75
|
-
Math.floor(n.bbox.x),
|
|
76
|
-
Math.floor(n.bbox.y),
|
|
77
|
-
Math.floor(n.bbox.x + n.bbox.w),
|
|
78
|
-
Math.floor(n.bbox.y + n.bbox.h),
|
|
85
|
+
Math.floor(n.bbox.x * scaleX),
|
|
86
|
+
Math.floor(n.bbox.y * scaleY),
|
|
87
|
+
Math.floor((n.bbox.x + n.bbox.w) * scaleX),
|
|
88
|
+
Math.floor((n.bbox.y + n.bbox.h) * scaleY),
|
|
79
89
|
]);
|
|
80
90
|
nodes.forEach((item, i) => {
|
|
81
91
|
const color = COLORS[i % COLORS.length];
|
|
82
92
|
const colorStr = `rgb(${color[0]},${color[1]},${color[2]})`;
|
|
83
93
|
const label = item.ff.split("-").pop() || "";
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
94
|
+
/*
|
|
95
|
+
* Convert current node bbox to actual
|
|
96
|
+
* screenshot coordinates.
|
|
97
|
+
*/
|
|
98
|
+
const x1 = Math.floor(item.bbox.x * scaleX);
|
|
99
|
+
const y1 = Math.floor(item.bbox.y * scaleY);
|
|
100
|
+
const x2 = Math.floor((item.bbox.x + item.bbox.w) * scaleX);
|
|
101
|
+
const y2 = Math.floor((item.bbox.y + item.bbox.h) * scaleY);
|
|
88
102
|
ctx.strokeStyle = colorStr;
|
|
89
103
|
ctx.lineWidth = Math.max(2, Math.floor(2 * scale));
|
|
90
104
|
ctx.strokeRect(x1, y1, x2 - x1, y2 - y1);
|
|
@@ -14,13 +14,16 @@ async function generateAnnotatedScreenshots(driver) {
|
|
|
14
14
|
// driver.execute(JS_PRIMARY),
|
|
15
15
|
// // driver.execute(JS_SECONDARY),
|
|
16
16
|
// ]);
|
|
17
|
+
const windowSize = await driver.getWindowSize();
|
|
18
|
+
const deviceWidth = windowSize.width;
|
|
19
|
+
const deviceHeight = windowSize.height;
|
|
17
20
|
const primary = primaryRaw ?? [];
|
|
18
21
|
let secondary = secondaryRaw ?? [];
|
|
19
22
|
const primaryIds = new Set(primary.map((item) => item.ff));
|
|
20
23
|
secondary = secondary.filter((item) => !primaryIds.has(item.ff));
|
|
21
24
|
const [primaryAnnotated, secondaryAnnotated] = await Promise.all([
|
|
22
|
-
(0, annotateScreenshot_js_1.annotateScreenshot)(screenshot, primary),
|
|
23
|
-
(0, annotateScreenshot_js_1.annotateScreenshot)(screenshot, secondary)
|
|
25
|
+
(0, annotateScreenshot_js_1.annotateScreenshot)(screenshot, deviceWidth, deviceHeight, primary),
|
|
26
|
+
(0, annotateScreenshot_js_1.annotateScreenshot)(screenshot, deviceWidth, deviceHeight, secondary)
|
|
24
27
|
]);
|
|
25
28
|
// Uncomment only when debugging
|
|
26
29
|
logData_js_1.logger.saveImage(primaryAnnotated, "annotated_primary.png");
|
|
File without changes
|