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
|
@@ -5,24 +5,35 @@ import { llmAction } from "../../ai/llmcalls/llmAction.js";
|
|
|
5
5
|
import { ExecutionContext } from "./executionContext.js";
|
|
6
6
|
import { createActionHandlers } from "../../core/main/actionHandlerFactory.js";
|
|
7
7
|
import { StepProcessor } from "./stepProcessor.js";
|
|
8
|
-
import { FireFlinkApiService } from "../../service/fireflinkApi.service.js";
|
|
8
|
+
import { FireFlinkApiService } from "../../service/api/fireflinkApi.service.js";
|
|
9
9
|
import { ScriptRunner } from "../../service/scriptRunner.service.js";
|
|
10
10
|
import { IPayload } from "../interfaces/fireflinkScriptPayloadInterface.js";
|
|
11
11
|
import { PromptType } from "../types/promptType.js";
|
|
12
12
|
import { INPUTLESS_ACTIONS, ELEMENTLESS_ACTION } from "../constants/supportedActions.js";
|
|
13
13
|
import { DomProcessingEngine } from "../../domAnalysis/getRelaventElements.js"
|
|
14
14
|
import { getAnnotatedDOM } from "../../utils/DomExtraction/jsForAttributeInjection.js"
|
|
15
|
+
import { JSDOM } from "jsdom";
|
|
16
|
+
import { getAnnotatedDOMForMobile } from "../../utils/DomExtraction/jsForAttributeInjection.js"
|
|
17
|
+
import { allKeywordAction } from "../constants/allAction.js";
|
|
18
|
+
import { IErrorInfo } from "../interfaces/errorInfoInterface.js";
|
|
19
|
+
import { newTabTracker } from "../../utils/newTab/newTabTracker.js";
|
|
20
|
+
import { generateAnnotatedScreenshots } from "../../imageAnalysisWeb/generateAnnotatedScreenshots.js";
|
|
21
|
+
import { getAiInstanceInfo } from "../../utils/InstancesDetails/getInstancesInfo.js"
|
|
22
|
+
import { isAlertPresent } from "../../utils/alertPopup/isAlertPresent.js";
|
|
23
|
+
import { TOAST_WATCHER_JS } from "../../utils/javascript/jsForToaster.js";
|
|
24
|
+
import { Find_element_by_ff_js_script } from "../../utils/javascript/jsFindElement.js"
|
|
25
|
+
import { getFFIndexAndXPath } from "../../utils/helpers/xpathcreation.js"
|
|
26
|
+
import { platform } from "../types/scriptTypesType.js"
|
|
15
27
|
import { logger } from "../../utils/logger/logData.js"
|
|
28
|
+
import { findXpathFromIndex } from "../../utils/mobileXpath/findXpathFromIndex.js"
|
|
29
|
+
import { sameActionHelper } from "../../utils/helpers/sameActionsHelper.js"
|
|
30
|
+
import { error } from "node:console";
|
|
31
|
+
import { annotateScreenshot } from "../../imageAnalysisMobile/annotatedScreenshotMobile.js";
|
|
32
|
+
import { IKafkaPayload } from "../interfaces/fireflinkScriptPayloadInterface.js"
|
|
16
33
|
export class AutomationRunner implements IAutomationRunner {
|
|
17
34
|
static sessionTerminationDetails: Record<string, boolean> = {};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
private pageLoad: number = 20000,
|
|
21
|
-
private implicit: number = 15000,
|
|
22
|
-
private tokensConsumed: number = 0
|
|
23
|
-
|
|
24
|
-
) { AutomationRunner.sessionTerminationDetails[request.testCaseId] = false }
|
|
25
|
-
|
|
35
|
+
private usedElementNames: string[] = [];
|
|
36
|
+
private KafkaPayload: IKafkaPayload = {} as IKafkaPayload;
|
|
26
37
|
static getSessionTerminationInfo(testCaseId: string): boolean {
|
|
27
38
|
return AutomationRunner.sessionTerminationDetails[testCaseId]
|
|
28
39
|
}
|
|
@@ -35,21 +46,44 @@ export class AutomationRunner implements IAutomationRunner {
|
|
|
35
46
|
domInfo: any,
|
|
36
47
|
extractedRelevantDom: any,
|
|
37
48
|
stepProcessor: StepProcessor,
|
|
38
|
-
scriptRunner: ScriptRunner
|
|
49
|
+
scriptRunner: ScriptRunner,
|
|
50
|
+
request: AutomationRequest,
|
|
51
|
+
platform: platform,
|
|
52
|
+
driver: any
|
|
39
53
|
) {
|
|
40
54
|
try {
|
|
55
|
+
|
|
41
56
|
logger.info("Starting cleanup process...");
|
|
42
|
-
if (context?.session) {
|
|
57
|
+
if ((context?.session) || (context?.androidSession)) {
|
|
43
58
|
try {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
59
|
+
|
|
60
|
+
const platformHandlers: Record<platform, () => Promise<void>> = {
|
|
61
|
+
|
|
62
|
+
android: async () => {
|
|
63
|
+
if (driver?.sessionId) {
|
|
64
|
+
await driver.deleteSession();
|
|
65
|
+
}
|
|
66
|
+
logger.info("Android session deleted successfully");
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
web: async () => {
|
|
70
|
+
logger.info(
|
|
71
|
+
"Still browser session is active, session id :",
|
|
72
|
+
driver.sessionId
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
await (platformHandlers[platform] ?? platformHandlers.web)();
|
|
79
|
+
|
|
80
|
+
} catch {
|
|
81
|
+
logger.error("Browser session is deactivated");
|
|
50
82
|
}
|
|
51
83
|
}
|
|
52
84
|
|
|
85
|
+
|
|
86
|
+
|
|
53
87
|
domInfo = null;
|
|
54
88
|
extractedRelevantDom = null;
|
|
55
89
|
|
|
@@ -57,186 +91,554 @@ export class AutomationRunner implements IAutomationRunner {
|
|
|
57
91
|
(stepProcessor as any).llm = null;
|
|
58
92
|
}
|
|
59
93
|
|
|
60
|
-
scriptRunner = null
|
|
94
|
+
(scriptRunner as any) = null;
|
|
61
95
|
|
|
62
|
-
delete AutomationRunner.sessionTerminationDetails[
|
|
96
|
+
delete AutomationRunner.sessionTerminationDetails[request.testCaseId];
|
|
63
97
|
|
|
64
98
|
if (global.gc) {
|
|
65
99
|
global.gc();
|
|
66
100
|
}
|
|
67
101
|
|
|
68
102
|
logger.info("Cleanup completed successfully.");
|
|
69
|
-
|
|
70
|
-
catch (error) {
|
|
103
|
+
|
|
104
|
+
} catch (error) {
|
|
71
105
|
logger.error("Cleanup error:", error);
|
|
72
106
|
}
|
|
73
107
|
}
|
|
74
108
|
|
|
75
|
-
|
|
76
|
-
|
|
109
|
+
async run(request: AutomationRequest): Promise<void> {
|
|
110
|
+
this.usedElementNames = [];
|
|
111
|
+
AutomationRunner.sessionTerminationDetails[request.testCaseId] = false;
|
|
77
112
|
const apiService = new FireFlinkApiService();
|
|
78
|
-
const scriptRunner = new ScriptRunner(apiService);
|
|
79
|
-
const
|
|
113
|
+
const scriptRunner = new ScriptRunner(apiService, request.kafkaProducerInstance);
|
|
114
|
+
const instanceDetails = await scriptRunner.runGetInstancesDetails(
|
|
115
|
+
request.projectId,
|
|
116
|
+
request.token,
|
|
117
|
+
request.serverHost
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
const aiInfo = getAiInstanceInfo(instanceDetails.responseObject)
|
|
121
|
+
|
|
122
|
+
const context = new ExecutionContext(request);
|
|
123
|
+
|
|
80
124
|
const configProvider = new ServiceProviderBaseUrlProvider();
|
|
81
|
-
const baseUrl = configProvider.getBaseUrl(
|
|
125
|
+
const baseUrl = configProvider.getBaseUrl(aiInfo.serviceProvider);
|
|
82
126
|
let domInfo: any = null;
|
|
83
127
|
let extractedRelevantDom: any = null;
|
|
84
|
-
|
|
128
|
+
let errorInfo: IErrorInfo = {};
|
|
129
|
+
const llm = new llmAction(aiInfo.apiKey, baseUrl, aiInfo.model, aiInfo.visionApiKey);
|
|
130
|
+
let preCapturedDomInfo: any = null;
|
|
85
131
|
const stepProcessor = new StepProcessor(llm);
|
|
86
|
-
|
|
87
|
-
const stepResult = await stepProcessor.getLLMResponse({ type: PromptType.USER_STORY_TO_LIST, args: {}, input: { userStory: this.request.userStory } });
|
|
88
|
-
|
|
132
|
+
const platform = request.platform.toLocaleLowerCase() as platform
|
|
89
133
|
const actionHandlers = createActionHandlers(
|
|
90
134
|
context,
|
|
91
|
-
this.pageLoad,
|
|
92
|
-
this.implicit
|
|
93
135
|
);
|
|
94
136
|
const domProcessor = new DomProcessingEngine();
|
|
95
137
|
let stepCount = 1;
|
|
96
|
-
const listOfSteps =
|
|
138
|
+
const listOfSteps = request.userStory.map(step => String(step));
|
|
139
|
+
let driver: any;
|
|
140
|
+
|
|
97
141
|
if (listOfSteps.length == 0) {
|
|
142
|
+
logger.info(listOfSteps)
|
|
98
143
|
throw new Error("No executable manual steps were returned by the LLM.");
|
|
99
144
|
}
|
|
100
|
-
|
|
101
|
-
logger.info(listOfSteps)
|
|
145
|
+
const start_time = new Date().getTime()
|
|
102
146
|
|
|
103
147
|
for (const step of listOfSteps) {
|
|
104
148
|
try {
|
|
105
|
-
if (AutomationRunner.getSessionTerminationInfo(
|
|
106
|
-
|
|
149
|
+
if (AutomationRunner.getSessionTerminationInfo(request.testCaseId)) { break; }
|
|
150
|
+
logger.info(`Processing step ${stepCount}: ${step}`);
|
|
107
151
|
const start = Math.max(0, stepCount - 3);
|
|
108
152
|
const end = Math.min(listOfSteps.length, stepCount + 3);
|
|
109
153
|
const priorAndNextSteps = listOfSteps.slice(start, end);
|
|
110
|
-
|
|
111
154
|
const result = await stepProcessor.getLLMResponse({
|
|
155
|
+
platform: platform,
|
|
112
156
|
type: PromptType.KEYWORD_EXTRACTOR,
|
|
113
157
|
args: { priorAndNextSteps },
|
|
114
158
|
input: { currentStep: step }
|
|
115
159
|
});
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
(
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
160
|
+
const action = result.response.action;
|
|
161
|
+
|
|
162
|
+
let elementName = result.response.elementName;
|
|
163
|
+
if (elementName) {
|
|
164
|
+
const baseName = elementName;
|
|
165
|
+
let newName = baseName;
|
|
166
|
+
let count = 0;
|
|
167
|
+
while (this.usedElementNames.includes(newName)) {
|
|
168
|
+
count++;
|
|
169
|
+
newName = `${baseName}_${count}`;
|
|
170
|
+
}
|
|
171
|
+
elementName = newName;
|
|
172
|
+
result.response.elementName = elementName;
|
|
173
|
+
this.usedElementNames.push(elementName);
|
|
129
174
|
}
|
|
130
175
|
|
|
176
|
+
if (!allKeywordAction.includes(action)) {
|
|
177
|
+
throw new Error(`Unsupported action at action or keyword exracter: ${action}`);
|
|
178
|
+
}
|
|
179
|
+
let handler = actionHandlers[action];
|
|
131
180
|
if (INPUTLESS_ACTIONS.includes(action)) {
|
|
132
|
-
|
|
181
|
+
logger.info(result.response.keywords)
|
|
182
|
+
await handler({ keywords: result.response.keywords, step: step });
|
|
133
183
|
stepCount++;
|
|
134
184
|
continue;
|
|
135
185
|
}
|
|
136
186
|
|
|
137
|
-
|
|
138
|
-
|
|
187
|
+
let stepResult: any;
|
|
188
|
+
let stepAction: string;
|
|
189
|
+
let fireflinkIndex: string;
|
|
190
|
+
let selector: string;
|
|
191
|
+
let xpath: string;
|
|
192
|
+
let frameAction: string | null = null;
|
|
193
|
+
let iframeDomHtml: string | null = null;
|
|
194
|
+
let doc: any = null;
|
|
195
|
+
let beforeHandles: any = null;
|
|
196
|
+
if (platform == "web") {
|
|
197
|
+
driver = await context.session.getCurrentDriver();
|
|
198
|
+
} else {
|
|
199
|
+
driver = await context.androidSession.getCurrentDriver();
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (await isAlertPresent(driver) && action != "wait") {
|
|
203
|
+
logger.info("Alert is present");
|
|
204
|
+
stepResult = await stepProcessor.getLLMResponse({
|
|
205
|
+
platform: platform,
|
|
139
206
|
type: PromptType.FF_INSPECTOR,
|
|
140
207
|
args: {
|
|
141
208
|
stepAction: action,
|
|
142
|
-
extractedDomJson:
|
|
209
|
+
extractedDomJson: JSON.stringify(extractedRelevantDom, null, 2),
|
|
143
210
|
priorAndNextSteps,
|
|
144
|
-
isAlert:
|
|
211
|
+
isAlert: true,
|
|
145
212
|
isDrag: false
|
|
146
213
|
},
|
|
147
214
|
input: { currentStep: step }
|
|
148
215
|
});
|
|
216
|
+
stepAction = stepResult.response.action;
|
|
149
217
|
|
|
150
|
-
|
|
151
|
-
|
|
218
|
+
handler = actionHandlers[stepAction];
|
|
219
|
+
await handler({
|
|
220
|
+
value: stepResult.response.input_text
|
|
221
|
+
});
|
|
152
222
|
continue;
|
|
153
223
|
}
|
|
224
|
+
else {
|
|
225
|
+
if (preCapturedDomInfo) {
|
|
226
|
+
logger.info("Using pre-captured DOM from previous toaster detection");
|
|
227
|
+
domInfo = preCapturedDomInfo;
|
|
228
|
+
preCapturedDomInfo = null;
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
if (platform === "web") {
|
|
232
|
+
domInfo = await getAnnotatedDOM(driver);
|
|
233
|
+
logger.saveDOM(domInfo.dom, `annotated-dom-${stepCount}`);
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
domInfo = await getAnnotatedDOMForMobile(driver);
|
|
237
|
+
logger.saveDOM(domInfo.dom, `annotated-dom-Mob-${stepCount}`);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const parser = new JSDOM(domInfo.dom);
|
|
242
|
+
doc = parser.window.document;
|
|
243
|
+
|
|
244
|
+
if (platform === "web") {
|
|
245
|
+
extractedRelevantDom = domProcessor.webProcess({
|
|
246
|
+
keywords: result.response.keywords,
|
|
247
|
+
rawDom: domInfo.dom,
|
|
248
|
+
stepCount: stepCount
|
|
249
|
+
});
|
|
250
|
+
logger.saveJSON(extractedRelevantDom, `relevant-dom-${stepCount}`);
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
extractedRelevantDom = domProcessor.mobileProcess({
|
|
254
|
+
keywords: result.response.keywords,
|
|
255
|
+
rawDom: domInfo.dom,
|
|
256
|
+
stepCount: stepCount
|
|
257
|
+
});
|
|
258
|
+
logger.saveJSON(extractedRelevantDom, `relevant-dom-Mob-${stepCount}`);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
if (action == "verify") {
|
|
264
|
+
stepResult = await stepProcessor.getLLMResponse({
|
|
265
|
+
platform: platform,
|
|
266
|
+
type: PromptType.VERIFY_PROMPT,
|
|
267
|
+
args: {
|
|
268
|
+
extractedDomJson: JSON.stringify(extractedRelevantDom, null, 2),
|
|
269
|
+
priorAndNextSteps,
|
|
270
|
+
},
|
|
271
|
+
input: { currentStep: step }
|
|
272
|
+
});
|
|
273
|
+
stepAction = stepResult.response.nlpName;
|
|
274
|
+
}
|
|
275
|
+
else if (action == "get") {
|
|
276
|
+
stepResult = await stepProcessor.getLLMResponse({
|
|
277
|
+
platform: platform,
|
|
278
|
+
type: PromptType.GET_PROMPT,
|
|
279
|
+
args: {
|
|
280
|
+
extractedDomJson: JSON.stringify(extractedRelevantDom, null, 2),
|
|
281
|
+
priorAndNextSteps,
|
|
282
|
+
},
|
|
283
|
+
input: { currentStep: step }
|
|
284
|
+
});
|
|
285
|
+
stepAction = stepResult.response.nlpName;
|
|
286
|
+
}
|
|
287
|
+
else if (action == "wait") {
|
|
288
|
+
stepResult = await stepProcessor.getLLMResponse({
|
|
289
|
+
platform: platform,
|
|
290
|
+
type: PromptType.WAIT_ACTION_EXTRACTOR_PROMPT,
|
|
291
|
+
args: {
|
|
292
|
+
extractedDomJson: JSON.stringify(extractedRelevantDom, null, 2),
|
|
293
|
+
priorAndNextSteps,
|
|
294
|
+
},
|
|
295
|
+
input: { currentStep: step }
|
|
296
|
+
});
|
|
297
|
+
stepAction = stepResult.response.nlpName;
|
|
298
|
+
}
|
|
299
|
+
else if (action == "combined") {
|
|
300
|
+
stepResult = await stepProcessor.getLLMResponse({
|
|
301
|
+
platform: platform,
|
|
302
|
+
type: PromptType.COMBINED_ACTION_EXTRACTOR_PROMPT,
|
|
303
|
+
args: {
|
|
304
|
+
extractedDomJson: JSON.stringify(extractedRelevantDom, null, 2),
|
|
305
|
+
priorAndNextSteps,
|
|
306
|
+
},
|
|
307
|
+
input: { currentStep: step }
|
|
308
|
+
});
|
|
309
|
+
stepAction = stepResult.response.nlpName;
|
|
310
|
+
}
|
|
311
|
+
else if (action == "drag_and_drop") {
|
|
312
|
+
stepResult = await stepProcessor.getLLMResponse({
|
|
313
|
+
platform: platform,
|
|
314
|
+
type: PromptType.FF_INSPECTOR,
|
|
315
|
+
args: {
|
|
316
|
+
extractedDomJson: JSON.stringify(extractedRelevantDom, null, 2),
|
|
317
|
+
priorAndNextSteps,
|
|
318
|
+
isDrag: true,
|
|
319
|
+
isAlert: false
|
|
320
|
+
},
|
|
321
|
+
input: { currentStep: step }
|
|
322
|
+
});
|
|
323
|
+
stepAction = stepResult.response.nlpName;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
else {
|
|
327
|
+
stepResult = await stepProcessor.getLLMResponse({
|
|
328
|
+
platform: platform,
|
|
329
|
+
type: PromptType.FF_INSPECTOR,
|
|
330
|
+
args: {
|
|
331
|
+
stepAction: action,
|
|
332
|
+
extractedDomJson: JSON.stringify(extractedRelevantDom, null, 2),
|
|
333
|
+
priorAndNextSteps,
|
|
334
|
+
isAlert: false,
|
|
335
|
+
isDrag: false
|
|
336
|
+
},
|
|
337
|
+
input: { currentStep: step }
|
|
338
|
+
});
|
|
339
|
+
if (platform == "web") {
|
|
340
|
+
stepAction = stepResult.response.action;
|
|
341
|
+
}
|
|
342
|
+
else {
|
|
343
|
+
stepAction = stepResult.response.nlpName;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
if (platform === "android") {
|
|
348
|
+
stepAction = sameActionHelper[stepAction] || stepAction;
|
|
349
|
+
logger.info(`step action: ${stepAction}`);
|
|
350
|
+
}
|
|
154
351
|
|
|
352
|
+
if (ELEMENTLESS_ACTION.includes(stepAction)) {
|
|
353
|
+
let currentDriver: any = null;
|
|
354
|
+
let beforeHandles: any = null;
|
|
355
|
+
if (platform == "web") {
|
|
356
|
+
currentDriver = await context.session.getCurrentDriver();
|
|
357
|
+
beforeHandles = await currentDriver.getWindowHandles();
|
|
358
|
+
} else {
|
|
359
|
+
currentDriver = await context.androidSession.getCurrentDriver();
|
|
360
|
+
}
|
|
155
361
|
|
|
156
|
-
|
|
157
|
-
domInfo = await getAnnotatedDOM(driver);
|
|
158
|
-
await logger.saveDOM(domInfo.dom, `annotated-dom-${stepCount}`);
|
|
362
|
+
handler = actionHandlers[stepAction];
|
|
159
363
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
364
|
+
await handler({ value: stepResult.response.input_text });
|
|
365
|
+
if ((currentDriver) && (platform == "web")) {
|
|
366
|
+
await newTabTracker(currentDriver, action, beforeHandles, context.scriptAppender);
|
|
367
|
+
}
|
|
368
|
+
stepCount++;
|
|
369
|
+
continue;
|
|
370
|
+
}
|
|
165
371
|
|
|
166
|
-
await logger.saveJSON(extractedRelevantDom, `relevant-dom-${stepCount}`);
|
|
167
|
-
|
|
168
|
-
const stepResult = await stepProcessor.getLLMResponse({
|
|
169
|
-
type: PromptType.FF_INSPECTOR,
|
|
170
|
-
args: {
|
|
171
|
-
stepAction: action,
|
|
172
|
-
extractedDomJson: JSON.stringify(extractedRelevantDom, null, 2),
|
|
173
|
-
priorAndNextSteps,
|
|
174
|
-
isAlert: false,
|
|
175
|
-
isDrag: false
|
|
176
|
-
},
|
|
177
|
-
input: { currentStep: step }
|
|
178
|
-
});
|
|
179
372
|
|
|
180
|
-
|
|
373
|
+
try {
|
|
374
|
+
|
|
375
|
+
fireflinkIndex = stepResult.response.attribute_value;
|
|
376
|
+
if (fireflinkIndex == "Fire-Flink-0") {
|
|
377
|
+
logger.error(`element not found for step "${step}"`);
|
|
378
|
+
throw new Error(`element not found for step "${step}"`, { cause: error });
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
if (platform === "web") {
|
|
382
|
+
const ele = doc.querySelector(
|
|
383
|
+
`[ff-inspect="${fireflinkIndex}"]`
|
|
384
|
+
);
|
|
385
|
+
selector = ele.getAttribute("ff-xpath");
|
|
386
|
+
}
|
|
387
|
+
else {
|
|
388
|
+
selector = await getFFIndexAndXPath(domInfo.dom, fireflinkIndex)
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
if (!selector) {
|
|
392
|
+
logger.info(`Unable to resolve xpath for ${fireflinkIndex}`);
|
|
393
|
+
throw new Error(`Unable to resolve xpath for ${fireflinkIndex}`, { cause: error });
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
if (platform === "web") {
|
|
397
|
+
beforeHandles = await driver.getWindowHandles();
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
if (stepAction == "Builtin_DragAndDropToElement") {
|
|
401
|
+
handler = actionHandlers[stepAction];
|
|
402
|
+
const fireflinkIndex1 = stepResult.response.drag;
|
|
403
|
+
const ele1 = doc.querySelector(`[ff-inspect="${fireflinkIndex1}"]`);
|
|
404
|
+
const selector1 = ele1?.getAttribute("ff-xpath");
|
|
405
|
+
const fireflinkIndex2 = stepResult.response.drop;
|
|
406
|
+
const ele2 = doc.querySelector(`[ff-inspect="${fireflinkIndex2}"]`);
|
|
407
|
+
const selector2 = ele2?.getAttribute("ff-xpath");
|
|
408
|
+
if (!selector2 && !selector1) {
|
|
409
|
+
throw new Error(`Unable to resolve xpath for ${fireflinkIndex2}`);
|
|
410
|
+
}
|
|
411
|
+
else if (fireflinkIndex2 == "Fire-Flink-0" && fireflinkIndex1 == "Fire-Flink-0") {
|
|
412
|
+
throw new Error(`Unable to find element for ${step}`);
|
|
413
|
+
}
|
|
414
|
+
await handler({
|
|
415
|
+
selector1: selector1,
|
|
416
|
+
selector2: selector2,
|
|
417
|
+
fireflinkIndex1: fireflinkIndex1,
|
|
418
|
+
fireflinkIndex2: fireflinkIndex2,
|
|
419
|
+
pageDOM: domInfo.dom,
|
|
420
|
+
elementName1: stepResult.response.drag_element_name,
|
|
421
|
+
elementName2: stepResult.response.drop_element_name,
|
|
422
|
+
elementType1: stepResult.response.drag_element_type,
|
|
423
|
+
elementType2: stepResult.response.drop_element_type
|
|
424
|
+
|
|
425
|
+
});
|
|
426
|
+
continue;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
if (selector.includes("shadow")) {
|
|
431
|
+
stepAction = stepAction + "_shadow";
|
|
432
|
+
logger.info(stepAction);
|
|
433
|
+
}
|
|
434
|
+
else if (selector.includes("iframe")) {
|
|
435
|
+
frameAction = "switchToDefaultContent";
|
|
436
|
+
handler = actionHandlers[frameAction];
|
|
437
|
+
await handler({
|
|
438
|
+
driver: driver,
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
const result_if = await driver.executeAsyncScript(
|
|
442
|
+
Find_element_by_ff_js_script,
|
|
443
|
+
[fireflinkIndex]
|
|
444
|
+
);
|
|
445
|
+
if (!result_if?.success) {
|
|
446
|
+
logger.info("Not found");
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
const { xpath_if, frames, iframe_dom_html } = result_if;
|
|
450
|
+
selector = xpath_if
|
|
451
|
+
iframeDomHtml = iframe_dom_html
|
|
452
|
+
frameAction = "switchToFrame";
|
|
453
|
+
handler = actionHandlers[frameAction];
|
|
454
|
+
await handler({
|
|
455
|
+
selector: selector,
|
|
456
|
+
fireflinkIndex,
|
|
457
|
+
frames: frames,
|
|
458
|
+
elementName: result.response.elementName,
|
|
459
|
+
elementType: stepResult.response.elementType
|
|
460
|
+
});
|
|
461
|
+
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
handler = actionHandlers[stepAction];
|
|
465
|
+
if (iframeDomHtml != null) {
|
|
466
|
+
domInfo = iframeDomHtml
|
|
467
|
+
}
|
|
468
|
+
else {
|
|
469
|
+
domInfo = domInfo.dom
|
|
470
|
+
}
|
|
471
|
+
await handler({
|
|
472
|
+
selector: selector,
|
|
473
|
+
value: stepResult.response.input_text,
|
|
474
|
+
fireflinkIndex,
|
|
475
|
+
pageDOM: domInfo,
|
|
476
|
+
elementName: result.response.elementName,
|
|
477
|
+
elementType: stepResult.response.elementType
|
|
478
|
+
});
|
|
479
|
+
if (platform === "web") {
|
|
480
|
+
if (await isAlertPresent(driver) != true) {
|
|
481
|
+
if (action === "click") {
|
|
482
|
+
await driver.executeScript(TOAST_WATCHER_JS, []);
|
|
483
|
+
|
|
484
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
485
|
+
const postClickToastDetected = await driver.executeScript(
|
|
486
|
+
"return window.__toastDetected === true;",
|
|
487
|
+
[]
|
|
488
|
+
);
|
|
489
|
+
if (postClickToastDetected) {
|
|
490
|
+
logger.info(`Toast detected after click`);
|
|
491
|
+
preCapturedDomInfo = await getAnnotatedDOM(driver);
|
|
492
|
+
logger.saveDOM(preCapturedDomInfo.dom, `toaster-dom-${stepCount}`);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
await newTabTracker(driver, action, beforeHandles, context.scriptAppender);
|
|
497
|
+
|
|
498
|
+
}
|
|
181
499
|
|
|
182
|
-
const fireflinkIndex = stepResult.response.attribute_value;
|
|
183
|
-
const xpath = domInfo.selectors[fireflinkIndex];
|
|
184
500
|
|
|
185
|
-
if (!xpath) {
|
|
186
|
-
throw new Error(`Unable to resolve xpath for ${fireflinkIndex}`);
|
|
187
|
-
}
|
|
188
|
-
else if (fireflinkIndex == "Fire-Flink-0") {
|
|
189
|
-
throw new Error(`Unable to find element for ${step}`);
|
|
190
501
|
}
|
|
502
|
+
catch (error: any) {
|
|
503
|
+
logger.error(`execution failed for step "${step}": ${error.message} and going for vision`);
|
|
504
|
+
try {
|
|
505
|
+
let annotatedScreenshot: any;
|
|
506
|
+
if (platform === "web") {
|
|
507
|
+
annotatedScreenshot = await generateAnnotatedScreenshots(driver);
|
|
508
|
+
}
|
|
509
|
+
else {
|
|
510
|
+
annotatedScreenshot = await annotateScreenshot(driver, domInfo.dom);
|
|
511
|
+
}
|
|
512
|
+
stepResult = await stepProcessor.getLLMResponse({
|
|
513
|
+
platform: platform,
|
|
514
|
+
type: PromptType.VISION_PROMPT,
|
|
515
|
+
args: {
|
|
516
|
+
priorAndNextSteps
|
|
517
|
+
},
|
|
518
|
+
input: { currentStep: step, annotatedScreenshot: annotatedScreenshot }
|
|
519
|
+
});
|
|
520
|
+
fireflinkIndex = stepResult.response.fireflinkIndex;
|
|
521
|
+
logger.info(`fireflinkIndex: ${fireflinkIndex}`);
|
|
522
|
+
if (fireflinkIndex == "Fire-Flink-0") {
|
|
523
|
+
logger.error(`vision unable to find element for step "${step}"`);
|
|
524
|
+
context.scriptAppender.setErrorNLP(stepAction)
|
|
525
|
+
throw new Error(`vision unable to find element for step "${step}"`, { cause: error });
|
|
526
|
+
}
|
|
527
|
+
if (platform == "android") {
|
|
528
|
+
xpath = findXpathFromIndex({
|
|
529
|
+
fireflinkIndex,
|
|
530
|
+
dom: domInfo.dom
|
|
531
|
+
})
|
|
532
|
+
}
|
|
533
|
+
else {
|
|
534
|
+
const ele = doc.querySelector(
|
|
535
|
+
`[ff-inspect="${fireflinkIndex}"]`
|
|
536
|
+
);
|
|
537
|
+
xpath = ele.getAttribute("ff-xpath");
|
|
538
|
+
if (!xpath) {
|
|
539
|
+
logger.info(`Unable to resolve xpath for ${fireflinkIndex}`);
|
|
540
|
+
context.scriptAppender.setErrorNLP(stepAction)
|
|
541
|
+
throw new Error(`Unable to resolve xpath for ${fireflinkIndex}`, { cause: error });
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
if (iframeDomHtml != null) {
|
|
548
|
+
domInfo = iframeDomHtml
|
|
549
|
+
}
|
|
550
|
+
else {
|
|
551
|
+
domInfo = domInfo.dom
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
handler = actionHandlers[stepAction];
|
|
555
|
+
await handler({
|
|
556
|
+
selector: xpath,
|
|
557
|
+
value: stepResult.response.input_text,
|
|
558
|
+
fireflinkIndex,
|
|
559
|
+
pageDOM: domInfo,
|
|
560
|
+
elementName: result.response.elementName,
|
|
561
|
+
elementType: stepResult.response.elementType
|
|
562
|
+
});
|
|
563
|
+
if (await isAlertPresent(driver) != true) {
|
|
564
|
+
|
|
565
|
+
if (action === "click") {
|
|
566
|
+
await driver.executeScript(TOAST_WATCHER_JS, []);
|
|
567
|
+
|
|
568
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
569
|
+
const postClickToastDetected = await driver.executeScript(
|
|
570
|
+
"return window.__toastDetected === true;",
|
|
571
|
+
[]
|
|
572
|
+
);
|
|
573
|
+
if (postClickToastDetected) {
|
|
574
|
+
logger.info(`Toast detected after click`);
|
|
575
|
+
preCapturedDomInfo = await getAnnotatedDOM(driver);
|
|
576
|
+
logger.saveDOM(preCapturedDomInfo.dom, `toaster-dom-${stepCount}`);
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
}
|
|
582
|
+
catch (error: any) {
|
|
583
|
+
logger.error(`vision execution failed for step "${step}": ${error}`);
|
|
584
|
+
throw error;
|
|
585
|
+
}
|
|
191
586
|
|
|
192
|
-
|
|
193
|
-
selector: xpath,
|
|
194
|
-
value: stepResult.response.input_text,
|
|
195
|
-
fireflinkIndex,
|
|
196
|
-
pageDOM: domInfo.dom,
|
|
197
|
-
elementName: result.response.elementName,
|
|
198
|
-
elementType: stepResult.response.elementType
|
|
199
|
-
});
|
|
587
|
+
}
|
|
200
588
|
domInfo = null;
|
|
201
589
|
extractedRelevantDom = null;
|
|
202
590
|
stepCount++;
|
|
203
|
-
await new Promise(resolve => setImmediate(resolve));
|
|
204
591
|
}
|
|
205
|
-
catch (error: any) {
|
|
206
|
-
context.scriptAppender.add({
|
|
207
|
-
nlpName: "CloseBrowser",
|
|
208
|
-
elementsData: [],
|
|
209
|
-
stepInputs: []
|
|
210
|
-
});
|
|
211
592
|
|
|
212
|
-
|
|
593
|
+
catch (error: any) {
|
|
594
|
+
logger.error(`Error executing step "${step}":`, error);
|
|
595
|
+
errorInfo = (await stepProcessor.getLLMResponse({ platform: platform, type: PromptType.ERROR_DESCRIPTION, args: {}, input: { error: logger.getError(error) } })).response;
|
|
596
|
+
if (
|
|
597
|
+
errorInfo.error === "Context Length Exceeded (400)" ||
|
|
598
|
+
errorInfo.error === "Rate Limit Exceeded (429)"
|
|
599
|
+
) {
|
|
600
|
+
break;
|
|
601
|
+
}
|
|
602
|
+
if (context.scriptAppender.getErrorNLP()) { errorInfo.nlp = context.scriptAppender.getErrorNLP() }
|
|
603
|
+
errorInfo.erroredManualStep = step
|
|
604
|
+
errorInfo.rawError = logger.getError(error);
|
|
213
605
|
break;
|
|
214
606
|
}
|
|
215
607
|
}
|
|
608
|
+
logger.info('execution time->', new Date().getTime() - start_time)
|
|
609
|
+
|
|
610
|
+
|
|
611
|
+
|
|
216
612
|
const payload: IPayload = {
|
|
217
|
-
scriptName:
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
613
|
+
scriptName: request.scriptName,
|
|
614
|
+
version: request.version,
|
|
615
|
+
type: request.type,
|
|
616
|
+
scriptType: request.scriptType,
|
|
617
|
+
projectId: request.projectId,
|
|
618
|
+
testCaseId: request.testCaseId,
|
|
619
|
+
promptId: request.promptId,
|
|
620
|
+
pageDetails: request.pageDetails,
|
|
621
|
+
generatedBy: request.generatedBy,
|
|
622
|
+
webSocketId: request.webSocketId,
|
|
623
|
+
licenseType: request.licenseType,
|
|
624
|
+
licenseId: request.licenseId,
|
|
625
|
+
userId: request.userId,
|
|
626
|
+
topic: request.topic,
|
|
627
|
+
projectType: request.projectType,
|
|
230
628
|
tokensConsumed: (await stepProcessor.getResultTokenUsage()).totalTokens,
|
|
629
|
+
errorInfo: errorInfo
|
|
231
630
|
}
|
|
232
631
|
try {
|
|
233
|
-
await
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
632
|
+
await context.scriptAppender.waitForAllSteps()
|
|
633
|
+
this.KafkaPayload.topic = request.topic;
|
|
634
|
+
this.KafkaPayload.message = {
|
|
635
|
+
...payload,
|
|
636
|
+
scriptGenerationData: context.scriptAppender.getData(),
|
|
637
|
+
serverHost: request.serverHost
|
|
638
|
+
};
|
|
639
|
+
await scriptRunner.produceMessageToKafka(this.KafkaPayload)
|
|
239
640
|
} catch (error: any) {
|
|
641
|
+
|
|
240
642
|
throw new Error(
|
|
241
643
|
"Failed to send payload to FireFlink API:", { cause: error }
|
|
242
644
|
);
|
|
@@ -247,7 +649,10 @@ export class AutomationRunner implements IAutomationRunner {
|
|
|
247
649
|
domInfo,
|
|
248
650
|
extractedRelevantDom,
|
|
249
651
|
stepProcessor,
|
|
250
|
-
scriptRunner
|
|
652
|
+
scriptRunner,
|
|
653
|
+
request,
|
|
654
|
+
platform,
|
|
655
|
+
driver
|
|
251
656
|
);
|
|
252
657
|
}
|
|
253
658
|
}
|