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
|
@@ -1,30 +1,79 @@
|
|
|
1
1
|
import { IScriptGenerationData } from "../../core/interfaces/scriptGenrationDataInterface.js";
|
|
2
|
-
import { IPayload } from "../../core/interfaces/fireflinkScriptPayloadInterface.js";
|
|
3
|
-
import { FireFlinkApiService } from "../../service/fireflinkApi.service.js";
|
|
4
|
-
import { ScriptRunner } from "../../service/scriptRunner.service.js";
|
|
5
|
-
|
|
6
|
-
const apiService = new FireFlinkApiService();
|
|
7
|
-
const scriptRunner = new ScriptRunner(apiService);
|
|
8
2
|
|
|
9
3
|
export class ScriptDataAppender {
|
|
4
|
+
|
|
10
5
|
private data: IScriptGenerationData[] = [];
|
|
11
|
-
|
|
6
|
+
private queue: (() => Promise<void>)[] = [];
|
|
7
|
+
private errorNLP: string = "";
|
|
8
|
+
|
|
9
|
+
private concurrencyLimit = 5;
|
|
10
|
+
|
|
11
|
+
add(task: () => Promise<IScriptGenerationData>) {
|
|
12
|
+
|
|
13
|
+
const job = async () => {
|
|
14
|
+
await this.retry(async () => {
|
|
15
|
+
const item = await task();
|
|
16
|
+
this.process(item);
|
|
17
|
+
}, 3);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
this.queue.push(job);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
private process(item: IScriptGenerationData) {
|
|
12
24
|
this.data.push(item);
|
|
13
25
|
}
|
|
14
|
-
|
|
26
|
+
|
|
27
|
+
private async retry(fn: () => Promise<void>, retries: number) {
|
|
28
|
+
|
|
29
|
+
for (let i = 0; i <= retries; i++) {
|
|
30
|
+
try {
|
|
31
|
+
return await fn();
|
|
32
|
+
} catch (err: any) {
|
|
33
|
+
|
|
34
|
+
if (i === retries) {
|
|
35
|
+
console.error("Step failed:", err);
|
|
36
|
+
this.errorNLP = err?.message ?? "Unknown error";
|
|
37
|
+
throw err;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async waitForAllSteps() {
|
|
45
|
+
|
|
46
|
+
const workers: Promise<void>[] = [];
|
|
47
|
+
|
|
48
|
+
while (this.queue.length > 0 || workers.length > 0) {
|
|
49
|
+
|
|
50
|
+
while (workers.length < this.concurrencyLimit && this.queue.length > 0) {
|
|
51
|
+
|
|
52
|
+
const job = this.queue.shift()!;
|
|
53
|
+
const worker = job().finally(() => {
|
|
54
|
+
const index = workers.indexOf(worker);
|
|
55
|
+
if (index > -1) workers.splice(index, 1);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
workers.push(worker);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (workers.length > 0) {
|
|
62
|
+
await Promise.race(workers);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
getData() {
|
|
15
69
|
return this.data;
|
|
16
70
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
)
|
|
23
|
-
return
|
|
24
|
-
result,
|
|
25
|
-
payload,
|
|
26
|
-
token,
|
|
27
|
-
serverHost
|
|
28
|
-
);
|
|
71
|
+
|
|
72
|
+
setErrorNLP(nlp: string) {
|
|
73
|
+
this.errorNLP = nlp;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
getErrorNLP() {
|
|
77
|
+
return this.errorNLP;
|
|
29
78
|
}
|
|
30
|
-
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { createCanvas, loadImage } from "canvas"
|
|
2
|
+
import { XMLParser } from "fast-xml-parser"
|
|
3
|
+
import { Bounds } from "./annotatedScreenshotMobileInterface.js"
|
|
4
|
+
import { logger } from "../utils/logger/logData.js"
|
|
5
|
+
|
|
6
|
+
function parseBounds(bounds: string): Bounds | null {
|
|
7
|
+
|
|
8
|
+
const nums = bounds.match(/\d+/g)
|
|
9
|
+
|
|
10
|
+
if (!nums || nums.length !== 4) return null
|
|
11
|
+
|
|
12
|
+
return {
|
|
13
|
+
x1: parseInt(nums[0]),
|
|
14
|
+
y1: parseInt(nums[1]),
|
|
15
|
+
x2: parseInt(nums[2]),
|
|
16
|
+
y2: parseInt(nums[3])
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
function extractBoxes(xmlSource: string): Bounds[] {
|
|
22
|
+
|
|
23
|
+
const parser = new XMLParser({
|
|
24
|
+
ignoreAttributes: false,
|
|
25
|
+
attributeNamePrefix: ""
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
const tree = parser.parse(xmlSource)
|
|
29
|
+
|
|
30
|
+
const boxes: Bounds[] = []
|
|
31
|
+
|
|
32
|
+
const traverse = (node: any) => {
|
|
33
|
+
|
|
34
|
+
if (node?.bounds) {
|
|
35
|
+
|
|
36
|
+
const clickable = node.clickable === "true"
|
|
37
|
+
const enabled = node.enabled === "true"
|
|
38
|
+
const clazz = node.class || ""
|
|
39
|
+
|
|
40
|
+
if (
|
|
41
|
+
(clickable && enabled) ||
|
|
42
|
+
clazz.toLowerCase().includes("edittext") ||
|
|
43
|
+
clazz.toLowerCase().includes("autocompletetextview")
|
|
44
|
+
) {
|
|
45
|
+
|
|
46
|
+
const bounds = parseBounds(node.bounds)
|
|
47
|
+
|
|
48
|
+
if (bounds) boxes.push(bounds)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
for (const key in node) {
|
|
53
|
+
if (typeof node[key] === "object") {
|
|
54
|
+
traverse(node[key])
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
traverse(tree)
|
|
60
|
+
|
|
61
|
+
return boxes
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
const COLORS: [number, number, number][] = [
|
|
66
|
+
[255, 0, 0],
|
|
67
|
+
[0, 128, 255],
|
|
68
|
+
[0, 180, 0],
|
|
69
|
+
[255, 140, 0],
|
|
70
|
+
[148, 0, 211],
|
|
71
|
+
[0, 180, 180],
|
|
72
|
+
[180, 0, 0],
|
|
73
|
+
[255, 105, 180],
|
|
74
|
+
];
|
|
75
|
+
|
|
76
|
+
async function drawBoxes(
|
|
77
|
+
screenshotBuffer: Buffer,
|
|
78
|
+
boxes: Bounds[]
|
|
79
|
+
): Promise<Buffer> {
|
|
80
|
+
|
|
81
|
+
const img = await loadImage(screenshotBuffer)
|
|
82
|
+
|
|
83
|
+
const canvas = createCanvas(img.width, img.height)
|
|
84
|
+
const ctx = canvas.getContext("2d")
|
|
85
|
+
|
|
86
|
+
ctx.drawImage(img, 0, 0)
|
|
87
|
+
|
|
88
|
+
const scale = img.width / 1080
|
|
89
|
+
const fontSize = Math.max(20, Math.floor(28 * scale))
|
|
90
|
+
|
|
91
|
+
ctx.font = `${fontSize}px Arial`
|
|
92
|
+
ctx.textBaseline = "top"
|
|
93
|
+
|
|
94
|
+
boxes.forEach((box, index) => {
|
|
95
|
+
|
|
96
|
+
const color = COLORS[index % COLORS.length]
|
|
97
|
+
const colorStr = `rgb(${color[0]},${color[1]},${color[2]})`
|
|
98
|
+
|
|
99
|
+
ctx.strokeStyle = colorStr
|
|
100
|
+
ctx.lineWidth = Math.max(2, Math.floor(3 * scale))
|
|
101
|
+
|
|
102
|
+
ctx.strokeRect(
|
|
103
|
+
box.x1,
|
|
104
|
+
box.y1,
|
|
105
|
+
box.x2 - box.x1,
|
|
106
|
+
box.y2 - box.y1
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
ctx.fillStyle = colorStr
|
|
110
|
+
ctx.fillText(
|
|
111
|
+
String(index + 1),
|
|
112
|
+
box.x1 + 6,
|
|
113
|
+
box.y1 + 6
|
|
114
|
+
)
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
return canvas.toBuffer("image/png")
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
export async function annotateScreenshot(
|
|
122
|
+
driver: any,
|
|
123
|
+
xmlSource: string
|
|
124
|
+
): Promise<Buffer> {
|
|
125
|
+
|
|
126
|
+
const screenshotBase64 = await driver.takeScreenshot()
|
|
127
|
+
const screenshotBuffer = Buffer.from(screenshotBase64, "base64")
|
|
128
|
+
|
|
129
|
+
const boxes = extractBoxes(xmlSource)
|
|
130
|
+
|
|
131
|
+
const boxedImageBuffer = await drawBoxes(screenshotBuffer, boxes)
|
|
132
|
+
|
|
133
|
+
// Uncomment only when debugging
|
|
134
|
+
await logger.saveImage(boxedImageBuffer, "boxed.png");
|
|
135
|
+
|
|
136
|
+
return boxedImageBuffer
|
|
137
|
+
}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { createCanvas, loadImage, CanvasRenderingContext2D } from "canvas";
|
|
2
|
+
import { Rect, NodeItem } from "./screenshotInterface.js";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
const COLORS: [number, number, number][] = [
|
|
6
|
+
[255, 0, 0],
|
|
7
|
+
[0, 128, 255],
|
|
8
|
+
[0, 180, 0],
|
|
9
|
+
[255, 140, 0],
|
|
10
|
+
[148, 0, 211],
|
|
11
|
+
[0, 180, 180],
|
|
12
|
+
[180, 0, 0],
|
|
13
|
+
[255, 105, 180],
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
const TAG_PADDING = 4;
|
|
17
|
+
|
|
18
|
+
function measureText(
|
|
19
|
+
ctx: CanvasRenderingContext2D,
|
|
20
|
+
text: string
|
|
21
|
+
) {
|
|
22
|
+
const metrics = ctx.measureText(text);
|
|
23
|
+
const height =
|
|
24
|
+
metrics.actualBoundingBoxAscent + metrics.actualBoundingBoxDescent;
|
|
25
|
+
return { width: metrics.width, height };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function rectsIntersect(a: Rect, b: Rect): boolean {
|
|
29
|
+
const [ax1, ay1, ax2, ay2] = a;
|
|
30
|
+
const [bx1, by1, bx2, by2] = b;
|
|
31
|
+
return !(ax2 < bx1 || ax1 > bx2 || ay2 < by1 || ay1 > by2);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function insideScreen(rect: Rect, width: number, height: number): boolean {
|
|
35
|
+
const [x1, y1, x2, y2] = rect;
|
|
36
|
+
return x1 >= 0 && y1 >= 0 && x2 <= width && y2 <= height;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function findFreeTagPosition(
|
|
40
|
+
box: Rect,
|
|
41
|
+
tagW: number,
|
|
42
|
+
tagH: number,
|
|
43
|
+
elementBoxes: Rect[],
|
|
44
|
+
usedTagRects: Rect[],
|
|
45
|
+
imgWidth: number,
|
|
46
|
+
imgHeight: number
|
|
47
|
+
) {
|
|
48
|
+
const [bx1, by1, bx2, by2] = box;
|
|
49
|
+
const cx = Math.floor((bx1 + bx2) / 2);
|
|
50
|
+
const cy = Math.floor((by1 + by2) / 2);
|
|
51
|
+
|
|
52
|
+
const maxRadius = 120;
|
|
53
|
+
const step = 6;
|
|
54
|
+
|
|
55
|
+
for (let radius = 6; radius < maxRadius; radius += step) {
|
|
56
|
+
for (let angle = 0; angle < 360; angle += 30) {
|
|
57
|
+
const rad = (angle * Math.PI) / 180;
|
|
58
|
+
|
|
59
|
+
const lx = Math.floor(cx + radius * Math.cos(rad) - tagW / 2);
|
|
60
|
+
const ly = Math.floor(cy + radius * Math.sin(rad) - tagH / 2);
|
|
61
|
+
|
|
62
|
+
const rect: Rect = [
|
|
63
|
+
lx - TAG_PADDING,
|
|
64
|
+
ly - TAG_PADDING,
|
|
65
|
+
lx + tagW + TAG_PADDING,
|
|
66
|
+
ly + tagH + TAG_PADDING,
|
|
67
|
+
];
|
|
68
|
+
|
|
69
|
+
if (!insideScreen(rect, imgWidth, imgHeight)) continue;
|
|
70
|
+
if (elementBoxes.some((b) => rectsIntersect(rect, b))) continue;
|
|
71
|
+
if (usedTagRects.some((t) => rectsIntersect(rect, t))) continue;
|
|
72
|
+
|
|
73
|
+
usedTagRects.push(rect);
|
|
74
|
+
return { x: lx, y: ly };
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const fallbackX = Math.max(0, bx1 - tagW - 10);
|
|
79
|
+
const fallbackY = Math.max(0, by1 - tagH - 10);
|
|
80
|
+
usedTagRects.push([fallbackX, fallbackY, fallbackX + tagW, fallbackY + tagH]);
|
|
81
|
+
|
|
82
|
+
return { x: fallbackX, y: fallbackY };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export async function annotateScreenshot(
|
|
86
|
+
screenshotBase64: string,
|
|
87
|
+
nodes: NodeItem[],
|
|
88
|
+
): Promise<Buffer> {
|
|
89
|
+
|
|
90
|
+
const buffer = Buffer.from(screenshotBase64, "base64");
|
|
91
|
+
const image = await loadImage(buffer);
|
|
92
|
+
const scale = image.width / 1920;
|
|
93
|
+
const fontSize = Math.max(10, Math.floor(14 * scale));
|
|
94
|
+
|
|
95
|
+
const canvas = createCanvas(image.width, image.height);
|
|
96
|
+
const ctx = canvas.getContext("2d");
|
|
97
|
+
|
|
98
|
+
ctx.drawImage(image, 0, 0);
|
|
99
|
+
ctx.font = `${fontSize}px Tahoma`;
|
|
100
|
+
ctx.textBaseline = "middle";
|
|
101
|
+
ctx.textAlign = "center";
|
|
102
|
+
|
|
103
|
+
const usedTagRects: Rect[] = [];
|
|
104
|
+
|
|
105
|
+
const elementBoxes: Rect[] = nodes.map((n) => [
|
|
106
|
+
Math.floor(n.bbox.x),
|
|
107
|
+
Math.floor(n.bbox.y),
|
|
108
|
+
Math.floor(n.bbox.x + n.bbox.w),
|
|
109
|
+
Math.floor(n.bbox.y + n.bbox.h),
|
|
110
|
+
]);
|
|
111
|
+
|
|
112
|
+
nodes.forEach((item, i) => {
|
|
113
|
+
|
|
114
|
+
const color = COLORS[i % COLORS.length];
|
|
115
|
+
const colorStr = `rgb(${color[0]},${color[1]},${color[2]})`;
|
|
116
|
+
|
|
117
|
+
const label = item.ff.split("-").pop() || "";
|
|
118
|
+
|
|
119
|
+
const x1 = Math.floor(item.bbox.x);
|
|
120
|
+
const y1 = Math.floor(item.bbox.y);
|
|
121
|
+
const x2 = Math.floor(item.bbox.x + item.bbox.w);
|
|
122
|
+
const y2 = Math.floor(item.bbox.y + item.bbox.h);
|
|
123
|
+
|
|
124
|
+
ctx.strokeStyle = colorStr;
|
|
125
|
+
ctx.lineWidth = Math.max(2, Math.floor(2 * scale));
|
|
126
|
+
ctx.strokeRect(x1, y1, x2 - x1, y2 - y1);
|
|
127
|
+
|
|
128
|
+
const { width: tw, height: th } = measureText(ctx, label);
|
|
129
|
+
|
|
130
|
+
const tagW = Math.max(22, tw + 10);
|
|
131
|
+
const tagH = Math.max(18, th + 8);
|
|
132
|
+
|
|
133
|
+
const { x: lx, y: ly } = findFreeTagPosition(
|
|
134
|
+
[x1, y1, x2, y2],
|
|
135
|
+
tagW,
|
|
136
|
+
tagH,
|
|
137
|
+
elementBoxes,
|
|
138
|
+
usedTagRects,
|
|
139
|
+
canvas.width,
|
|
140
|
+
canvas.height
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
ctx.fillStyle = "white";
|
|
144
|
+
ctx.strokeStyle = colorStr;
|
|
145
|
+
ctx.lineWidth = 2;
|
|
146
|
+
ctx.fillRect(lx, ly, tagW, tagH);
|
|
147
|
+
ctx.strokeRect(lx, ly, tagW, tagH);
|
|
148
|
+
|
|
149
|
+
ctx.fillStyle = colorStr;
|
|
150
|
+
ctx.fillText(label, lx + tagW / 2, ly + tagH / 2);
|
|
151
|
+
|
|
152
|
+
const tagCx = lx + tagW / 2;
|
|
153
|
+
const tagCy = ly + tagH / 2;
|
|
154
|
+
const boxCx = (x1 + x2) / 2;
|
|
155
|
+
const boxCy = (y1 + y2) / 2;
|
|
156
|
+
|
|
157
|
+
const offset = 2;
|
|
158
|
+
|
|
159
|
+
let lineStartX: number;
|
|
160
|
+
let lineStartY: number;
|
|
161
|
+
let lineEndX: number;
|
|
162
|
+
let lineEndY: number;
|
|
163
|
+
|
|
164
|
+
if (tagCx < x1) {
|
|
165
|
+
lineStartX = lx + tagW;
|
|
166
|
+
lineStartY = tagCy;
|
|
167
|
+
lineEndX = x1 - offset;
|
|
168
|
+
lineEndY = boxCy;
|
|
169
|
+
} else if (tagCx > x2) {
|
|
170
|
+
lineStartX = lx;
|
|
171
|
+
lineStartY = tagCy;
|
|
172
|
+
lineEndX = x2 + offset;
|
|
173
|
+
lineEndY = boxCy;
|
|
174
|
+
} else if (tagCy < y1) {
|
|
175
|
+
lineStartX = tagCx;
|
|
176
|
+
lineStartY = ly + tagH;
|
|
177
|
+
lineEndX = boxCx;
|
|
178
|
+
lineEndY = y1 - offset;
|
|
179
|
+
} else {
|
|
180
|
+
lineStartX = tagCx;
|
|
181
|
+
lineStartY = ly;
|
|
182
|
+
lineEndX = boxCx;
|
|
183
|
+
lineEndY = y2 + offset;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
ctx.beginPath();
|
|
187
|
+
ctx.moveTo(lineStartX, lineStartY);
|
|
188
|
+
ctx.lineTo(lineEndX, lineEndY);
|
|
189
|
+
ctx.stroke();
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
const boxedImageBuffer = canvas.toBuffer("image/png");
|
|
194
|
+
|
|
195
|
+
return boxedImageBuffer;
|
|
196
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { annotateScreenshot } from "./annotateScreenshot.js";
|
|
2
|
+
import { JS_PRIMARY } from "../utils/javascript/jsForVision.js";
|
|
3
|
+
import { NodeItem } from "./screenshotInterface.js";
|
|
4
|
+
// import { logger } from "../utils/logger/logData.js";
|
|
5
|
+
|
|
6
|
+
export async function generateAnnotatedScreenshots(
|
|
7
|
+
driver: WebdriverIO.Browser
|
|
8
|
+
): Promise<Buffer> {
|
|
9
|
+
|
|
10
|
+
const screenshot = await driver.takeScreenshot();
|
|
11
|
+
|
|
12
|
+
// const [primaryRaw, secondaryRaw] = await Promise.all([
|
|
13
|
+
// driver.execute(JS_PRIMARY),
|
|
14
|
+
// driver.execute(JS_SECONDARY),
|
|
15
|
+
// ]);
|
|
16
|
+
const [primaryRaw] = await Promise.all([
|
|
17
|
+
driver.execute(JS_PRIMARY),
|
|
18
|
+
// driver.execute(JS_SECONDARY),
|
|
19
|
+
]);
|
|
20
|
+
|
|
21
|
+
const primary = (primaryRaw as NodeItem[]) ?? [];
|
|
22
|
+
// let secondary = (secondaryRaw as NodeItem[]) ?? [];
|
|
23
|
+
|
|
24
|
+
// const primaryIds = new Set(primary.map((item) => item.ff));
|
|
25
|
+
// secondary = secondary.filter((item) => !primaryIds.has(item.ff));
|
|
26
|
+
|
|
27
|
+
const [primaryAnnotated] = await Promise.all([
|
|
28
|
+
annotateScreenshot(
|
|
29
|
+
screenshot,
|
|
30
|
+
primary,
|
|
31
|
+
),
|
|
32
|
+
// annotateScreenshot(
|
|
33
|
+
// screenshot,
|
|
34
|
+
// secondary,
|
|
35
|
+
// )
|
|
36
|
+
]);
|
|
37
|
+
|
|
38
|
+
// Uncomment only when debugging
|
|
39
|
+
// await logger.saveImage(primaryAnnotated, "annotated_primary.png");
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
return primaryAnnotated;
|
|
43
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
export interface BBox {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
w: number;
|
|
6
|
+
h: number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface NodeItem {
|
|
10
|
+
ff: string;
|
|
11
|
+
xpath: string;
|
|
12
|
+
bbox: BBox;
|
|
13
|
+
tag: string;
|
|
14
|
+
text: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type Rect = [number, number, number, number];
|
|
18
|
+
|
package/src/index.ts
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import axios, { AxiosError } from "axios";
|
|
2
|
-
import { IFireFlinkApiService } from "
|
|
2
|
+
import { IFireFlinkApiService } from "../../core/interfaces/fireflinkScriptPayloadInterface.js";
|
|
3
3
|
|
|
4
4
|
export class FireFlinkApiService implements IFireFlinkApiService {
|
|
5
|
-
|
|
6
|
-
async callFireFlinkApi(
|
|
5
|
+
async getInstancesDetailsApi(
|
|
7
6
|
headers: Record<string, string>,
|
|
8
|
-
body: any,
|
|
9
7
|
url: string
|
|
10
8
|
): Promise<any> {
|
|
11
9
|
|
|
12
10
|
try {
|
|
13
|
-
const response = await axios.
|
|
11
|
+
const response = await axios.get(url, {
|
|
14
12
|
headers,
|
|
15
13
|
timeout: 30000,
|
|
16
14
|
});
|
|
@@ -23,7 +21,7 @@ export class FireFlinkApiService implements IFireFlinkApiService {
|
|
|
23
21
|
|
|
24
22
|
if (err.code === "ECONNABORTED") {
|
|
25
23
|
throw new Error(
|
|
26
|
-
"Request to FireFlink API timed out",
|
|
24
|
+
"Request to FireFlink API timed out for getting the instances details",
|
|
27
25
|
{ cause: error }
|
|
28
26
|
);
|
|
29
27
|
}
|
|
@@ -38,7 +36,7 @@ export class FireFlinkApiService implements IFireFlinkApiService {
|
|
|
38
36
|
}
|
|
39
37
|
|
|
40
38
|
throw new Error(
|
|
41
|
-
"Unexpected error while calling FireFlink API",
|
|
39
|
+
"Unexpected error while calling FireFlink API for getting the instances details",
|
|
42
40
|
{ cause: error }
|
|
43
41
|
);
|
|
44
42
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Producer } from "kafkajs";
|
|
2
|
+
import { IKafkaPayload } from "../../core/interfaces/fireflinkScriptPayloadInterface.js";
|
|
3
|
+
import { logger } from "../../utils/logger/logData.js";
|
|
4
|
+
|
|
5
|
+
export class KafkaProducerService {
|
|
6
|
+
|
|
7
|
+
constructor(private kafkaProducer: Producer) { }
|
|
8
|
+
|
|
9
|
+
async produceMessage(kafkaArgs: IKafkaPayload) {
|
|
10
|
+
try {
|
|
11
|
+
await this.kafkaProducer.connect();
|
|
12
|
+
logger.info("Kafka connected successfully");
|
|
13
|
+
|
|
14
|
+
await this.kafkaProducer.send({
|
|
15
|
+
topic: kafkaArgs.topic,
|
|
16
|
+
messages: [{ value: JSON.stringify(kafkaArgs.message) }],
|
|
17
|
+
});
|
|
18
|
+
await this.kafkaProducer.disconnect()
|
|
19
|
+
logger.info("Kafka produced message successfully and Kafka produced disconnected successfully");
|
|
20
|
+
} catch (error) {
|
|
21
|
+
await this.kafkaProducer.disconnect();
|
|
22
|
+
logger.error("An error occurred and the Kafka producer disconnected without sending the message", error);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -1,65 +1,39 @@
|
|
|
1
1
|
import {
|
|
2
|
-
IPayload,
|
|
3
2
|
IScriptRunner,
|
|
4
|
-
IStep,
|
|
5
3
|
IFireFlinkApiService,
|
|
6
|
-
|
|
4
|
+
IKafkaPayload
|
|
5
|
+
} from "../core/interfaces/fireflinkScriptPayloadInterface.js";
|
|
6
|
+
|
|
7
|
+
import { KafkaProducerService } from "../service/kafka/fireflinkKafka.service.js"
|
|
8
|
+
import { Producer } from "kafkajs";
|
|
7
9
|
|
|
8
10
|
import { logger } from "../utils/logger/logData.js"
|
|
9
11
|
|
|
10
12
|
export class ScriptRunner implements IScriptRunner {
|
|
11
|
-
|
|
13
|
+
private kafkaProducer: KafkaProducerService;
|
|
14
|
+
constructor(private apiService: IFireFlinkApiService,
|
|
15
|
+
private kafkaProducerInstance: Producer,
|
|
16
|
+
) {
|
|
17
|
+
this.kafkaProducer = new KafkaProducerService(this.kafkaProducerInstance)
|
|
12
18
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
19
|
+
}
|
|
20
|
+
async runGetInstancesDetails(
|
|
21
|
+
projectId: string,
|
|
16
22
|
token: string,
|
|
17
23
|
serverHost: string
|
|
18
24
|
): Promise<any> {
|
|
19
|
-
let stepData: IStep[];
|
|
20
|
-
|
|
21
|
-
try {
|
|
22
|
-
stepData =
|
|
23
|
-
typeof result === "string" ? JSON.parse(result) : result;
|
|
24
|
-
|
|
25
|
-
} catch (error) {
|
|
26
|
-
logger.error(`Failed to parse final llm data: ${error}`);
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
logger.info("Sending script payload to FireFlink");
|
|
30
|
-
|
|
31
|
-
const body = {
|
|
32
|
-
stepData: stepData,
|
|
33
|
-
scriptName: payload.scriptName,
|
|
34
|
-
scriptType: payload.scriptType,
|
|
35
|
-
projectId: payload.projectId,
|
|
36
|
-
testCaseId: payload.testCaseId,
|
|
37
|
-
promptId: payload.promptId,
|
|
38
|
-
pageDetails: payload.pageDetails,
|
|
39
|
-
generatedBy: payload.generatedBy,
|
|
40
|
-
webSocketId: payload.webSocketId,
|
|
41
|
-
licenseType: payload.licenseType,
|
|
42
|
-
licenseId: payload.licenseId,
|
|
43
|
-
userId: payload.userId,
|
|
44
|
-
topic: payload.topic,
|
|
45
|
-
projectType: payload.projectType,
|
|
46
|
-
tokensConsumed: payload.tokensConsumed,
|
|
47
|
-
};
|
|
48
|
-
logger.info("PayLoad for Fireflink : ", body)
|
|
49
25
|
const headers = {
|
|
50
26
|
Accept: "*/*",
|
|
51
27
|
"Accept-Language": "en-US,en;q=0.9",
|
|
52
28
|
"Content-Type": "application/json",
|
|
53
|
-
projectId:
|
|
29
|
+
projectId: projectId || "",
|
|
54
30
|
Authorization: `Bearer ${token}`,
|
|
55
31
|
};
|
|
56
32
|
|
|
57
|
-
const url = `${serverHost}/project/optimize/v3/
|
|
58
|
-
|
|
33
|
+
const url = `${serverHost}/project/optimize/v3/ai-service-provider/selected-instance?projectId=${projectId}`;
|
|
59
34
|
try {
|
|
60
|
-
const finalResult = await this.apiService.
|
|
35
|
+
const finalResult = await this.apiService.getInstancesDetailsApi(
|
|
61
36
|
headers,
|
|
62
|
-
JSON.stringify(body),
|
|
63
37
|
url
|
|
64
38
|
);
|
|
65
39
|
if (finalResult) {
|
|
@@ -79,5 +53,12 @@ export class ScriptRunner implements IScriptRunner {
|
|
|
79
53
|
"Failed to submit automation script", { cause: error }
|
|
80
54
|
);
|
|
81
55
|
}
|
|
56
|
+
|
|
57
|
+
}
|
|
58
|
+
async produceMessageToKafka(kafkaArgs: IKafkaPayload) {
|
|
59
|
+
this.kafkaProducer.produceMessage(kafkaArgs)
|
|
60
|
+
|
|
82
61
|
}
|
|
83
62
|
}
|
|
63
|
+
|
|
64
|
+
|