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
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
export const JS_PRIMARY = `return (function() {
|
|
2
|
+
|
|
3
|
+
function isReallyVisible(n) {
|
|
4
|
+
const r = n.getBoundingClientRect();
|
|
5
|
+
if (r.width === 0 || r.height === 0) return false;
|
|
6
|
+
|
|
7
|
+
const cx = r.x + r.width / 2;
|
|
8
|
+
const cy = r.y + r.height / 2;
|
|
9
|
+
|
|
10
|
+
let topEl = document.elementFromPoint(cx, cy);
|
|
11
|
+
if (!topEl) return false;
|
|
12
|
+
|
|
13
|
+
return n === topEl || n.contains(topEl);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function isPrimary(n) {
|
|
17
|
+
const tag = n.tagName.toLowerCase();
|
|
18
|
+
const text = (n.innerText || "").trim();
|
|
19
|
+
const style = window.getComputedStyle(n);
|
|
20
|
+
|
|
21
|
+
if (["input", "button", "select", "textarea"].includes(tag))
|
|
22
|
+
return true;
|
|
23
|
+
|
|
24
|
+
if (tag === "label" && text.length > 0)
|
|
25
|
+
return true;
|
|
26
|
+
|
|
27
|
+
if (tag === "a" && text.length > 0)
|
|
28
|
+
return true;
|
|
29
|
+
|
|
30
|
+
if (tag === "li") {
|
|
31
|
+
if (text.length > 0 && style.cursor === "pointer")
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
function getBBox(n) {
|
|
38
|
+
const r = n.getBoundingClientRect();
|
|
39
|
+
return {x:r.x, y:r.y, w:r.width, h:r.height};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function collectShadowAware(root, out) {
|
|
43
|
+
if (!root) return;
|
|
44
|
+
|
|
45
|
+
if (root.nodeType === Node.ELEMENT_NODE && root.hasAttribute("ff-inspect"))
|
|
46
|
+
out.push(root);
|
|
47
|
+
|
|
48
|
+
for (const child of root.children) {
|
|
49
|
+
collectShadowAware(child, out);
|
|
50
|
+
if (child.shadowRoot) collectShadowAware(child.shadowRoot, out);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const all = [];
|
|
55
|
+
collectShadowAware(document.documentElement, all);
|
|
56
|
+
|
|
57
|
+
const out = [];
|
|
58
|
+
|
|
59
|
+
for (let n of all) {
|
|
60
|
+
if (isReallyVisible(n) && isPrimary(n)) {
|
|
61
|
+
out.push({
|
|
62
|
+
ff: n.getAttribute("ff-inspect"),
|
|
63
|
+
xpath: n.getAttribute("ff-xpath"),
|
|
64
|
+
bbox: getBBox(n),
|
|
65
|
+
tag: n.tagName.toLowerCase(),
|
|
66
|
+
text: (n.innerText || "").trim()
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return out;
|
|
72
|
+
})();
|
|
73
|
+
`
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
export const JS_SECONDARY = `return (function() {
|
|
78
|
+
|
|
79
|
+
function isReallyVisible(n) {
|
|
80
|
+
const r = n.getBoundingClientRect();
|
|
81
|
+
if (r.width === 0 || r.height === 0) return false;
|
|
82
|
+
|
|
83
|
+
const cx = r.x + r.width / 2;
|
|
84
|
+
const cy = r.y + r.height / 2;
|
|
85
|
+
|
|
86
|
+
let topEl = document.elementFromPoint(cx, cy);
|
|
87
|
+
if (!topEl) return false;
|
|
88
|
+
|
|
89
|
+
return n === topEl || n.contains(topEl);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function isSecondary(n) {
|
|
93
|
+
const r = n.getBoundingClientRect();
|
|
94
|
+
const tag = n.tagName.toLowerCase();
|
|
95
|
+
const text = (n.innerText || "").trim();
|
|
96
|
+
const style = window.getComputedStyle(n);
|
|
97
|
+
|
|
98
|
+
if (r.y < 120 && text.length > 0 && text.length <= 12)
|
|
99
|
+
return true;
|
|
100
|
+
|
|
101
|
+
if (["div", "span"].includes(tag)) {
|
|
102
|
+
if (text.length > 0 && text.length <= 20 && r.height > 10)
|
|
103
|
+
return true;
|
|
104
|
+
if (style.cursor === "pointer")
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (tag === "li") {
|
|
109
|
+
if (text.length > 0 || style.cursor === "pointer")
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function getBBox(n) {
|
|
117
|
+
const r = n.getBoundingClientRect();
|
|
118
|
+
return {x:r.x, y:r.y, w:r.width, h:r.height};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function collectShadowAware(root, out) {
|
|
122
|
+
if (!root) return;
|
|
123
|
+
|
|
124
|
+
if (root.nodeType === Node.ELEMENT_NODE && root.hasAttribute("ff-inspect"))
|
|
125
|
+
out.push(root);
|
|
126
|
+
|
|
127
|
+
for (const child of root.children) {
|
|
128
|
+
collectShadowAware(child, out);
|
|
129
|
+
if (child.shadowRoot) collectShadowAware(child.shadowRoot, out);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const all = [];
|
|
134
|
+
collectShadowAware(document.documentElement, all);
|
|
135
|
+
|
|
136
|
+
const out = [];
|
|
137
|
+
|
|
138
|
+
for (let n of all) {
|
|
139
|
+
if (isReallyVisible(n) && isSecondary(n)) {
|
|
140
|
+
out.push({
|
|
141
|
+
ff: n.getAttribute("ff-inspect"),
|
|
142
|
+
xpath: n.getAttribute("ff-xpath"),
|
|
143
|
+
bbox: getBBox(n),
|
|
144
|
+
tag: n.tagName.toLowerCase(),
|
|
145
|
+
text: (n.innerText || "").trim()
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return out;
|
|
151
|
+
})();`
|
|
@@ -1,81 +1,160 @@
|
|
|
1
|
-
import fs from "fs";
|
|
1
|
+
import fs from "fs/promises";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import beautify from "js-beautify";
|
|
4
4
|
|
|
5
5
|
const logsDir = path.resolve(process.cwd(), "logs");
|
|
6
6
|
const domDir = path.resolve(process.cwd(), "dom");
|
|
7
|
+
const screenshotsDir = path.resolve(process.cwd(), "screenshots");
|
|
8
|
+
|
|
9
|
+
const now = new Date();
|
|
10
|
+
|
|
11
|
+
const istDate = new Intl.DateTimeFormat("sv-SE", {
|
|
12
|
+
timeZone: "Asia/Kolkata",
|
|
13
|
+
year: "numeric",
|
|
14
|
+
month: "2-digit",
|
|
15
|
+
day: "2-digit",
|
|
16
|
+
hour: "2-digit",
|
|
17
|
+
minute: "2-digit",
|
|
18
|
+
second: "2-digit",
|
|
19
|
+
fractionalSecondDigits: 3,
|
|
20
|
+
hour12: false,
|
|
21
|
+
})
|
|
22
|
+
.format(now)
|
|
23
|
+
.replace(" ", "T");
|
|
7
24
|
|
|
8
|
-
|
|
9
|
-
fs.mkdirSync(logsDir, { recursive: true });
|
|
10
|
-
}
|
|
25
|
+
const logFilePath = path.join(logsDir, "ai-execution-logs.txt");
|
|
11
26
|
|
|
12
|
-
|
|
13
|
-
fs.
|
|
27
|
+
async function ensureDirs() {
|
|
28
|
+
await fs.mkdir(logsDir, { recursive: true });
|
|
29
|
+
await fs.mkdir(domDir, { recursive: true });
|
|
30
|
+
await fs.mkdir(screenshotsDir, { recursive: true });
|
|
14
31
|
}
|
|
15
32
|
|
|
16
|
-
|
|
33
|
+
ensureDirs();
|
|
17
34
|
|
|
18
35
|
export const logger = {
|
|
19
|
-
info: (...args: any[]) => {
|
|
20
|
-
const formattedArgs = args.map(arg =>
|
|
21
|
-
typeof arg === "object"
|
|
22
|
-
? JSON.stringify(arg, null, 2)
|
|
23
|
-
: arg
|
|
36
|
+
info: async (...args: any[]) => {
|
|
37
|
+
const formattedArgs = args.map((arg) =>
|
|
38
|
+
typeof arg === "object" ? JSON.stringify(arg, null, 2) : arg
|
|
24
39
|
);
|
|
25
40
|
|
|
26
|
-
const message = `[INFO] ${
|
|
41
|
+
const message = `[INFO] ${istDate}+05:30 - ${formattedArgs.join(" ")}\n`;
|
|
27
42
|
|
|
28
|
-
fs.
|
|
43
|
+
await fs.appendFile(logFilePath, message, "utf-8");
|
|
29
44
|
},
|
|
30
45
|
|
|
31
|
-
error: (...args: any[]) => {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
: arg
|
|
36
|
-
);
|
|
46
|
+
error: async (...args: any[]) => {
|
|
47
|
+
const formatted = args.map((arg) => {
|
|
48
|
+
if (arg instanceof Error) {
|
|
49
|
+
let output = arg.stack || `${arg.name}: ${arg.message}`;
|
|
37
50
|
|
|
38
|
-
|
|
51
|
+
output = output.replace(
|
|
52
|
+
/invalid session id:\s*invalid session id:/gi,
|
|
53
|
+
"invalid session id:"
|
|
54
|
+
);
|
|
39
55
|
|
|
40
|
-
|
|
41
|
-
|
|
56
|
+
if (arg.cause instanceof Error) {
|
|
57
|
+
let causeStack = arg.cause.stack || "";
|
|
42
58
|
|
|
43
|
-
|
|
59
|
+
causeStack = causeStack.replace(
|
|
60
|
+
/invalid session id:\s*invalid session id:/gi,
|
|
61
|
+
"invalid session id:"
|
|
62
|
+
);
|
|
44
63
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
? `${fileName}.html`
|
|
48
|
-
: `dom-${timestamp}.html`;
|
|
64
|
+
output += `\nCaused by: ${causeStack}`;
|
|
65
|
+
}
|
|
49
66
|
|
|
50
|
-
|
|
67
|
+
return output;
|
|
68
|
+
}
|
|
51
69
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
70
|
+
if (typeof arg === "object") {
|
|
71
|
+
return JSON.stringify(arg, null, 2);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return String(arg);
|
|
56
75
|
});
|
|
57
76
|
|
|
58
|
-
|
|
77
|
+
const message = `[ERROR] ${new Date().toISOString()} - ${formatted.join(
|
|
78
|
+
" "
|
|
79
|
+
)}\n`;
|
|
80
|
+
|
|
81
|
+
await fs.appendFile(logFilePath, message, "utf-8");
|
|
59
82
|
},
|
|
60
83
|
|
|
61
|
-
|
|
62
|
-
const
|
|
84
|
+
getError: (...args: any[]) => {
|
|
85
|
+
const formatted = args.map((arg) => {
|
|
86
|
+
if (arg instanceof Error) {
|
|
87
|
+
let output = arg.stack || `${arg.name}: ${arg.message}`;
|
|
63
88
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
89
|
+
output = output.replace(
|
|
90
|
+
/invalid session id:\s*invalid session id:/gi,
|
|
91
|
+
"invalid session id:"
|
|
92
|
+
);
|
|
67
93
|
|
|
68
|
-
|
|
94
|
+
if (arg.cause instanceof Error) {
|
|
95
|
+
let causeStack = arg.cause.stack || "";
|
|
69
96
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
97
|
+
causeStack = causeStack.replace(
|
|
98
|
+
/invalid session id:\s*invalid session id:/gi,
|
|
99
|
+
"invalid session id:"
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
output += `\nCaused by: ${causeStack}`;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return output;
|
|
106
|
+
}
|
|
75
107
|
|
|
108
|
+
if (typeof arg === "object") {
|
|
109
|
+
return JSON.stringify(arg, null, 2);
|
|
110
|
+
}
|
|
76
111
|
|
|
77
|
-
|
|
112
|
+
return String(arg);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
return formatted.join(" ");
|
|
116
|
+
},
|
|
117
|
+
|
|
118
|
+
saveDOM: async (domContent: string, fileName?: string) => {
|
|
119
|
+
const timestamp = new Date().toLocaleString().replace(/[:.]/g, "-");
|
|
120
|
+
let finalFileName: string;
|
|
121
|
+
let formattedContent: string;
|
|
122
|
+
|
|
123
|
+
if (fileName?.includes("Mob")) {
|
|
124
|
+
finalFileName = fileName ? `${fileName}.xml` : `dom-${timestamp}.xml`;
|
|
125
|
+
formattedContent = domContent;
|
|
126
|
+
} else {
|
|
127
|
+
finalFileName = fileName ? `${fileName}.html` : `dom-${timestamp}.html`;
|
|
128
|
+
formattedContent = beautify.html(domContent, {
|
|
129
|
+
indent_size: 2,
|
|
130
|
+
preserve_newlines: false,
|
|
131
|
+
wrap_line_length: 120,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const filePath = path.join(domDir, finalFileName);
|
|
136
|
+
await fs.writeFile(filePath, formattedContent, "utf-8");
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
saveJSON: async (data: unknown, fileName?: string) => {
|
|
140
|
+
const timestamp = new Date().toLocaleString().replace(/[:.]/g, "-");
|
|
141
|
+
const finalFileName = fileName ? `${fileName}.json` : `data-${timestamp}.json`;
|
|
142
|
+
const filePath = path.join(domDir, finalFileName);
|
|
78
143
|
|
|
144
|
+
const safeData = JSON.stringify(
|
|
145
|
+
data,
|
|
146
|
+
(key, value) => {
|
|
147
|
+
if (key === "element") return undefined; // remove DOM node
|
|
148
|
+
return value;
|
|
149
|
+
},
|
|
150
|
+
2
|
|
151
|
+
);
|
|
79
152
|
|
|
80
|
-
|
|
153
|
+
await fs.writeFile(filePath, safeData, "utf-8");
|
|
154
|
+
},
|
|
81
155
|
|
|
156
|
+
saveImage: async (imageBuffer: Buffer, fileName: string) => {
|
|
157
|
+
const filePath = path.join(screenshotsDir, fileName);
|
|
158
|
+
await fs.writeFile(filePath, imageBuffer);
|
|
159
|
+
},
|
|
160
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import * as cheerio from "cheerio"
|
|
2
|
+
import { IMobileXpathFinder } from "./findXpathFromIndexInterface.js";
|
|
3
|
+
export function findXpathFromIndex(
|
|
4
|
+
args: IMobileXpathFinder
|
|
5
|
+
): string {
|
|
6
|
+
const $ = cheerio.load(args.dom, { xmlMode: true });
|
|
7
|
+
const centers: [number, number][] = [];
|
|
8
|
+
const clickableBoxes: [number, number, number, number][] = [];
|
|
9
|
+
|
|
10
|
+
const traverse = (node: any) => {
|
|
11
|
+
if (node?.type === "tag") {
|
|
12
|
+
const attr = node.attribs;
|
|
13
|
+
if (attr?.bounds) {
|
|
14
|
+
const clickable = attr.clickable === "true";
|
|
15
|
+
const enabled = attr.enabled === "true";
|
|
16
|
+
const clazz = attr.class || "";
|
|
17
|
+
|
|
18
|
+
if (
|
|
19
|
+
(clickable && enabled) ||
|
|
20
|
+
clazz.toLowerCase().includes("edittext") ||
|
|
21
|
+
clazz.toLowerCase().includes("autocompletetextview")
|
|
22
|
+
) {
|
|
23
|
+
const match = attr.bounds.match(/\d+/g);
|
|
24
|
+
if (match && match.length === 4) {
|
|
25
|
+
const x1 = parseInt(match[0]);
|
|
26
|
+
const y1 = parseInt(match[1]);
|
|
27
|
+
const x2 = parseInt(match[2]);
|
|
28
|
+
const y2 = parseInt(match[3]);
|
|
29
|
+
|
|
30
|
+
clickableBoxes.push([x1, y1, x2, y2]);
|
|
31
|
+
centers.push([Math.floor((x1 + x2) / 2), Math.floor((y1 + y2) / 2)]);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (node.children) {
|
|
38
|
+
node.children.forEach(traverse);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
traverse($.root()[0]);
|
|
43
|
+
|
|
44
|
+
const index = Number(args.fireflinkIndex.split("-").pop());
|
|
45
|
+
|
|
46
|
+
if (isNaN(index) || index < 1 || index > centers.length) {
|
|
47
|
+
throw new Error(`Index ${index} out of range (Total clickable items: ${centers.length})`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const [x1, y1, x2, y2] = clickableBoxes[index - 1];
|
|
51
|
+
const boundsStr = `[${x1},${y1}][${x2},${y2}]`;
|
|
52
|
+
|
|
53
|
+
const element = $(`[bounds="${boundsStr}"]`).first();
|
|
54
|
+
|
|
55
|
+
if (!element.length) {
|
|
56
|
+
throw new Error(`Element with bounds ${boundsStr} not found`);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return getXPath(element);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function getXPath(element: cheerio.Cheerio<any>): string {
|
|
63
|
+
|
|
64
|
+
let xpath = ""
|
|
65
|
+
let current: any = element
|
|
66
|
+
|
|
67
|
+
while (current.length && current[0].tagName !== "hierarchy") {
|
|
68
|
+
|
|
69
|
+
const tag = current[0].tagName
|
|
70
|
+
|
|
71
|
+
const siblings = current.parent().children(tag)
|
|
72
|
+
|
|
73
|
+
if (siblings.length > 1) {
|
|
74
|
+
|
|
75
|
+
const index = siblings.index(current) + 1
|
|
76
|
+
xpath = `/${tag}[${index}]` + xpath
|
|
77
|
+
|
|
78
|
+
} else {
|
|
79
|
+
|
|
80
|
+
xpath = `/${tag}` + xpath
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
current = current.parent()
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return `/hierarchy${xpath}`
|
|
87
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { ScriptDataAppender } from "../../fireflinkData/fireflinkScript/scriptGenrationData.js";
|
|
2
|
+
|
|
3
|
+
export async function newTabTracker(
|
|
4
|
+
driver: WebdriverIO.Browser,
|
|
5
|
+
stepAction: string,
|
|
6
|
+
previousHandles: string[],
|
|
7
|
+
scriptAppender: ScriptDataAppender
|
|
8
|
+
): Promise<void> {
|
|
9
|
+
|
|
10
|
+
if (stepAction === "switch") return;
|
|
11
|
+
|
|
12
|
+
const currentHandle = await driver.getWindowHandle();
|
|
13
|
+
const currentHandles = await driver.getWindowHandles();
|
|
14
|
+
|
|
15
|
+
if (currentHandles.length <= previousHandles.length) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const newHandles = currentHandles.filter(
|
|
20
|
+
handle => !previousHandles.includes(handle)
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
for (const handle of newHandles) {
|
|
24
|
+
try {
|
|
25
|
+
await driver.switchToWindow(handle);
|
|
26
|
+
|
|
27
|
+
const url = await driver.getUrl();
|
|
28
|
+
|
|
29
|
+
// Skip unwanted system URLs
|
|
30
|
+
if (
|
|
31
|
+
!url ||
|
|
32
|
+
url.startsWith("devtools://") ||
|
|
33
|
+
url.startsWith("chrome://") ||
|
|
34
|
+
url === "about:blank"
|
|
35
|
+
) {
|
|
36
|
+
await driver.switchToWindow(currentHandle);
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Valid URL → accept it
|
|
41
|
+
scriptAppender.add(async () => ({
|
|
42
|
+
nlpName: "SwitchToWindowBasedOnURL",
|
|
43
|
+
stepInputs: [url],
|
|
44
|
+
elementsData: []
|
|
45
|
+
}));
|
|
46
|
+
|
|
47
|
+
return;
|
|
48
|
+
|
|
49
|
+
} catch (error) {
|
|
50
|
+
// Restore original window before failing
|
|
51
|
+
await driver.switchToWindow(currentHandle);
|
|
52
|
+
|
|
53
|
+
throw new Error(
|
|
54
|
+
`Error switching to new window: ${error}`,
|
|
55
|
+
{ cause: error }
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// If no valid window found, ensure we are back on original
|
|
61
|
+
await driver.switchToWindow(currentHandle);
|
|
62
|
+
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { ClickInterface } from "../interface/interactionActionInterface.js";
|
|
2
|
-
export async function click(args: ClickInterface): Promise<void> {
|
|
3
|
-
try {
|
|
4
|
-
const element = await args.driver.$(args.selector);
|
|
5
|
-
await element.scrollIntoView({ block: 'center', inline: 'center' });
|
|
6
|
-
await element.click();
|
|
7
|
-
const ffElement: any = await args.elementGetter.getFireFlinkElement(
|
|
8
|
-
args.pageDOM,
|
|
9
|
-
`[ff-inspect="${args.fireflinkIndex}"]`
|
|
10
|
-
);
|
|
11
|
-
args.scriptDataAppender.add(
|
|
12
|
-
{
|
|
13
|
-
nlpName: 'Click',
|
|
14
|
-
stepInputs: [],
|
|
15
|
-
elementsData: [{
|
|
16
|
-
elementName: args.elementName,
|
|
17
|
-
type: args.elementType,
|
|
18
|
-
locators: ffElement.locators,
|
|
19
|
-
platform: args.platform
|
|
20
|
-
}]
|
|
21
|
-
});
|
|
22
|
-
} catch (error: any) {
|
|
23
|
-
throw new Error("Click action failed", { cause: error });
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { EnterInputInterface } from "../interface/interactionActionInterface.js";
|
|
2
|
-
import { enterActionHelper } from "../../../utils/helpers/enterActionHelper.js";
|
|
3
|
-
export async function enterInput(args: EnterInputInterface): Promise<void> {
|
|
4
|
-
|
|
5
|
-
try {
|
|
6
|
-
|
|
7
|
-
const { ffNumber, xpathPath } = enterActionHelper(
|
|
8
|
-
args.pageDOM,
|
|
9
|
-
args.fireflinkIndex
|
|
10
|
-
);
|
|
11
|
-
|
|
12
|
-
const element = await args.driver.$(xpathPath);
|
|
13
|
-
await element.scrollIntoView({ block: 'center', inline: 'center' });
|
|
14
|
-
await element.setValue(args.value);
|
|
15
|
-
const ffElement: any = await args.elementGetter.getFireFlinkElement(
|
|
16
|
-
args.pageDOM,
|
|
17
|
-
`[ff-inspect="Fire-Flink-${ffNumber}"]`
|
|
18
|
-
);
|
|
19
|
-
args.scriptDataAppender.add({
|
|
20
|
-
nlpName: 'SendKeys',
|
|
21
|
-
stepInputs: [args.value],
|
|
22
|
-
elementsData: [{
|
|
23
|
-
elementName: args.elementName,
|
|
24
|
-
type: args.elementType,
|
|
25
|
-
locators: ffElement.locators,
|
|
26
|
-
platform: args.platform
|
|
27
|
-
}]
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
catch (error: any) {
|
|
32
|
-
console.log(error);
|
|
33
|
-
throw new Error("enter action failed", { cause: error });
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { getTitleInterface } from "../interface/navigationActionInterface.js";
|
|
2
|
-
export async function getTitle(args: getTitleInterface): Promise<void> {
|
|
3
|
-
try {
|
|
4
|
-
const title = await args.driver.getTitle();
|
|
5
|
-
args.scriptDataAppender.add({ nlpName: 'getTitle', elementsData: [], stepInputs: [title] });
|
|
6
|
-
} catch (error: any) {
|
|
7
|
-
throw new Error("Get title action failed", { cause: error });
|
|
8
|
-
}
|
|
9
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { goBackInterface } from "../interface/navigationActionInterface.js";
|
|
2
|
-
export async function goBack(args: goBackInterface): Promise<void> {
|
|
3
|
-
try {
|
|
4
|
-
await args.driver.back();
|
|
5
|
-
args.scriptDataAppender.add({ nlpName: 'goBack', elementsData: [], stepInputs: [] });
|
|
6
|
-
} catch (error: any) {
|
|
7
|
-
throw new Error("Navigate action failed", { cause: error });
|
|
8
|
-
}
|
|
9
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { navigateToUrlInterface } from "../interface/navigationActionInterface.js";
|
|
2
|
-
export async function navigate(args: navigateToUrlInterface): Promise<void> {
|
|
3
|
-
try {
|
|
4
|
-
await args.driver.url(args.url);
|
|
5
|
-
args.scriptDataAppender.add({ nlpName: 'NavigateToURL', elementsData: [], stepInputs: [args.url] });
|
|
6
|
-
|
|
7
|
-
} catch (error: any) {
|
|
8
|
-
throw new Error("Navigate action failed", { cause: error });
|
|
9
|
-
}
|
|
10
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { refreshInterface } from "../interface/navigationActionInterface.js";
|
|
2
|
-
export async function pageRefresh(args: refreshInterface): Promise<void> {
|
|
3
|
-
try {
|
|
4
|
-
await args.driver.refresh();
|
|
5
|
-
args.scriptDataAppender.add({ nlpName: 'refresh', elementsData: [], stepInputs: [] });
|
|
6
|
-
} catch (error: any) {
|
|
7
|
-
throw new Error("Refresh action failed", { cause: error });
|
|
8
|
-
}
|
|
9
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { waitInterface } from "../interface/waitActionInterface.js";
|
|
2
|
-
export async function wait(args: waitInterface): Promise<void> {
|
|
3
|
-
try {
|
|
4
|
-
await args.driver.pause(Number(args.time) * 1000);
|
|
5
|
-
args.scriptDataAppender.add({ nlpName: 'Sleep', elementsData: [], stepInputs: [args.time] });
|
|
6
|
-
|
|
7
|
-
} catch (error: any) {
|
|
8
|
-
throw new Error("Navigate action failed", { cause: error });
|
|
9
|
-
}
|
|
10
|
-
}
|