ff-automationv2 2.1.3 → 2.2.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/.env +1 -0
- package/.husky/pre-commit +5 -0
- package/ARCHITECTURE.md +6 -3
- package/Note.md +7 -0
- package/RELEASE_GUIDE.md +1 -1
- package/bitbucket-pipelines.yml +4 -25
- package/eslint.config.ts +4 -0
- package/package.json +21 -9
- package/src/ai/llmcalls/decodeApiKey.ts +1 -1
- package/src/ai/llmcalls/llmAction.ts +154 -47
- package/src/ai/llmprompts/llmPromptTypes/systemPromptTypes.ts +45 -0
- package/src/ai/llmprompts/promptRegistry.ts +34 -8
- package/src/ai/llmprompts/systemPrompts/actionExtractorPrompt.ts +4 -7
- package/src/ai/llmprompts/systemPrompts/combinedActionExtractorPrompt.ts +41 -0
- package/src/ai/llmprompts/systemPrompts/combinedActionExtractorPromptMob.ts +53 -0
- package/src/ai/llmprompts/systemPrompts/errorDescriptionPrompt.ts +43 -14
- package/src/ai/llmprompts/systemPrompts/fireflinkElementIndexExtactors.ts +111 -36
- package/src/ai/llmprompts/systemPrompts/fireflinkElementIndexExtractor_Mob.ts +53 -0
- package/src/ai/llmprompts/systemPrompts/getActionExtractorPrompt.ts +62 -0
- package/src/ai/llmprompts/systemPrompts/getActionExtractorPromptMob.ts +54 -0
- package/src/ai/llmprompts/systemPrompts/mobileKeywordExtractor.ts +39 -0
- package/src/ai/llmprompts/systemPrompts/userStoryToListPrompt.ts +48 -11
- package/src/ai/llmprompts/systemPrompts/verifyActionExtractorPrompt.ts +82 -0
- package/src/ai/llmprompts/systemPrompts/verifyActionExtractorPromptMob.ts +58 -0
- package/src/ai/llmprompts/systemPrompts/visionPrompt.ts +8 -14
- package/src/ai/llmprompts/systemPrompts/visionPromptMobile.ts +25 -0
- package/src/ai/llmprompts/systemPrompts/waitActionExtractorPrompt.ts +65 -0
- package/src/ai/llmprompts/systemPrompts/waitActionExtractorPromptMob.ts +45 -0
- package/src/ai/llmprompts/userPrompts/userPrompt.ts +28 -4
- package/src/automation/actions/executor.ts +4478 -48
- package/src/automation/actions/interaction/alert/clickCancelOnAlertPopup.ts +21 -0
- package/src/automation/actions/interaction/alert/clickOkOnAlertPopup.ts +20 -0
- package/src/automation/actions/interaction/alert/enterDataToAlert.ts +20 -0
- package/src/automation/actions/interaction/alert/getTextPresentOnAlertPopup.ts +19 -0
- package/src/automation/actions/interaction/alert/verifyAlertPopUpMessageContainsString.ts +32 -0
- package/src/automation/actions/interaction/alert/verifyAlertPopupIsDisplayed.ts +19 -0
- package/src/automation/actions/interaction/alert/verifyTextPresentOnAlertPopup.ts +33 -0
- package/src/automation/actions/interaction/alert/waitTillAlertIsPresent.ts +25 -0
- package/src/automation/actions/interaction/clear/clear.ts +61 -0
- package/src/automation/actions/interaction/clear/clearAndEnter.ts +58 -0
- package/src/automation/actions/interaction/click/click.ts +61 -0
- package/src/automation/actions/interaction/click/clickNtimes.ts +67 -0
- package/src/automation/actions/interaction/click/clickUsingJs.ts +33 -0
- package/src/automation/actions/interaction/click/doubleClick.ts +66 -0
- package/src/automation/actions/interaction/click/rightClick.ts +29 -0
- package/src/automation/actions/interaction/click/waitAndClick.ts +83 -0
- package/src/automation/actions/interaction/dragAndDrop/dragAndDrop.ts +46 -0
- package/src/automation/actions/interaction/enterActions/enterInput.ts +81 -0
- package/src/automation/actions/interaction/enterActions/enterInputAndPress.ts +134 -0
- package/src/automation/actions/interaction/enterActions/enterUrl.ts +52 -0
- package/src/automation/actions/interaction/enterActions/enterusingJs.ts +41 -0
- package/src/automation/actions/interaction/enterActions/waitAndEnter.ts +106 -0
- package/src/automation/actions/interaction/find/findElements.ts +57 -0
- package/src/automation/actions/interaction/get/browserWindowGetPosition.ts +15 -0
- package/src/automation/actions/interaction/get/getAllBrokenImages.ts +16 -0
- package/src/automation/actions/interaction/get/getAllBrokenLinkCount.ts +17 -0
- package/src/automation/actions/interaction/get/getAllBrokenLinks.ts +16 -0
- package/src/automation/actions/interaction/get/getAllConsoleErrors.ts +16 -0
- package/src/automation/actions/interaction/get/getAllConsoleInformation.ts +16 -0
- package/src/automation/actions/interaction/get/getAllConsoleLogs.ts +16 -0
- package/src/automation/actions/interaction/get/getAllConsoleWarnings.ts +18 -0
- package/src/automation/actions/interaction/get/getAllCookieNames.ts +16 -0
- package/src/automation/actions/interaction/get/getAllCookieValues.ts +16 -0
- package/src/automation/actions/interaction/get/getAllSelectedOptions.ts +43 -0
- package/src/automation/actions/interaction/get/getAllTheOptionsFromListBoxAsText.ts +46 -0
- package/src/automation/actions/interaction/get/getAllTheOptionsFromListBoxAsTextInSortedOrder.ts +54 -0
- package/src/automation/actions/interaction/get/getAllTheSelectedOptionsFromListBoxAsText.ts +43 -0
- package/src/automation/actions/interaction/get/getAllWindowHandles.ts +18 -0
- package/src/automation/actions/interaction/get/getAttribute.ts +83 -0
- package/src/automation/actions/interaction/get/getAudioCurrentPlaybackRate.ts +35 -0
- package/src/automation/actions/interaction/get/getAudioCurrentSeekTime.ts +36 -0
- package/src/automation/actions/interaction/get/getAudioCurrentVolume.ts +36 -0
- package/src/automation/actions/interaction/get/getAudioDecodedByte.ts +43 -0
- package/src/automation/actions/interaction/get/getAudioDefaultPlaybackRate.ts +36 -0
- package/src/automation/actions/interaction/get/getAudioDimension.ts +43 -0
- package/src/automation/actions/interaction/get/getAudioHeight.ts +38 -0
- package/src/automation/actions/interaction/get/getAudioMediaLength.ts +34 -0
- package/src/automation/actions/interaction/get/getAudioMediaSource.ts +44 -0
- package/src/automation/actions/interaction/get/getAudioWidth.ts +38 -0
- package/src/automation/actions/interaction/get/getBestPracticesScore.ts +20 -0
- package/src/automation/actions/interaction/get/getBrowserCount.ts +17 -0
- package/src/automation/actions/interaction/get/getBrowserVersion.ts +16 -0
- package/src/automation/actions/interaction/get/getCapabilityNames.ts +18 -0
- package/src/automation/actions/interaction/get/getClipBoardText.ts +16 -0
- package/src/automation/actions/interaction/get/getCollectiveApiResponseTime.ts +27 -0
- package/src/automation/actions/interaction/get/getCollectiveApiStatusCode.ts +29 -0
- package/src/automation/actions/interaction/get/getCssValue.ts +38 -0
- package/src/automation/actions/interaction/get/getCurrentDayOfTheWeek.ts +18 -0
- package/src/automation/actions/interaction/get/getCurrentSecondsFromCurrentSystemTime.ts +19 -0
- package/src/automation/actions/interaction/get/getCurrentSystemDate.ts +18 -0
- package/src/automation/actions/interaction/get/getCurrentSystemDay.ts +16 -0
- package/src/automation/actions/interaction/get/getCurrentSystemMonth.ts +16 -0
- package/src/automation/actions/interaction/get/getCurrentSystemTime.ts +18 -0
- package/src/automation/actions/interaction/get/getCurrentSystemYear.ts +18 -0
- package/src/automation/actions/interaction/get/getCurrentWindowHandle.ts +36 -0
- package/src/automation/actions/interaction/get/getDataFromApiRequestHeaderForJsonPath.ts +21 -0
- package/src/automation/actions/interaction/get/getDataFromApiResponseForJsonPath.ts +21 -0
- package/src/automation/actions/interaction/get/getDateWithGivenFormat.ts +35 -0
- package/src/automation/actions/interaction/get/getDriverInstance.ts +35 -0
- package/src/automation/actions/interaction/get/getFirstContentfulPaint.ts +16 -0
- package/src/automation/actions/interaction/get/getFirstSelectedOption.ts +44 -0
- package/src/automation/actions/interaction/get/getFullPaintTime.ts +16 -0
- package/src/automation/actions/interaction/get/getHTMLCodeOfPage.ts +18 -0
- package/src/automation/actions/interaction/get/getHeightOfBrowserWindow.ts +18 -0
- package/src/automation/actions/interaction/get/getHeightOfWebElement.ts +36 -0
- package/src/automation/actions/interaction/get/getHourFromCurrentSystemTime.ts +18 -0
- package/src/automation/actions/interaction/get/getImplicitTimeOut.ts +36 -0
- package/src/automation/actions/interaction/get/getLargestContentfulPaint.ts +16 -0
- package/src/automation/actions/interaction/get/getListBoxSize.ts +41 -0
- package/src/automation/actions/interaction/get/getListOfElementsFromLocatorTypeLocatorValue.ts +63 -0
- package/src/automation/actions/interaction/get/getLocation.ts +68 -0
- package/src/automation/actions/interaction/get/getMinuteFromCurrentSystemTime.ts +18 -0
- package/src/automation/actions/interaction/get/getNetworkRouteTime.ts +16 -0
- package/src/automation/actions/interaction/get/getNumberOfBrokenImages.ts +16 -0
- package/src/automation/actions/interaction/get/getNumberOfLinksPresentInCurrentPage.ts +18 -0
- package/src/automation/actions/interaction/get/getNumberOfWorkingLinksFromCurrentPage.ts +15 -0
- package/src/automation/actions/interaction/get/getOptions.ts +35 -0
- package/src/automation/actions/interaction/get/getPageTitle.ts +18 -0
- package/src/automation/actions/interaction/get/getPerformanceMetrics.ts +15 -0
- package/src/automation/actions/interaction/get/getPwaScore.ts +20 -0
- package/src/automation/actions/interaction/get/getRect.ts +87 -0
- package/src/automation/actions/interaction/get/getScreenshot.ts +41 -0
- package/src/automation/actions/interaction/get/getScreenshotAs.ts +64 -0
- package/src/automation/actions/interaction/get/getSeoScore.ts +20 -0
- package/src/automation/actions/interaction/get/getSingleApiRequestPayload.ts +22 -0
- package/src/automation/actions/interaction/get/getSingleApiResponse.ts +30 -0
- package/src/automation/actions/interaction/get/getSingleApiResponseTime.ts +28 -0
- package/src/automation/actions/interaction/get/getSingleApiStatusCode.ts +32 -0
- package/src/automation/actions/interaction/get/getSize.ts +68 -0
- package/src/automation/actions/interaction/get/getSizeOfBrowserWindow.ts +17 -0
- package/src/automation/actions/interaction/get/getStringDataFromLocalFile.ts +25 -0
- package/src/automation/actions/interaction/get/getSystemProperty.ts +46 -0
- package/src/automation/actions/interaction/get/getTagName.ts +67 -0
- package/src/automation/actions/interaction/get/getText.ts +68 -0
- package/src/automation/actions/interaction/get/getTheFirstSelectedOptionFromListBoxAsText.ts +44 -0
- package/src/automation/actions/interaction/get/getTotalNumberOfCookies.ts +16 -0
- package/src/automation/actions/interaction/get/getTunnelIdentifier.ts +25 -0
- package/src/automation/actions/interaction/get/getURLPresentInAddressBar.ts +18 -0
- package/src/automation/actions/interaction/get/getUserHomeDirectory.ts +16 -0
- package/src/automation/actions/interaction/get/getValueByCookieName.ts +27 -0
- package/src/automation/actions/interaction/get/getValueFromLocalStorage.ts +26 -0
- package/src/automation/actions/interaction/get/getValueOfSystemVariable.ts +20 -0
- package/src/automation/actions/interaction/get/getVideoCurrentPlaybackRate.ts +36 -0
- package/src/automation/actions/interaction/get/getVideoCurrentSeekTime.ts +36 -0
- package/src/automation/actions/interaction/get/getVideoCurrentVolume.ts +36 -0
- package/src/automation/actions/interaction/get/getVideoDecodedByte.ts +52 -0
- package/src/automation/actions/interaction/get/getVideoDefaultPlaybackRate.ts +36 -0
- package/src/automation/actions/interaction/get/getVideoDimension.ts +40 -0
- package/src/automation/actions/interaction/get/getVideoHeight.ts +36 -0
- package/src/automation/actions/interaction/get/getVideoMediaLength.ts +36 -0
- package/src/automation/actions/interaction/get/getVideoMediaSource.ts +46 -0
- package/src/automation/actions/interaction/get/getVideoWidth.ts +36 -0
- package/src/automation/actions/interaction/get/getWidthOfBrowser.ts +18 -0
- package/src/automation/actions/interaction/get/getWidthOfWebElement.ts +36 -0
- package/src/automation/actions/interaction/get/getWorkingLinksFromCurrentPage.ts +16 -0
- package/src/automation/actions/interaction/get/getWrappedElement.ts +36 -0
- package/src/automation/actions/interaction/get/getWrappedOptionFromListBoxAsText.ts +47 -0
- package/src/automation/actions/interaction/get/getXLocationOfBrowserWindow.ts +18 -0
- package/src/automation/actions/interaction/get/getXLocationOfWebElement.ts +71 -0
- package/src/automation/actions/interaction/get/getYLocationOfBrowserWindow.ts +18 -0
- package/src/automation/actions/interaction/get/getYLocationOfWebElement.ts +70 -0
- package/src/automation/actions/interaction/iframe/switchToDefaultContent.ts +15 -0
- package/src/automation/actions/interaction/maximize/maximize.ts +15 -0
- package/src/automation/actions/interaction/maximize/minimize.ts +17 -0
- package/src/automation/actions/interaction/navigation/goBack.ts +14 -0
- package/src/automation/actions/interaction/navigation/navigate.ts +16 -0
- package/src/automation/actions/interaction/navigation/refresh.ts +14 -0
- package/src/automation/actions/interaction/press/mobPressBackKey.ts +19 -0
- package/src/automation/actions/interaction/press/pressAnyKey.ts +89 -0
- package/src/automation/actions/interaction/press/pressAnyKeyNTimes.ts +100 -0
- package/src/automation/actions/interaction/press/pressEnterKey.ts +45 -0
- package/src/automation/actions/interaction/scroll/scrollHorizontallyTillElementIsVisible.ts +29 -0
- package/src/automation/actions/interaction/scroll/scrollPageToSpecificLocation.ts +37 -0
- package/src/automation/actions/interaction/scroll/scrollToElement.ts +28 -0
- package/src/automation/actions/interaction/scroll/scrollVerticallyTillElementIsVisible.ts +29 -0
- package/src/automation/actions/interaction/set/setClipBoardText.ts +46 -0
- package/src/automation/actions/interaction/shadowDom/shadowDomClick.ts +25 -0
- package/src/automation/actions/interaction/shadowDom/shadowDomEnter.ts +27 -0
- package/src/automation/actions/interaction/shadowDom/shadowDomGetText.ts +28 -0
- package/src/automation/actions/interaction/shadowDom/shadowDomUpload.ts +37 -0
- package/src/automation/actions/interaction/shadowDom/shadowDomVerifyPartialText.ts +29 -0
- package/src/automation/actions/interaction/shadowDom/shadowDomVerifyText.ts +22 -0
- package/src/automation/actions/interaction/switch/switchToNewTabBasedOnTitle.ts +16 -0
- package/src/automation/actions/interaction/switch/switchToNewWindowBasedOnTitle.ts +16 -0
- package/src/automation/actions/interaction/switch/switchToParentWindow.ts +19 -0
- package/src/automation/actions/interaction/switch/switchToTabBasedOnUrl.ts +16 -0
- package/src/automation/actions/interaction/switch/switchToWindowBasedOnURL.ts +16 -0
- package/src/automation/actions/interaction/switch/switchToWindowIfTitleContainsString.ts +18 -0
- package/src/automation/actions/interaction/switch/switchToWindowIfUrlContainsString.ts +18 -0
- package/src/automation/actions/interaction/upload/uploadfile.ts +41 -0
- package/src/automation/actions/interaction/verify/VerifyAccessibilityScore.ts +90 -0
- package/src/automation/actions/interaction/verify/VerifyAllBrokenImages.ts +54 -0
- package/src/automation/actions/interaction/verify/VerifyAllBrowserWindowsClosed.ts +27 -0
- package/src/automation/actions/interaction/verify/VerifyAllOptionsAreDeSelected.ts +55 -0
- package/src/automation/actions/interaction/verify/VerifyAllOptionsAreSelected.ts +66 -0
- package/src/automation/actions/interaction/verify/VerifyAttributeValue.ts +96 -0
- package/src/automation/actions/interaction/verify/VerifyBestPracticesScore.ts +87 -0
- package/src/automation/actions/interaction/verify/VerifyBrowserHtmlCodeContainsString.ts +35 -0
- package/src/automation/actions/interaction/verify/VerifyBrowserWindowHeight.ts +35 -0
- package/src/automation/actions/interaction/verify/VerifyBrowserWindowTitleContainsString.ts +31 -0
- package/src/automation/actions/interaction/verify/VerifyBrowserWindowTitleIsString.ts +30 -0
- package/src/automation/actions/interaction/verify/VerifyBrowserWindowUrlContainsExpectedUrl.ts +30 -0
- package/src/automation/actions/interaction/verify/VerifyBrowserWindowUrlIsString.ts +30 -0
- package/src/automation/actions/interaction/verify/VerifyBrowserWindowWidth.ts +35 -0
- package/src/automation/actions/interaction/verify/VerifyBrowserWindowXLocation.ts +36 -0
- package/src/automation/actions/interaction/verify/VerifyBrowserWindowYLocation.ts +35 -0
- package/src/automation/actions/interaction/verify/VerifyCheckBoxIsNotSelected.ts +46 -0
- package/src/automation/actions/interaction/verify/VerifyCheckBoxIsSelected.ts +43 -0
- package/src/automation/actions/interaction/verify/VerifyCssAttributeValue.ts +62 -0
- package/src/automation/actions/interaction/verify/VerifyElementIsClickable.ts +86 -0
- package/src/automation/actions/interaction/verify/VerifyElementIsDisabled.ts +91 -0
- package/src/automation/actions/interaction/verify/VerifyElementIsDisplayed.ts +87 -0
- package/src/automation/actions/interaction/verify/VerifyElementIsEnabled.ts +87 -0
- package/src/automation/actions/interaction/verify/VerifyElementIsNotDisplayed.ts +45 -0
- package/src/automation/actions/interaction/verify/VerifyElementIsSelected.ts +83 -0
- package/src/automation/actions/interaction/verify/VerifyElementNotContainsText.ts +129 -0
- package/src/automation/actions/interaction/verify/VerifyHeightOfWebElement.ts +101 -0
- package/src/automation/actions/interaction/verify/VerifyHexCodeForGivenXYCoordinates.ts +51 -0
- package/src/automation/actions/interaction/verify/VerifyIfAllCookiesAreDeleted.ts +27 -0
- package/src/automation/actions/interaction/verify/VerifyIfAudioEnded.ts +48 -0
- package/src/automation/actions/interaction/verify/VerifyIfAudioIsMuted.ts +48 -0
- package/src/automation/actions/interaction/verify/VerifyIfAudioIsPaused.ts +48 -0
- package/src/automation/actions/interaction/verify/VerifyIfAudioIsPlaying.ts +57 -0
- package/src/automation/actions/interaction/verify/VerifyIfBrowserWindowIsClosed.ts +27 -0
- package/src/automation/actions/interaction/verify/VerifyIfCookieNameIsAdded.ts +38 -0
- package/src/automation/actions/interaction/verify/VerifyIfCookieNameIsDeleted.ts +33 -0
- package/src/automation/actions/interaction/verify/VerifyIfCookieObjectIsPresent.ts +49 -0
- package/src/automation/actions/interaction/verify/VerifyIfGivenOptionIsDuplicate.ts +60 -0
- package/src/automation/actions/interaction/verify/VerifyIfImageIsBroken.ts +40 -0
- package/src/automation/actions/interaction/verify/VerifyIfLinkIsBroken.ts +38 -0
- package/src/automation/actions/interaction/verify/VerifyIfLinkIsWorking.ts +37 -0
- package/src/automation/actions/interaction/verify/VerifyIfLinksAreBroken.ts +46 -0
- package/src/automation/actions/interaction/verify/VerifyIfLinksAreWorking.ts +45 -0
- package/src/automation/actions/interaction/verify/VerifyIfOptionWithIndexIsDeselectedInElement.ts +75 -0
- package/src/automation/actions/interaction/verify/VerifyIfOptionWithIndexIsSelectedInListBox.ts +77 -0
- package/src/automation/actions/interaction/verify/VerifyIfOptionWithTextIsDeselected.ts +40 -0
- package/src/automation/actions/interaction/verify/VerifyIfOptionWithValueIsDeselected.ts +61 -0
- package/src/automation/actions/interaction/verify/VerifyIfOptionWithValueIsSelected.ts +58 -0
- package/src/automation/actions/interaction/verify/VerifyIfOptionWithVisibleTextIsSelected.ts +40 -0
- package/src/automation/actions/interaction/verify/VerifyIfSpecifiedOptionIsSelected.ts +78 -0
- package/src/automation/actions/interaction/verify/VerifyIfStatusCodeOfALinkIsStatusCode.ts +37 -0
- package/src/automation/actions/interaction/verify/VerifyIfStatusCodesOfLinks.ts +46 -0
- package/src/automation/actions/interaction/verify/VerifyIfVideoEnded.ts +49 -0
- package/src/automation/actions/interaction/verify/VerifyIfVideoIsMuted.ts +49 -0
- package/src/automation/actions/interaction/verify/VerifyIfVideoIsPaused.ts +49 -0
- package/src/automation/actions/interaction/verify/VerifyIfVideoIsPlaying.ts +50 -0
- package/src/automation/actions/interaction/verify/VerifyIfVideoPlayingInMute.ts +58 -0
- package/src/automation/actions/interaction/verify/VerifyIfVideoPlayingInUnmute.ts +58 -0
- package/src/automation/actions/interaction/verify/VerifyIfXAndYCoordinateOfElement.ts +101 -0
- package/src/automation/actions/interaction/verify/VerifyLinkNavigatesToTitle.ts +41 -0
- package/src/automation/actions/interaction/verify/VerifyListBoxOptionsAreSorted.ts +72 -0
- package/src/automation/actions/interaction/verify/VerifyNavigateURL.ts +34 -0
- package/src/automation/actions/interaction/verify/VerifyNumberOfElementsByTagName.ts +35 -0
- package/src/automation/actions/interaction/verify/VerifyNumberOfElementsByXpath.ts +52 -0
- package/src/automation/actions/interaction/verify/VerifyPartialAttributeValue.ts +94 -0
- package/src/automation/actions/interaction/verify/VerifyPartialTitleOfCurrentPage.ts +29 -0
- package/src/automation/actions/interaction/verify/VerifyPerformanceScore.ts +84 -0
- package/src/automation/actions/interaction/verify/VerifyPwaScore.ts +66 -0
- package/src/automation/actions/interaction/verify/VerifyRadioButtonIsNotSelected.ts +42 -0
- package/src/automation/actions/interaction/verify/VerifyRadioButtonIsSelected.ts +42 -0
- package/src/automation/actions/interaction/verify/VerifySeoScore.ts +79 -0
- package/src/automation/actions/interaction/verify/VerifyTagName.ts +44 -0
- package/src/automation/actions/interaction/verify/VerifyThatSpecifiedOptionIsNotSelected.ts +73 -0
- package/src/automation/actions/interaction/verify/VerifyTitleInAllPage.ts +51 -0
- package/src/automation/actions/interaction/verify/VerifyTitleOfCurrentPage.ts +30 -0
- package/src/automation/actions/interaction/verify/VerifyValueOfElementContainsString.ts +51 -0
- package/src/automation/actions/interaction/verify/VerifyValueOfElementIsCleared.ts +45 -0
- package/src/automation/actions/interaction/verify/VerifyValueOfElementIsString.ts +54 -0
- package/src/automation/actions/interaction/verify/VerifyWidthOfElement.ts +90 -0
- package/src/automation/actions/interaction/verify/VerifyXLocationOfElement.ts +89 -0
- package/src/automation/actions/interaction/verify/VerifyYLocationOfElement.ts +90 -0
- package/src/automation/actions/interaction/verify/checkIfElementIsDisplayed.ts +83 -0
- package/src/automation/actions/interaction/verify/verifypartialtext.ts +131 -0
- package/src/automation/actions/interaction/verify/verifytext.ts +143 -0
- package/src/automation/actions/interaction/wait/wait.ts +16 -0
- package/src/automation/actions/interaction/wait/waitTillAttributeOfElementIsString.ts +88 -0
- package/src/automation/actions/interaction/wait/waitTillElementContainsText.ts +79 -0
- package/src/automation/actions/interaction/wait/waitTillElementHasText.ts +71 -0
- package/src/automation/actions/interaction/wait/waitTillElementIsClickable.ts +72 -0
- package/src/automation/actions/interaction/wait/waitTillPresenceOfAllElements.ts +72 -0
- package/src/automation/actions/interaction/wait/waitTillPresenceOfElement.ts +67 -0
- package/src/automation/actions/interface/IframeInterface.ts +6 -0
- package/src/automation/actions/interface/alertActionInterface.ts +39 -0
- package/src/automation/actions/interface/clearActionInterface.ts +27 -0
- package/src/automation/actions/interface/clickActionInterface.ts +87 -0
- package/src/automation/actions/interface/dragAndDropToElementInterface.ts +18 -0
- package/src/automation/actions/interface/findActionInterface.ts +15 -0
- package/src/automation/actions/interface/getActionInterface.ts +873 -0
- package/src/automation/actions/interface/interactionActionInterface.ts +51 -3
- package/src/automation/actions/interface/maximizeAndMinimizeInterface.ts +12 -0
- package/src/automation/actions/interface/navigationActionInterface.ts +1 -1
- package/src/automation/actions/interface/pressActionInterface.ts +25 -0
- package/src/automation/actions/interface/scrollActionInterface.ts +45 -0
- package/src/automation/actions/interface/setActionInterface.ts +10 -0
- package/src/automation/actions/interface/shadowDomInterface.ts +78 -0
- package/src/automation/actions/interface/switchingActionInterface.ts +93 -0
- package/src/automation/actions/interface/uploadFile.ts +14 -0
- package/src/automation/actions/interface/verifyActionInterface.ts +743 -0
- package/src/automation/actions/interface/waitActionInterface.ts +75 -0
- package/src/automation/browserSession/initiateBrowserSession.ts +12 -40
- package/src/automation/mobileSession/initiateMobileSession.ts +81 -0
- package/src/core/constants/allAction.ts +21 -0
- package/src/core/constants/defaultValues.ts +1 -0
- package/src/core/constants/supportedActions.ts +27 -2
- package/src/core/interfaces/actionInterface.ts +238 -3
- package/src/core/interfaces/automationRunnerInterface.ts +2 -1
- package/src/core/interfaces/browserCapabilitiesInterface.ts +1 -3
- package/src/core/interfaces/errorInfoInterface.ts +7 -0
- package/src/core/interfaces/executionDetails.ts +10 -6
- package/src/core/interfaces/fireflinkScriptPayloadInterface.ts +17 -5
- package/src/core/interfaces/llmResponseInterface.ts +28 -4
- package/src/core/interfaces/promptInterface.ts +20 -0
- package/src/core/interfaces/scriptGenrationDataInterface.ts +2 -2
- package/src/core/interfaces/simplifyAndFlattenInterface.ts +13 -0
- package/src/core/main/actionHandlerFactory.ts +1528 -53
- package/src/core/main/executionContext.ts +5 -1
- package/src/core/main/runAutomationScript.ts +528 -123
- package/src/core/main/stepProcessor.ts +4 -2
- package/src/core/types/llmResponseType.ts +7 -3
- package/src/core/types/promptMap.ts +7 -4
- package/src/core/types/promptType.ts +6 -0
- package/src/core/types/scriptTypesType.ts +1 -0
- package/src/domAnalysis/getRelaventElements.ts +10 -1
- package/src/domAnalysis/relativeElementsFromDom.ts +205 -0
- package/src/domAnalysis/searchBest.ts +130 -17
- package/src/domAnalysis/simplifyAndFlatten.ts +139 -10
- package/src/fireflinkData/fireflinkLocators/getListOfLocators.ts +1 -2
- package/src/fireflinkData/fireflinkScript/scriptGenrationData.ts +70 -21
- package/src/imageAnalysisMobile/annotatedScreenshotMobile.ts +137 -0
- package/src/imageAnalysisMobile/annotatedScreenshotMobileInterface.ts +6 -0
- package/src/imageAnalysisWeb/annotateScreenshot.ts +196 -0
- package/src/imageAnalysisWeb/generateAnnotatedScreenshots.ts +43 -0
- package/src/imageAnalysisWeb/screenshotInterface.ts +18 -0
- package/src/index.ts +2 -2
- package/src/service/{fireflinkApi.service.ts → api/fireflinkApi.service.ts} +5 -7
- package/src/service/kafka/fireflinkKafka.service.ts +25 -0
- package/src/service/scriptRunner.service.ts +23 -42
- package/src/utils/DomExtraction/jsForAttributeInjection.ts +68 -12
- package/src/utils/InstancesDetails/getInstancesInfo.ts +12 -0
- package/src/utils/alertPopup/isAlertPresent.ts +20 -0
- package/src/utils/alertPopup/isAlertPresentInterface.ts +6 -0
- package/src/utils/helpers/enterActionHelper.ts +88 -2
- package/src/utils/helpers/imageUtils.ts +10 -0
- package/src/utils/helpers/sameActionsHelper.ts +52 -0
- package/src/utils/helpers/xpathcreation.ts +59 -0
- package/src/utils/iframesExtraction/findElementUsingFF.ts +45 -0
- package/src/utils/iframesExtraction/iframeInterface.ts +22 -0
- package/src/utils/iframesExtraction/switchToIframeByMeta.ts +23 -0
- package/src/utils/javascript/jsFindElement.ts +39 -31
- package/src/utils/javascript/jsForShadowRoot.ts +9 -9
- package/src/utils/javascript/jsForVision.ts +151 -0
- package/src/utils/logger/logData.ts +126 -47
- package/src/utils/mobileXpath/findXpathFromIndex.ts +87 -0
- package/src/utils/mobileXpath/findXpathFromIndexInterface.ts +4 -0
- package/src/utils/newTab/newTabTracker.ts +62 -0
- package/src/automation/actions/interaction/click.ts +0 -25
- package/src/automation/actions/interaction/enterInput.ts +0 -36
- package/src/automation/actions/navigation/getTitle.ts +0 -9
- package/src/automation/actions/navigation/goBack.ts +0 -9
- package/src/automation/actions/navigation/navigate.ts +0 -10
- package/src/automation/actions/navigation/refresh.ts +0 -9
- package/src/automation/actions/wait/wait.ts +0 -10
|
@@ -2,8 +2,10 @@ import { llmAction } from "../../ai/llmcalls/llmAction.js";
|
|
|
2
2
|
import { LLMResultParser } from "../../ai/llmcalls/parseLlmOputput.js";
|
|
3
3
|
import { FireFlinkLLMResponse } from "../types/llmResponseType.js"
|
|
4
4
|
import { PromptType } from "../types/promptType.js";
|
|
5
|
+
import { platform } from "../types/scriptTypesType.js"
|
|
5
6
|
|
|
6
7
|
export interface LLMRequest {
|
|
8
|
+
platform: platform;
|
|
7
9
|
type: PromptType;
|
|
8
10
|
args: Record<string, any>;
|
|
9
11
|
input: Record<string, any>;
|
|
@@ -21,8 +23,8 @@ export class StepProcessor {
|
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
|
|
24
|
-
async getLLMResponse({ type, args, input }: LLMRequest): Promise<{ response: FireFlinkLLMResponse }> {
|
|
25
|
-
const response = await this.llm.getLLMResponse(type, args, input);
|
|
26
|
+
async getLLMResponse({ platform, type, args, input }: LLMRequest): Promise<{ response: FireFlinkLLMResponse }> {
|
|
27
|
+
const response = await this.llm.getLLMResponse(platform, type, args, input);
|
|
26
28
|
return this.resultParser.fetchResult(response);
|
|
27
29
|
}
|
|
28
30
|
}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import { IKeywordAction, IDragDropAction,
|
|
1
|
+
import { IKeywordAction, IDragDropAction, IAlertAction, IScrollOrAttributeAction, IManualSteps, IVisionAction , IWaitAction, IClickAction, IVerifyAction, IGetAction} from "../interfaces/llmResponseInterface.js";
|
|
2
2
|
|
|
3
3
|
export type FireFlinkLLMResponse =
|
|
4
4
|
|
|
5
5
|
| IKeywordAction
|
|
6
|
-
|
|
|
6
|
+
| IAlertAction
|
|
7
7
|
| IDragDropAction
|
|
8
8
|
| IScrollOrAttributeAction
|
|
9
9
|
| IManualSteps
|
|
10
|
-
|
|
|
10
|
+
| IVisionAction
|
|
11
|
+
| IWaitAction
|
|
12
|
+
| IClickAction
|
|
13
|
+
| IVerifyAction
|
|
14
|
+
| IGetAction
|
|
11
15
|
| any
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { PromptArgsMap } from "../interfaces/promptInterface.js";
|
|
2
|
+
import { platform } from "../types/scriptTypesType.js"
|
|
2
3
|
|
|
3
4
|
export type PromptMap = {
|
|
4
|
-
[
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
[P in platform]: {
|
|
6
|
+
[K in keyof PromptArgsMap]: (
|
|
7
|
+
args: PromptArgsMap[K]
|
|
8
|
+
) => Promise<string>;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
@@ -4,4 +4,10 @@ export enum PromptType {
|
|
|
4
4
|
ERROR_DESCRIPTION = "errorDescriptionPrompt",
|
|
5
5
|
FF_INSPECTOR = "ffInspectorNumExtractor",
|
|
6
6
|
VISION_PROMPT = "visionPrompt",
|
|
7
|
+
VERIFY_PROMPT = "verifyActionExtractorPrompt",
|
|
8
|
+
GET_PROMPT = "getActionExtractorPrompt",
|
|
9
|
+
WAIT_ACTION_EXTRACTOR_PROMPT = "waitActionExtractorPrompt",
|
|
10
|
+
COMBINED_ACTION_EXTRACTOR_PROMPT = "combinedActionExtractorPrompt"
|
|
7
11
|
}
|
|
12
|
+
|
|
13
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type platform = "web" | "android";
|
|
@@ -16,7 +16,7 @@ export class DomProcessingEngine {
|
|
|
16
16
|
private searcher = new DomSearcher();
|
|
17
17
|
private relationshipBuilder = new DomRelationshipBuilder();
|
|
18
18
|
|
|
19
|
-
public
|
|
19
|
+
public webProcess(request: DomProcessingRequest) {
|
|
20
20
|
|
|
21
21
|
const flat = this.simplifier.simplify(request.rawDom);
|
|
22
22
|
logger.saveJSON(flat, `flat-dom-${request.stepCount}`);
|
|
@@ -25,4 +25,13 @@ export class DomProcessingEngine {
|
|
|
25
25
|
|
|
26
26
|
return structured;
|
|
27
27
|
}
|
|
28
|
+
public mobileProcess(request: DomProcessingRequest) {
|
|
29
|
+
|
|
30
|
+
const { flatNodes, parentMap } = this.simplifier.simplifyMobile(request.rawDom);
|
|
31
|
+
logger.saveJSON(flatNodes, `flat-dom-Mob-${request.stepCount}`);
|
|
32
|
+
const { results, indexMap } = this.searcher.searchBestMobile(flatNodes, request.keywords);
|
|
33
|
+
const grouped = this.relationshipBuilder.buildGroupedResultsMobile(results,flatNodes,indexMap,parentMap);
|
|
34
|
+
|
|
35
|
+
return grouped;
|
|
36
|
+
}
|
|
28
37
|
}
|
|
@@ -91,4 +91,209 @@ export class DomRelationshipBuilder {
|
|
|
91
91
|
|
|
92
92
|
return structured;
|
|
93
93
|
}
|
|
94
|
+
|
|
95
|
+
public buildGroupedResultsMobile(
|
|
96
|
+
results: Record<string, any[]>,
|
|
97
|
+
nodes: any[],
|
|
98
|
+
indexMap: Record<string, number>,
|
|
99
|
+
parentMap: Map<Element, Element | null>
|
|
100
|
+
) {
|
|
101
|
+
|
|
102
|
+
const groupedResults: any[][] = [];
|
|
103
|
+
const usedNodes = new Set<string>();
|
|
104
|
+
|
|
105
|
+
const slim = (n: Record<string, any>) => {
|
|
106
|
+
const keys = [
|
|
107
|
+
"tag",
|
|
108
|
+
"FF-inspecter",
|
|
109
|
+
"text",
|
|
110
|
+
"content-desc",
|
|
111
|
+
"resource-id",
|
|
112
|
+
"class",
|
|
113
|
+
"pane-title",
|
|
114
|
+
"hint",
|
|
115
|
+
"clickable",
|
|
116
|
+
"editable",
|
|
117
|
+
"enabled"
|
|
118
|
+
];
|
|
119
|
+
|
|
120
|
+
const out: Record<string, any> = {};
|
|
121
|
+
for (const k of keys) {
|
|
122
|
+
if (k in n) out[k] = n[k];
|
|
123
|
+
}
|
|
124
|
+
return out;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const addNodeSafe = (
|
|
128
|
+
nodeDict: Record<string, any>,
|
|
129
|
+
group: any[],
|
|
130
|
+
localUsed: Set<string>
|
|
131
|
+
) => {
|
|
132
|
+
|
|
133
|
+
const ff = nodeDict["FF-inspecter"];
|
|
134
|
+
|
|
135
|
+
if (!ff || localUsed.has(ff)) return;
|
|
136
|
+
|
|
137
|
+
group.push(slim(nodeDict));
|
|
138
|
+
localUsed.add(ff);
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
for (const matchedNodes of Object.values(results)) {
|
|
142
|
+
|
|
143
|
+
for (const matchedNode of matchedNodes) {
|
|
144
|
+
|
|
145
|
+
const selectedFF = matchedNode["FF-inspecter"];
|
|
146
|
+
|
|
147
|
+
if (!(selectedFF in indexMap)) continue;
|
|
148
|
+
if (usedNodes.has(selectedFF)) continue;
|
|
149
|
+
|
|
150
|
+
const item = nodes[indexMap[selectedFF]];
|
|
151
|
+
const element = item.element;
|
|
152
|
+
const parent = parentMap.get(element) || null;
|
|
153
|
+
|
|
154
|
+
const group: any[] = [];
|
|
155
|
+
const localUsed = new Set<string>();
|
|
156
|
+
|
|
157
|
+
addNodeSafe(matchedNode, group, localUsed);
|
|
158
|
+
|
|
159
|
+
if (matchedNode["clickable"] === "true") {
|
|
160
|
+
groupedResults.push(group);
|
|
161
|
+
localUsed.forEach(ff => usedNodes.add(ff));
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (!parent) {
|
|
166
|
+
groupedResults.push(group);
|
|
167
|
+
localUsed.forEach(ff => usedNodes.add(ff));
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// parent check
|
|
172
|
+
if (
|
|
173
|
+
parent.getAttribute("clickable") === "true" &&
|
|
174
|
+
parent.getAttribute("enabled") !== "false"
|
|
175
|
+
) {
|
|
176
|
+
addNodeSafe(
|
|
177
|
+
Object.fromEntries(Array.from(parent?.attributes ?? []).map(a => [a.name, a.value])),
|
|
178
|
+
group,
|
|
179
|
+
localUsed
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const siblings = Array.from(parent?.children ?? []);
|
|
184
|
+
const idx = siblings.indexOf(element);
|
|
185
|
+
|
|
186
|
+
// upper siblings
|
|
187
|
+
if (idx > 0) {
|
|
188
|
+
for (let j = idx - 1; j >= 0; j--) {
|
|
189
|
+
|
|
190
|
+
const upper = siblings[j];
|
|
191
|
+
|
|
192
|
+
if (
|
|
193
|
+
upper.getAttribute("clickable") === "true" &&
|
|
194
|
+
upper.getAttribute("enabled") !== "false"
|
|
195
|
+
) {
|
|
196
|
+
addNodeSafe(
|
|
197
|
+
Object.fromEntries(Array.from(upper?.attributes ?? []).map(a => [a.name, a.value])),
|
|
198
|
+
group,
|
|
199
|
+
localUsed
|
|
200
|
+
);
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const upperParent = parentMap.get(upper);
|
|
205
|
+
|
|
206
|
+
if (
|
|
207
|
+
upperParent &&
|
|
208
|
+
upperParent.getAttribute("clickable") === "true" &&
|
|
209
|
+
upperParent.getAttribute("enabled") !== "false"
|
|
210
|
+
) {
|
|
211
|
+
addNodeSafe(
|
|
212
|
+
Object.fromEntries(Array.from(upperParent?.attributes ?? []).map(a => [a.name, a.value])),
|
|
213
|
+
group,
|
|
214
|
+
localUsed
|
|
215
|
+
);
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// lower siblings
|
|
222
|
+
if (idx !== -1) {
|
|
223
|
+
for (let j = idx + 1; j < siblings.length; j++) {
|
|
224
|
+
|
|
225
|
+
const lower = siblings[j];
|
|
226
|
+
|
|
227
|
+
if (
|
|
228
|
+
lower.getAttribute("clickable") === "true" &&
|
|
229
|
+
lower.getAttribute("enabled") !== "false"
|
|
230
|
+
) {
|
|
231
|
+
addNodeSafe(
|
|
232
|
+
Object.fromEntries(Array.from(lower?.attributes ?? []).map(a => [a.name, a.value])),
|
|
233
|
+
group,
|
|
234
|
+
localUsed
|
|
235
|
+
);
|
|
236
|
+
break;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
for (const child of Array.from(lower?.children ?? [])) {
|
|
240
|
+
if (
|
|
241
|
+
child.getAttribute("clickable") === "true" &&
|
|
242
|
+
child.getAttribute("enabled") !== "false"
|
|
243
|
+
) {
|
|
244
|
+
addNodeSafe(
|
|
245
|
+
Object.fromEntries(Array.from(child?.attributes ?? []).map(a => [a.name, a.value])),
|
|
246
|
+
group,
|
|
247
|
+
localUsed
|
|
248
|
+
);
|
|
249
|
+
break;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
groupedResults.push(group);
|
|
256
|
+
localUsed.forEach(ff => usedNodes.add(ff));
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
const firstMultiIndex: Record<string, number> = {};
|
|
261
|
+
|
|
262
|
+
groupedResults.forEach((group, i) => {
|
|
263
|
+
if (group.length > 1) {
|
|
264
|
+
group.forEach(node => {
|
|
265
|
+
const ff = node["FF-inspecter"];
|
|
266
|
+
if (!(ff in firstMultiIndex)) {
|
|
267
|
+
firstMultiIndex[ff] = i;
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
const finalResults: any[][] = [];
|
|
274
|
+
const usedFF = new Set<string>();
|
|
275
|
+
|
|
276
|
+
groupedResults.forEach((group, i) => {
|
|
277
|
+
|
|
278
|
+
const newGroup: any[] = [];
|
|
279
|
+
|
|
280
|
+
group.forEach(node => {
|
|
281
|
+
|
|
282
|
+
const ff = node["FF-inspecter"];
|
|
283
|
+
|
|
284
|
+
if (usedFF.has(ff)) return;
|
|
285
|
+
|
|
286
|
+
if (group.length === 1 && ff in firstMultiIndex) return;
|
|
287
|
+
|
|
288
|
+
if (ff in firstMultiIndex && firstMultiIndex[ff] !== i) return;
|
|
289
|
+
|
|
290
|
+
newGroup.push(node);
|
|
291
|
+
usedFF.add(ff);
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
if (newGroup.length) finalResults.push(newGroup);
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
return finalResults;
|
|
298
|
+
}
|
|
94
299
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import { FlatNode } from "./simplifyAndFlatten.js";
|
|
1
|
+
import { fuzzy } from "fast-fuzzy";
|
|
2
|
+
import { FlatNode } from "../core/interfaces/simplifyAndFlattenInterface";
|
|
4
3
|
|
|
5
4
|
export class DomSearcher {
|
|
6
5
|
|
|
@@ -8,7 +7,7 @@ export class DomSearcher {
|
|
|
8
7
|
nodes: FlatNode[],
|
|
9
8
|
keywords: string[] | string,
|
|
10
9
|
topN = 20,
|
|
11
|
-
threshold =
|
|
10
|
+
threshold = 40
|
|
12
11
|
) {
|
|
13
12
|
|
|
14
13
|
if (typeof keywords === "string") {
|
|
@@ -99,9 +98,10 @@ export class DomSearcher {
|
|
|
99
98
|
}
|
|
100
99
|
|
|
101
100
|
if (!matched) {
|
|
102
|
-
const score =
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
const score = fuzzy(kw, searchText);
|
|
102
|
+
|
|
103
|
+
if (score >= threshold / 100) {
|
|
104
|
+
fuzzyList.push([score * 100, i]);
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
|
|
@@ -144,17 +144,15 @@ export class DomSearcher {
|
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
const seen = new Set<string>();
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
const
|
|
152
|
-
if (
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
147
|
+
|
|
148
|
+
const unique = Object.values(results)
|
|
149
|
+
.flat()
|
|
150
|
+
.filter(node => {
|
|
151
|
+
const ff = node["FF-inspecter"];
|
|
152
|
+
if (!ff || seen.has(ff)) return false;
|
|
153
|
+
seen.add(ff);
|
|
154
|
+
return true;
|
|
156
155
|
});
|
|
157
|
-
});
|
|
158
156
|
|
|
159
157
|
unique.sort((a, b) =>
|
|
160
158
|
ffNumber(a["FF-inspecter"]) - ffNumber(b["FF-inspecter"])
|
|
@@ -162,4 +160,119 @@ export class DomSearcher {
|
|
|
162
160
|
|
|
163
161
|
return unique;
|
|
164
162
|
}
|
|
163
|
+
|
|
164
|
+
public searchBestMobile(
|
|
165
|
+
nodes: FlatNode[],
|
|
166
|
+
keywords: string[] | string,
|
|
167
|
+
topN = 5,
|
|
168
|
+
threshold = 60
|
|
169
|
+
) {
|
|
170
|
+
|
|
171
|
+
if (typeof keywords === "string") {
|
|
172
|
+
keywords = keywords.replace(/[\[\]]/g, "").split(",").map(k => k.trim());
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
keywords = keywords.map(k => k.toLowerCase());
|
|
176
|
+
|
|
177
|
+
const slim = (n: Record<string, any>) => {
|
|
178
|
+
const allowed = [
|
|
179
|
+
"tag",
|
|
180
|
+
"FF-inspecter",
|
|
181
|
+
"text",
|
|
182
|
+
"content-desc",
|
|
183
|
+
"resource-id",
|
|
184
|
+
"class",
|
|
185
|
+
"pane-title",
|
|
186
|
+
"hint",
|
|
187
|
+
"clickable",
|
|
188
|
+
"editable",
|
|
189
|
+
"enabled"
|
|
190
|
+
];
|
|
191
|
+
|
|
192
|
+
const result: Record<string, any> = {};
|
|
193
|
+
|
|
194
|
+
for (const key of allowed) {
|
|
195
|
+
if (key in n) result[key] = n[key];
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return result;
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
const indexMap: Record<string, number> = {};
|
|
202
|
+
|
|
203
|
+
nodes.forEach((item, i) => {
|
|
204
|
+
const ff = item.node["FF-inspecter"];
|
|
205
|
+
if (ff) indexMap[ff] = i;
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
const results: Record<string, any[]> = {};
|
|
209
|
+
|
|
210
|
+
for (const kw of keywords) {
|
|
211
|
+
|
|
212
|
+
const exact: Record<string, any>[] = [];
|
|
213
|
+
const strong: Record<string, any>[] = [];
|
|
214
|
+
const fuzzyMatches: [number, Record<string, any>][] = [];
|
|
215
|
+
|
|
216
|
+
for (const item of nodes) {
|
|
217
|
+
|
|
218
|
+
const node = item.node;
|
|
219
|
+
|
|
220
|
+
const text = (item.search || "").toLowerCase();
|
|
221
|
+
const t = (node["text"] || "").toLowerCase();
|
|
222
|
+
const cd = (node["content-desc"] || "").toLowerCase();
|
|
223
|
+
const rid = (node["resource-id"] || "").toLowerCase();
|
|
224
|
+
const hint = (node["hint"] || "").toLowerCase();
|
|
225
|
+
|
|
226
|
+
// EXACT MATCH
|
|
227
|
+
if (
|
|
228
|
+
text === kw ||
|
|
229
|
+
t === kw ||
|
|
230
|
+
cd === kw ||
|
|
231
|
+
rid === kw ||
|
|
232
|
+
hint === kw
|
|
233
|
+
) {
|
|
234
|
+
exact.push(node);
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// STRONG PARTIAL MATCH
|
|
239
|
+
if (
|
|
240
|
+
text.includes(kw) ||
|
|
241
|
+
t.includes(kw) ||
|
|
242
|
+
cd.includes(kw) ||
|
|
243
|
+
rid.includes(kw) ||
|
|
244
|
+
hint.includes(kw)
|
|
245
|
+
) {
|
|
246
|
+
strong.push(node);
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// FUZZY MATCH
|
|
251
|
+
const score = fuzzy(kw, text) * 100;
|
|
252
|
+
|
|
253
|
+
if (score >= threshold) {
|
|
254
|
+
fuzzyMatches.push([score, node]);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
let selected: Record<string, any>[];
|
|
259
|
+
|
|
260
|
+
if (exact.length) {
|
|
261
|
+
selected = exact.slice(0, topN);
|
|
262
|
+
} else if (strong.length) {
|
|
263
|
+
selected = strong.slice(0, topN);
|
|
264
|
+
} else {
|
|
265
|
+
fuzzyMatches.sort((a, b) => b[0] - a[0]);
|
|
266
|
+
selected = fuzzyMatches.slice(0, topN).map(f => f[1]);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
results[kw] = selected.map(slim);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
return {
|
|
273
|
+
results,
|
|
274
|
+
indexMap
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
|
|
165
278
|
}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import * as cheerio from "cheerio";
|
|
2
2
|
import { Element } from "domhandler";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
node: Record<string, any>;
|
|
6
|
-
search: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
3
|
+
import { DOMParser } from "@xmldom/xmldom";
|
|
4
|
+
import { FlatNode, FlatNodeMob, SimplifiedDomResult } from "../core/interfaces/simplifyAndFlattenInterface.js"
|
|
9
5
|
export class DomSimplifier {
|
|
10
6
|
|
|
11
7
|
public simplify(rawDom: string): FlatNode[] {
|
|
12
8
|
|
|
13
|
-
const $ = cheerio.load(rawDom);
|
|
9
|
+
const $ = cheerio.load(rawDom, { xml: true });
|
|
14
10
|
const flatNodes: FlatNode[] = [];
|
|
15
11
|
|
|
16
12
|
$("*").each((_, node) => {
|
|
@@ -21,13 +17,12 @@ export class DomSimplifier {
|
|
|
21
17
|
const tag = el.tagName.toLowerCase();
|
|
22
18
|
if (!tag || tag === "meta") return;
|
|
23
19
|
|
|
24
|
-
const attribs = el.attribs ?? {};
|
|
20
|
+
const attribs = el.attribs ?? {};
|
|
25
21
|
|
|
26
22
|
if (tag !== "select" && tag !== "option") {
|
|
27
23
|
if (
|
|
28
24
|
(attribs["element-visibility"] === "hidden" ||
|
|
29
|
-
attribs["element-covered"] === "true")
|
|
30
|
-
attribs["element-covered-by-tag"] !== "iframe"
|
|
25
|
+
attribs["element-covered"] === "true")
|
|
31
26
|
) {
|
|
32
27
|
return;
|
|
33
28
|
}
|
|
@@ -115,4 +110,138 @@ export class DomSimplifier {
|
|
|
115
110
|
|
|
116
111
|
return flatNodes;
|
|
117
112
|
}
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
public simplifyMobile(rawDom: string): SimplifiedDomResult {
|
|
117
|
+
const parser = new DOMParser();
|
|
118
|
+
const xmlDoc = parser.parseFromString(rawDom, "text/xml");
|
|
119
|
+
|
|
120
|
+
const root = xmlDoc.documentElement;
|
|
121
|
+
|
|
122
|
+
const flatNodes: FlatNodeMob[] = [];
|
|
123
|
+
|
|
124
|
+
// parentMap: child → parent
|
|
125
|
+
const parentMap = new Map<globalThis.Element, globalThis.Element>();
|
|
126
|
+
|
|
127
|
+
function xmlToTree(elem: globalThis.Element): any {
|
|
128
|
+
|
|
129
|
+
const children: any[] = [];
|
|
130
|
+
|
|
131
|
+
for (let i = 0; i < elem.childNodes.length; i++) {
|
|
132
|
+
|
|
133
|
+
const child = elem.childNodes[i];
|
|
134
|
+
|
|
135
|
+
if (child.nodeType === 1) {
|
|
136
|
+
|
|
137
|
+
const childElement = child as globalThis.Element;
|
|
138
|
+
|
|
139
|
+
// store parent relationship
|
|
140
|
+
parentMap.set(childElement, elem);
|
|
141
|
+
|
|
142
|
+
children.push(xmlToTree(childElement));
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const attributes: Record<string, string> = {};
|
|
147
|
+
|
|
148
|
+
for (let i = 0; i < elem.attributes.length; i++) {
|
|
149
|
+
const attr = elem.attributes[i];
|
|
150
|
+
attributes[attr.name] = attr.value;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return {
|
|
154
|
+
tag: elem.tagName,
|
|
155
|
+
attributes,
|
|
156
|
+
text: (elem.textContent || "").trim(),
|
|
157
|
+
_element: elem,
|
|
158
|
+
children
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const xmlTree = xmlToTree(root);
|
|
163
|
+
|
|
164
|
+
function simplifyAndFlatten(node: any): any {
|
|
165
|
+
|
|
166
|
+
const simplified: Record<string, any> = {};
|
|
167
|
+
const attrs = node.attributes || {};
|
|
168
|
+
|
|
169
|
+
simplified["tag"] = node.tag;
|
|
170
|
+
|
|
171
|
+
const skipNode = attrs["enabled"] === "false";
|
|
172
|
+
|
|
173
|
+
if (attrs["FF-inspecter"]) {
|
|
174
|
+
simplified["FF-inspecter"] = attrs["FF-inspecter"];
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
simplified["text"] = node.text || attrs["text"] || "";
|
|
178
|
+
|
|
179
|
+
const importantAttrs = [
|
|
180
|
+
"resource-id",
|
|
181
|
+
"content-desc",
|
|
182
|
+
"pane-title",
|
|
183
|
+
"clickable",
|
|
184
|
+
"editable",
|
|
185
|
+
"enabled",
|
|
186
|
+
"class",
|
|
187
|
+
"hint"
|
|
188
|
+
];
|
|
189
|
+
|
|
190
|
+
for (const attr of importantAttrs) {
|
|
191
|
+
if (attrs[attr]) {
|
|
192
|
+
simplified[attr] = attrs[attr];
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const searchParts: string[] = [];
|
|
197
|
+
|
|
198
|
+
if (simplified.text && simplified.text.trim()) {
|
|
199
|
+
searchParts.push(simplified.text);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
for (const key of [
|
|
203
|
+
"content-desc",
|
|
204
|
+
"pane-title",
|
|
205
|
+
"resource-id",
|
|
206
|
+
"hint"
|
|
207
|
+
]) {
|
|
208
|
+
const val = simplified[key];
|
|
209
|
+
if (val && typeof val === "string" && val.trim()) {
|
|
210
|
+
searchParts.push(val);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
simplified["search"] = searchParts.join(" ").trim().toLowerCase();
|
|
215
|
+
|
|
216
|
+
if (!skipNode) {
|
|
217
|
+
flatNodes.push({
|
|
218
|
+
node: simplified,
|
|
219
|
+
search: simplified["search"],
|
|
220
|
+
element: node._element
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
const children: any[] = [];
|
|
225
|
+
|
|
226
|
+
for (const child of node.children || []) {
|
|
227
|
+
const simplifiedChild = simplifyAndFlatten(child);
|
|
228
|
+
|
|
229
|
+
if (simplifiedChild && simplifiedChild.enabled !== "false") {
|
|
230
|
+
children.push(simplifiedChild);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
if (children.length) {
|
|
235
|
+
simplified["children"] = children;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return simplified;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
simplifyAndFlatten(xmlTree);
|
|
242
|
+
|
|
243
|
+
return {
|
|
244
|
+
flatNodes, parentMap
|
|
245
|
+
};
|
|
246
|
+
}
|
|
118
247
|
}
|
|
@@ -4,7 +4,7 @@ export class ElementGetter {
|
|
|
4
4
|
async getFireFlinkElement(html: string, attribute: string): Promise<any> {
|
|
5
5
|
const formattedAttribute = attribute.replace('[', '//*[@');
|
|
6
6
|
try {
|
|
7
|
-
const result =
|
|
7
|
+
const result = getElementsFromHTML(
|
|
8
8
|
[
|
|
9
9
|
{
|
|
10
10
|
name: "xpath",
|
|
@@ -17,7 +17,6 @@ export class ElementGetter {
|
|
|
17
17
|
],
|
|
18
18
|
html
|
|
19
19
|
);
|
|
20
|
-
|
|
21
20
|
return Array.isArray(result) && result.length > 0 ? JSON.parse(JSON.stringify(result[0], null, 4)) : null;
|
|
22
21
|
}
|
|
23
22
|
catch (error) {
|