ff-automationv2 2.1.3 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env +1 -0
- package/.husky/pre-commit +5 -0
- package/ARCHITECTURE.md +6 -3
- package/Note.md +7 -0
- package/RELEASE_GUIDE.md +1 -1
- package/bitbucket-pipelines.yml +4 -25
- package/eslint.config.ts +4 -0
- package/package.json +21 -9
- package/src/ai/llmcalls/decodeApiKey.ts +1 -1
- package/src/ai/llmcalls/llmAction.ts +154 -47
- package/src/ai/llmprompts/llmPromptTypes/systemPromptTypes.ts +45 -0
- package/src/ai/llmprompts/promptRegistry.ts +34 -8
- package/src/ai/llmprompts/systemPrompts/actionExtractorPrompt.ts +4 -7
- package/src/ai/llmprompts/systemPrompts/combinedActionExtractorPrompt.ts +41 -0
- package/src/ai/llmprompts/systemPrompts/combinedActionExtractorPromptMob.ts +53 -0
- package/src/ai/llmprompts/systemPrompts/errorDescriptionPrompt.ts +43 -14
- package/src/ai/llmprompts/systemPrompts/fireflinkElementIndexExtactors.ts +111 -36
- package/src/ai/llmprompts/systemPrompts/fireflinkElementIndexExtractor_Mob.ts +53 -0
- package/src/ai/llmprompts/systemPrompts/getActionExtractorPrompt.ts +62 -0
- package/src/ai/llmprompts/systemPrompts/getActionExtractorPromptMob.ts +54 -0
- package/src/ai/llmprompts/systemPrompts/mobileKeywordExtractor.ts +39 -0
- package/src/ai/llmprompts/systemPrompts/userStoryToListPrompt.ts +48 -11
- package/src/ai/llmprompts/systemPrompts/verifyActionExtractorPrompt.ts +82 -0
- package/src/ai/llmprompts/systemPrompts/verifyActionExtractorPromptMob.ts +58 -0
- package/src/ai/llmprompts/systemPrompts/visionPrompt.ts +8 -14
- package/src/ai/llmprompts/systemPrompts/visionPromptMobile.ts +25 -0
- package/src/ai/llmprompts/systemPrompts/waitActionExtractorPrompt.ts +65 -0
- package/src/ai/llmprompts/systemPrompts/waitActionExtractorPromptMob.ts +45 -0
- package/src/ai/llmprompts/userPrompts/userPrompt.ts +28 -4
- package/src/automation/actions/executor.ts +4478 -48
- package/src/automation/actions/interaction/alert/clickCancelOnAlertPopup.ts +21 -0
- package/src/automation/actions/interaction/alert/clickOkOnAlertPopup.ts +20 -0
- package/src/automation/actions/interaction/alert/enterDataToAlert.ts +20 -0
- package/src/automation/actions/interaction/alert/getTextPresentOnAlertPopup.ts +19 -0
- package/src/automation/actions/interaction/alert/verifyAlertPopUpMessageContainsString.ts +32 -0
- package/src/automation/actions/interaction/alert/verifyAlertPopupIsDisplayed.ts +19 -0
- package/src/automation/actions/interaction/alert/verifyTextPresentOnAlertPopup.ts +33 -0
- package/src/automation/actions/interaction/alert/waitTillAlertIsPresent.ts +25 -0
- package/src/automation/actions/interaction/clear/clear.ts +61 -0
- package/src/automation/actions/interaction/clear/clearAndEnter.ts +58 -0
- package/src/automation/actions/interaction/click/click.ts +61 -0
- package/src/automation/actions/interaction/click/clickNtimes.ts +67 -0
- package/src/automation/actions/interaction/click/clickUsingJs.ts +33 -0
- package/src/automation/actions/interaction/click/doubleClick.ts +66 -0
- package/src/automation/actions/interaction/click/rightClick.ts +29 -0
- package/src/automation/actions/interaction/click/waitAndClick.ts +83 -0
- package/src/automation/actions/interaction/dragAndDrop/dragAndDrop.ts +46 -0
- package/src/automation/actions/interaction/enterActions/enterInput.ts +81 -0
- package/src/automation/actions/interaction/enterActions/enterInputAndPress.ts +134 -0
- package/src/automation/actions/interaction/enterActions/enterUrl.ts +52 -0
- package/src/automation/actions/interaction/enterActions/enterusingJs.ts +41 -0
- package/src/automation/actions/interaction/enterActions/waitAndEnter.ts +106 -0
- package/src/automation/actions/interaction/find/findElements.ts +57 -0
- package/src/automation/actions/interaction/get/browserWindowGetPosition.ts +15 -0
- package/src/automation/actions/interaction/get/getAllBrokenImages.ts +16 -0
- package/src/automation/actions/interaction/get/getAllBrokenLinkCount.ts +17 -0
- package/src/automation/actions/interaction/get/getAllBrokenLinks.ts +16 -0
- package/src/automation/actions/interaction/get/getAllConsoleErrors.ts +16 -0
- package/src/automation/actions/interaction/get/getAllConsoleInformation.ts +16 -0
- package/src/automation/actions/interaction/get/getAllConsoleLogs.ts +16 -0
- package/src/automation/actions/interaction/get/getAllConsoleWarnings.ts +18 -0
- package/src/automation/actions/interaction/get/getAllCookieNames.ts +16 -0
- package/src/automation/actions/interaction/get/getAllCookieValues.ts +16 -0
- package/src/automation/actions/interaction/get/getAllSelectedOptions.ts +43 -0
- package/src/automation/actions/interaction/get/getAllTheOptionsFromListBoxAsText.ts +46 -0
- package/src/automation/actions/interaction/get/getAllTheOptionsFromListBoxAsTextInSortedOrder.ts +54 -0
- package/src/automation/actions/interaction/get/getAllTheSelectedOptionsFromListBoxAsText.ts +43 -0
- package/src/automation/actions/interaction/get/getAllWindowHandles.ts +18 -0
- package/src/automation/actions/interaction/get/getAttribute.ts +83 -0
- package/src/automation/actions/interaction/get/getAudioCurrentPlaybackRate.ts +35 -0
- package/src/automation/actions/interaction/get/getAudioCurrentSeekTime.ts +36 -0
- package/src/automation/actions/interaction/get/getAudioCurrentVolume.ts +36 -0
- package/src/automation/actions/interaction/get/getAudioDecodedByte.ts +43 -0
- package/src/automation/actions/interaction/get/getAudioDefaultPlaybackRate.ts +36 -0
- package/src/automation/actions/interaction/get/getAudioDimension.ts +43 -0
- package/src/automation/actions/interaction/get/getAudioHeight.ts +38 -0
- package/src/automation/actions/interaction/get/getAudioMediaLength.ts +34 -0
- package/src/automation/actions/interaction/get/getAudioMediaSource.ts +44 -0
- package/src/automation/actions/interaction/get/getAudioWidth.ts +38 -0
- package/src/automation/actions/interaction/get/getBestPracticesScore.ts +20 -0
- package/src/automation/actions/interaction/get/getBrowserCount.ts +17 -0
- package/src/automation/actions/interaction/get/getBrowserVersion.ts +16 -0
- package/src/automation/actions/interaction/get/getCapabilityNames.ts +18 -0
- package/src/automation/actions/interaction/get/getClipBoardText.ts +16 -0
- package/src/automation/actions/interaction/get/getCollectiveApiResponseTime.ts +27 -0
- package/src/automation/actions/interaction/get/getCollectiveApiStatusCode.ts +29 -0
- package/src/automation/actions/interaction/get/getCssValue.ts +38 -0
- package/src/automation/actions/interaction/get/getCurrentDayOfTheWeek.ts +18 -0
- package/src/automation/actions/interaction/get/getCurrentSecondsFromCurrentSystemTime.ts +19 -0
- package/src/automation/actions/interaction/get/getCurrentSystemDate.ts +18 -0
- package/src/automation/actions/interaction/get/getCurrentSystemDay.ts +16 -0
- package/src/automation/actions/interaction/get/getCurrentSystemMonth.ts +16 -0
- package/src/automation/actions/interaction/get/getCurrentSystemTime.ts +18 -0
- package/src/automation/actions/interaction/get/getCurrentSystemYear.ts +18 -0
- package/src/automation/actions/interaction/get/getCurrentWindowHandle.ts +36 -0
- package/src/automation/actions/interaction/get/getDataFromApiRequestHeaderForJsonPath.ts +21 -0
- package/src/automation/actions/interaction/get/getDataFromApiResponseForJsonPath.ts +21 -0
- package/src/automation/actions/interaction/get/getDateWithGivenFormat.ts +35 -0
- package/src/automation/actions/interaction/get/getDriverInstance.ts +35 -0
- package/src/automation/actions/interaction/get/getFirstContentfulPaint.ts +16 -0
- package/src/automation/actions/interaction/get/getFirstSelectedOption.ts +44 -0
- package/src/automation/actions/interaction/get/getFullPaintTime.ts +16 -0
- package/src/automation/actions/interaction/get/getHTMLCodeOfPage.ts +18 -0
- package/src/automation/actions/interaction/get/getHeightOfBrowserWindow.ts +18 -0
- package/src/automation/actions/interaction/get/getHeightOfWebElement.ts +36 -0
- package/src/automation/actions/interaction/get/getHourFromCurrentSystemTime.ts +18 -0
- package/src/automation/actions/interaction/get/getImplicitTimeOut.ts +36 -0
- package/src/automation/actions/interaction/get/getLargestContentfulPaint.ts +16 -0
- package/src/automation/actions/interaction/get/getListBoxSize.ts +41 -0
- package/src/automation/actions/interaction/get/getListOfElementsFromLocatorTypeLocatorValue.ts +63 -0
- package/src/automation/actions/interaction/get/getLocation.ts +68 -0
- package/src/automation/actions/interaction/get/getMinuteFromCurrentSystemTime.ts +18 -0
- package/src/automation/actions/interaction/get/getNetworkRouteTime.ts +16 -0
- package/src/automation/actions/interaction/get/getNumberOfBrokenImages.ts +16 -0
- package/src/automation/actions/interaction/get/getNumberOfLinksPresentInCurrentPage.ts +18 -0
- package/src/automation/actions/interaction/get/getNumberOfWorkingLinksFromCurrentPage.ts +15 -0
- package/src/automation/actions/interaction/get/getOptions.ts +35 -0
- package/src/automation/actions/interaction/get/getPageTitle.ts +18 -0
- package/src/automation/actions/interaction/get/getPerformanceMetrics.ts +15 -0
- package/src/automation/actions/interaction/get/getPwaScore.ts +20 -0
- package/src/automation/actions/interaction/get/getRect.ts +87 -0
- package/src/automation/actions/interaction/get/getScreenshot.ts +41 -0
- package/src/automation/actions/interaction/get/getScreenshotAs.ts +64 -0
- package/src/automation/actions/interaction/get/getSeoScore.ts +20 -0
- package/src/automation/actions/interaction/get/getSingleApiRequestPayload.ts +22 -0
- package/src/automation/actions/interaction/get/getSingleApiResponse.ts +30 -0
- package/src/automation/actions/interaction/get/getSingleApiResponseTime.ts +28 -0
- package/src/automation/actions/interaction/get/getSingleApiStatusCode.ts +32 -0
- package/src/automation/actions/interaction/get/getSize.ts +68 -0
- package/src/automation/actions/interaction/get/getSizeOfBrowserWindow.ts +17 -0
- package/src/automation/actions/interaction/get/getStringDataFromLocalFile.ts +25 -0
- package/src/automation/actions/interaction/get/getSystemProperty.ts +46 -0
- package/src/automation/actions/interaction/get/getTagName.ts +67 -0
- package/src/automation/actions/interaction/get/getText.ts +68 -0
- package/src/automation/actions/interaction/get/getTheFirstSelectedOptionFromListBoxAsText.ts +44 -0
- package/src/automation/actions/interaction/get/getTotalNumberOfCookies.ts +16 -0
- package/src/automation/actions/interaction/get/getTunnelIdentifier.ts +25 -0
- package/src/automation/actions/interaction/get/getURLPresentInAddressBar.ts +18 -0
- package/src/automation/actions/interaction/get/getUserHomeDirectory.ts +16 -0
- package/src/automation/actions/interaction/get/getValueByCookieName.ts +27 -0
- package/src/automation/actions/interaction/get/getValueFromLocalStorage.ts +26 -0
- package/src/automation/actions/interaction/get/getValueOfSystemVariable.ts +20 -0
- package/src/automation/actions/interaction/get/getVideoCurrentPlaybackRate.ts +36 -0
- package/src/automation/actions/interaction/get/getVideoCurrentSeekTime.ts +36 -0
- package/src/automation/actions/interaction/get/getVideoCurrentVolume.ts +36 -0
- package/src/automation/actions/interaction/get/getVideoDecodedByte.ts +52 -0
- package/src/automation/actions/interaction/get/getVideoDefaultPlaybackRate.ts +36 -0
- package/src/automation/actions/interaction/get/getVideoDimension.ts +40 -0
- package/src/automation/actions/interaction/get/getVideoHeight.ts +36 -0
- package/src/automation/actions/interaction/get/getVideoMediaLength.ts +36 -0
- package/src/automation/actions/interaction/get/getVideoMediaSource.ts +46 -0
- package/src/automation/actions/interaction/get/getVideoWidth.ts +36 -0
- package/src/automation/actions/interaction/get/getWidthOfBrowser.ts +18 -0
- package/src/automation/actions/interaction/get/getWidthOfWebElement.ts +36 -0
- package/src/automation/actions/interaction/get/getWorkingLinksFromCurrentPage.ts +16 -0
- package/src/automation/actions/interaction/get/getWrappedElement.ts +36 -0
- package/src/automation/actions/interaction/get/getWrappedOptionFromListBoxAsText.ts +47 -0
- package/src/automation/actions/interaction/get/getXLocationOfBrowserWindow.ts +18 -0
- package/src/automation/actions/interaction/get/getXLocationOfWebElement.ts +71 -0
- package/src/automation/actions/interaction/get/getYLocationOfBrowserWindow.ts +18 -0
- package/src/automation/actions/interaction/get/getYLocationOfWebElement.ts +70 -0
- package/src/automation/actions/interaction/iframe/switchToDefaultContent.ts +15 -0
- package/src/automation/actions/interaction/maximize/maximize.ts +15 -0
- package/src/automation/actions/interaction/maximize/minimize.ts +17 -0
- package/src/automation/actions/interaction/navigation/goBack.ts +14 -0
- package/src/automation/actions/interaction/navigation/navigate.ts +16 -0
- package/src/automation/actions/interaction/navigation/refresh.ts +14 -0
- package/src/automation/actions/interaction/press/mobPressBackKey.ts +19 -0
- package/src/automation/actions/interaction/press/pressAnyKey.ts +89 -0
- package/src/automation/actions/interaction/press/pressAnyKeyNTimes.ts +100 -0
- package/src/automation/actions/interaction/press/pressEnterKey.ts +45 -0
- package/src/automation/actions/interaction/scroll/scrollHorizontallyTillElementIsVisible.ts +29 -0
- package/src/automation/actions/interaction/scroll/scrollPageToSpecificLocation.ts +37 -0
- package/src/automation/actions/interaction/scroll/scrollToElement.ts +28 -0
- package/src/automation/actions/interaction/scroll/scrollVerticallyTillElementIsVisible.ts +29 -0
- package/src/automation/actions/interaction/set/setClipBoardText.ts +46 -0
- package/src/automation/actions/interaction/shadowDom/shadowDomClick.ts +25 -0
- package/src/automation/actions/interaction/shadowDom/shadowDomEnter.ts +27 -0
- package/src/automation/actions/interaction/shadowDom/shadowDomGetText.ts +28 -0
- package/src/automation/actions/interaction/shadowDom/shadowDomUpload.ts +37 -0
- package/src/automation/actions/interaction/shadowDom/shadowDomVerifyPartialText.ts +29 -0
- package/src/automation/actions/interaction/shadowDom/shadowDomVerifyText.ts +22 -0
- package/src/automation/actions/interaction/switch/switchToNewTabBasedOnTitle.ts +16 -0
- package/src/automation/actions/interaction/switch/switchToNewWindowBasedOnTitle.ts +16 -0
- package/src/automation/actions/interaction/switch/switchToParentWindow.ts +19 -0
- package/src/automation/actions/interaction/switch/switchToTabBasedOnUrl.ts +16 -0
- package/src/automation/actions/interaction/switch/switchToWindowBasedOnURL.ts +16 -0
- package/src/automation/actions/interaction/switch/switchToWindowIfTitleContainsString.ts +18 -0
- package/src/automation/actions/interaction/switch/switchToWindowIfUrlContainsString.ts +18 -0
- package/src/automation/actions/interaction/upload/uploadfile.ts +41 -0
- package/src/automation/actions/interaction/verify/VerifyAccessibilityScore.ts +90 -0
- package/src/automation/actions/interaction/verify/VerifyAllBrokenImages.ts +54 -0
- package/src/automation/actions/interaction/verify/VerifyAllBrowserWindowsClosed.ts +27 -0
- package/src/automation/actions/interaction/verify/VerifyAllOptionsAreDeSelected.ts +55 -0
- package/src/automation/actions/interaction/verify/VerifyAllOptionsAreSelected.ts +66 -0
- package/src/automation/actions/interaction/verify/VerifyAttributeValue.ts +96 -0
- package/src/automation/actions/interaction/verify/VerifyBestPracticesScore.ts +87 -0
- package/src/automation/actions/interaction/verify/VerifyBrowserHtmlCodeContainsString.ts +35 -0
- package/src/automation/actions/interaction/verify/VerifyBrowserWindowHeight.ts +35 -0
- package/src/automation/actions/interaction/verify/VerifyBrowserWindowTitleContainsString.ts +31 -0
- package/src/automation/actions/interaction/verify/VerifyBrowserWindowTitleIsString.ts +30 -0
- package/src/automation/actions/interaction/verify/VerifyBrowserWindowUrlContainsExpectedUrl.ts +30 -0
- package/src/automation/actions/interaction/verify/VerifyBrowserWindowUrlIsString.ts +30 -0
- package/src/automation/actions/interaction/verify/VerifyBrowserWindowWidth.ts +35 -0
- package/src/automation/actions/interaction/verify/VerifyBrowserWindowXLocation.ts +36 -0
- package/src/automation/actions/interaction/verify/VerifyBrowserWindowYLocation.ts +35 -0
- package/src/automation/actions/interaction/verify/VerifyCheckBoxIsNotSelected.ts +46 -0
- package/src/automation/actions/interaction/verify/VerifyCheckBoxIsSelected.ts +43 -0
- package/src/automation/actions/interaction/verify/VerifyCssAttributeValue.ts +62 -0
- package/src/automation/actions/interaction/verify/VerifyElementIsClickable.ts +86 -0
- package/src/automation/actions/interaction/verify/VerifyElementIsDisabled.ts +91 -0
- package/src/automation/actions/interaction/verify/VerifyElementIsDisplayed.ts +87 -0
- package/src/automation/actions/interaction/verify/VerifyElementIsEnabled.ts +87 -0
- package/src/automation/actions/interaction/verify/VerifyElementIsNotDisplayed.ts +45 -0
- package/src/automation/actions/interaction/verify/VerifyElementIsSelected.ts +83 -0
- package/src/automation/actions/interaction/verify/VerifyElementNotContainsText.ts +129 -0
- package/src/automation/actions/interaction/verify/VerifyHeightOfWebElement.ts +101 -0
- package/src/automation/actions/interaction/verify/VerifyHexCodeForGivenXYCoordinates.ts +51 -0
- package/src/automation/actions/interaction/verify/VerifyIfAllCookiesAreDeleted.ts +27 -0
- package/src/automation/actions/interaction/verify/VerifyIfAudioEnded.ts +48 -0
- package/src/automation/actions/interaction/verify/VerifyIfAudioIsMuted.ts +48 -0
- package/src/automation/actions/interaction/verify/VerifyIfAudioIsPaused.ts +48 -0
- package/src/automation/actions/interaction/verify/VerifyIfAudioIsPlaying.ts +57 -0
- package/src/automation/actions/interaction/verify/VerifyIfBrowserWindowIsClosed.ts +27 -0
- package/src/automation/actions/interaction/verify/VerifyIfCookieNameIsAdded.ts +38 -0
- package/src/automation/actions/interaction/verify/VerifyIfCookieNameIsDeleted.ts +33 -0
- package/src/automation/actions/interaction/verify/VerifyIfCookieObjectIsPresent.ts +49 -0
- package/src/automation/actions/interaction/verify/VerifyIfGivenOptionIsDuplicate.ts +60 -0
- package/src/automation/actions/interaction/verify/VerifyIfImageIsBroken.ts +40 -0
- package/src/automation/actions/interaction/verify/VerifyIfLinkIsBroken.ts +38 -0
- package/src/automation/actions/interaction/verify/VerifyIfLinkIsWorking.ts +37 -0
- package/src/automation/actions/interaction/verify/VerifyIfLinksAreBroken.ts +46 -0
- package/src/automation/actions/interaction/verify/VerifyIfLinksAreWorking.ts +45 -0
- package/src/automation/actions/interaction/verify/VerifyIfOptionWithIndexIsDeselectedInElement.ts +75 -0
- package/src/automation/actions/interaction/verify/VerifyIfOptionWithIndexIsSelectedInListBox.ts +77 -0
- package/src/automation/actions/interaction/verify/VerifyIfOptionWithTextIsDeselected.ts +40 -0
- package/src/automation/actions/interaction/verify/VerifyIfOptionWithValueIsDeselected.ts +61 -0
- package/src/automation/actions/interaction/verify/VerifyIfOptionWithValueIsSelected.ts +58 -0
- package/src/automation/actions/interaction/verify/VerifyIfOptionWithVisibleTextIsSelected.ts +40 -0
- package/src/automation/actions/interaction/verify/VerifyIfSpecifiedOptionIsSelected.ts +78 -0
- package/src/automation/actions/interaction/verify/VerifyIfStatusCodeOfALinkIsStatusCode.ts +37 -0
- package/src/automation/actions/interaction/verify/VerifyIfStatusCodesOfLinks.ts +46 -0
- package/src/automation/actions/interaction/verify/VerifyIfVideoEnded.ts +49 -0
- package/src/automation/actions/interaction/verify/VerifyIfVideoIsMuted.ts +49 -0
- package/src/automation/actions/interaction/verify/VerifyIfVideoIsPaused.ts +49 -0
- package/src/automation/actions/interaction/verify/VerifyIfVideoIsPlaying.ts +50 -0
- package/src/automation/actions/interaction/verify/VerifyIfVideoPlayingInMute.ts +58 -0
- package/src/automation/actions/interaction/verify/VerifyIfVideoPlayingInUnmute.ts +58 -0
- package/src/automation/actions/interaction/verify/VerifyIfXAndYCoordinateOfElement.ts +101 -0
- package/src/automation/actions/interaction/verify/VerifyLinkNavigatesToTitle.ts +41 -0
- package/src/automation/actions/interaction/verify/VerifyListBoxOptionsAreSorted.ts +72 -0
- package/src/automation/actions/interaction/verify/VerifyNavigateURL.ts +34 -0
- package/src/automation/actions/interaction/verify/VerifyNumberOfElementsByTagName.ts +35 -0
- package/src/automation/actions/interaction/verify/VerifyNumberOfElementsByXpath.ts +52 -0
- package/src/automation/actions/interaction/verify/VerifyPartialAttributeValue.ts +94 -0
- package/src/automation/actions/interaction/verify/VerifyPartialTitleOfCurrentPage.ts +29 -0
- package/src/automation/actions/interaction/verify/VerifyPerformanceScore.ts +84 -0
- package/src/automation/actions/interaction/verify/VerifyPwaScore.ts +66 -0
- package/src/automation/actions/interaction/verify/VerifyRadioButtonIsNotSelected.ts +42 -0
- package/src/automation/actions/interaction/verify/VerifyRadioButtonIsSelected.ts +42 -0
- package/src/automation/actions/interaction/verify/VerifySeoScore.ts +79 -0
- package/src/automation/actions/interaction/verify/VerifyTagName.ts +44 -0
- package/src/automation/actions/interaction/verify/VerifyThatSpecifiedOptionIsNotSelected.ts +73 -0
- package/src/automation/actions/interaction/verify/VerifyTitleInAllPage.ts +51 -0
- package/src/automation/actions/interaction/verify/VerifyTitleOfCurrentPage.ts +30 -0
- package/src/automation/actions/interaction/verify/VerifyValueOfElementContainsString.ts +51 -0
- package/src/automation/actions/interaction/verify/VerifyValueOfElementIsCleared.ts +45 -0
- package/src/automation/actions/interaction/verify/VerifyValueOfElementIsString.ts +54 -0
- package/src/automation/actions/interaction/verify/VerifyWidthOfElement.ts +90 -0
- package/src/automation/actions/interaction/verify/VerifyXLocationOfElement.ts +89 -0
- package/src/automation/actions/interaction/verify/VerifyYLocationOfElement.ts +90 -0
- package/src/automation/actions/interaction/verify/checkIfElementIsDisplayed.ts +83 -0
- package/src/automation/actions/interaction/verify/verifypartialtext.ts +131 -0
- package/src/automation/actions/interaction/verify/verifytext.ts +143 -0
- package/src/automation/actions/interaction/wait/wait.ts +16 -0
- package/src/automation/actions/interaction/wait/waitTillAttributeOfElementIsString.ts +88 -0
- package/src/automation/actions/interaction/wait/waitTillElementContainsText.ts +79 -0
- package/src/automation/actions/interaction/wait/waitTillElementHasText.ts +71 -0
- package/src/automation/actions/interaction/wait/waitTillElementIsClickable.ts +72 -0
- package/src/automation/actions/interaction/wait/waitTillPresenceOfAllElements.ts +72 -0
- package/src/automation/actions/interaction/wait/waitTillPresenceOfElement.ts +67 -0
- package/src/automation/actions/interface/IframeInterface.ts +6 -0
- package/src/automation/actions/interface/alertActionInterface.ts +39 -0
- package/src/automation/actions/interface/clearActionInterface.ts +27 -0
- package/src/automation/actions/interface/clickActionInterface.ts +87 -0
- package/src/automation/actions/interface/dragAndDropToElementInterface.ts +18 -0
- package/src/automation/actions/interface/findActionInterface.ts +15 -0
- package/src/automation/actions/interface/getActionInterface.ts +873 -0
- package/src/automation/actions/interface/interactionActionInterface.ts +51 -3
- package/src/automation/actions/interface/maximizeAndMinimizeInterface.ts +12 -0
- package/src/automation/actions/interface/navigationActionInterface.ts +1 -1
- package/src/automation/actions/interface/pressActionInterface.ts +25 -0
- package/src/automation/actions/interface/scrollActionInterface.ts +45 -0
- package/src/automation/actions/interface/setActionInterface.ts +10 -0
- package/src/automation/actions/interface/shadowDomInterface.ts +78 -0
- package/src/automation/actions/interface/switchingActionInterface.ts +93 -0
- package/src/automation/actions/interface/uploadFile.ts +14 -0
- package/src/automation/actions/interface/verifyActionInterface.ts +743 -0
- package/src/automation/actions/interface/waitActionInterface.ts +75 -0
- package/src/automation/browserSession/initiateBrowserSession.ts +12 -40
- package/src/automation/mobileSession/initiateMobileSession.ts +81 -0
- package/src/core/constants/allAction.ts +21 -0
- package/src/core/constants/defaultValues.ts +1 -0
- package/src/core/constants/supportedActions.ts +27 -2
- package/src/core/interfaces/actionInterface.ts +238 -3
- package/src/core/interfaces/automationRunnerInterface.ts +2 -1
- package/src/core/interfaces/browserCapabilitiesInterface.ts +1 -3
- package/src/core/interfaces/errorInfoInterface.ts +7 -0
- package/src/core/interfaces/executionDetails.ts +10 -6
- package/src/core/interfaces/fireflinkScriptPayloadInterface.ts +17 -5
- package/src/core/interfaces/llmResponseInterface.ts +28 -4
- package/src/core/interfaces/promptInterface.ts +20 -0
- package/src/core/interfaces/scriptGenrationDataInterface.ts +2 -2
- package/src/core/interfaces/simplifyAndFlattenInterface.ts +13 -0
- package/src/core/main/actionHandlerFactory.ts +1528 -53
- package/src/core/main/executionContext.ts +5 -1
- package/src/core/main/runAutomationScript.ts +528 -123
- package/src/core/main/stepProcessor.ts +4 -2
- package/src/core/types/llmResponseType.ts +7 -3
- package/src/core/types/promptMap.ts +7 -4
- package/src/core/types/promptType.ts +6 -0
- package/src/core/types/scriptTypesType.ts +1 -0
- package/src/domAnalysis/getRelaventElements.ts +10 -1
- package/src/domAnalysis/relativeElementsFromDom.ts +205 -0
- package/src/domAnalysis/searchBest.ts +130 -17
- package/src/domAnalysis/simplifyAndFlatten.ts +139 -10
- package/src/fireflinkData/fireflinkLocators/getListOfLocators.ts +1 -2
- package/src/fireflinkData/fireflinkScript/scriptGenrationData.ts +70 -21
- package/src/imageAnalysisMobile/annotatedScreenshotMobile.ts +137 -0
- package/src/imageAnalysisMobile/annotatedScreenshotMobileInterface.ts +6 -0
- package/src/imageAnalysisWeb/annotateScreenshot.ts +196 -0
- package/src/imageAnalysisWeb/generateAnnotatedScreenshots.ts +43 -0
- package/src/imageAnalysisWeb/screenshotInterface.ts +18 -0
- package/src/index.ts +2 -2
- package/src/service/{fireflinkApi.service.ts → api/fireflinkApi.service.ts} +5 -7
- package/src/service/kafka/fireflinkKafka.service.ts +25 -0
- package/src/service/scriptRunner.service.ts +23 -42
- package/src/utils/DomExtraction/jsForAttributeInjection.ts +68 -12
- package/src/utils/InstancesDetails/getInstancesInfo.ts +12 -0
- package/src/utils/alertPopup/isAlertPresent.ts +20 -0
- package/src/utils/alertPopup/isAlertPresentInterface.ts +6 -0
- package/src/utils/helpers/enterActionHelper.ts +88 -2
- package/src/utils/helpers/imageUtils.ts +10 -0
- package/src/utils/helpers/sameActionsHelper.ts +52 -0
- package/src/utils/helpers/xpathcreation.ts +59 -0
- package/src/utils/iframesExtraction/findElementUsingFF.ts +45 -0
- package/src/utils/iframesExtraction/iframeInterface.ts +22 -0
- package/src/utils/iframesExtraction/switchToIframeByMeta.ts +23 -0
- package/src/utils/javascript/jsFindElement.ts +39 -31
- package/src/utils/javascript/jsForShadowRoot.ts +9 -9
- package/src/utils/javascript/jsForVision.ts +151 -0
- package/src/utils/logger/logData.ts +126 -47
- package/src/utils/mobileXpath/findXpathFromIndex.ts +87 -0
- package/src/utils/mobileXpath/findXpathFromIndexInterface.ts +4 -0
- package/src/utils/newTab/newTabTracker.ts +62 -0
- package/src/automation/actions/interaction/click.ts +0 -25
- package/src/automation/actions/interaction/enterInput.ts +0 -36
- package/src/automation/actions/navigation/getTitle.ts +0 -9
- package/src/automation/actions/navigation/goBack.ts +0 -9
- package/src/automation/actions/navigation/navigate.ts +0 -10
- package/src/automation/actions/navigation/refresh.ts +0 -9
- package/src/automation/actions/wait/wait.ts +0 -10
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { logger } from "../../utils/logger/logData.js"
|
|
3
2
|
export interface AnnotatedDOMResult {
|
|
4
3
|
dom: string;
|
|
5
|
-
selectors: Record<string, string>;
|
|
4
|
+
// selectors: Record<string, string>;
|
|
6
5
|
}
|
|
7
6
|
|
|
8
7
|
export async function getAnnotatedDOM(
|
|
9
|
-
browser: Browser
|
|
8
|
+
browser: WebdriverIO.Browser
|
|
10
9
|
): Promise<AnnotatedDOMResult> {
|
|
11
10
|
|
|
12
11
|
return await browser.execute<AnnotatedDOMResult, []>(() => {
|
|
13
12
|
|
|
14
13
|
let nodeIndex = 0;
|
|
15
|
-
const xpaths: Record<string, string> = {};
|
|
14
|
+
// const xpaths: Record<string, string> = {};
|
|
16
15
|
|
|
17
16
|
// ==========================================================
|
|
18
17
|
// COVERAGE CHECK
|
|
@@ -32,9 +31,9 @@ export async function getAnnotatedDOM(
|
|
|
32
31
|
[rect.left + rect.width / 2, rect.top + rect.height / 2]
|
|
33
32
|
];
|
|
34
33
|
|
|
35
|
-
for (
|
|
34
|
+
for (const [x, y] of testPoints) {
|
|
36
35
|
|
|
37
|
-
|
|
36
|
+
const topEl = document.elementFromPoint(x, y);
|
|
38
37
|
if (!topEl) continue;
|
|
39
38
|
|
|
40
39
|
if (topEl === el || el.contains(topEl)) continue;
|
|
@@ -115,7 +114,7 @@ export async function getAnnotatedDOM(
|
|
|
115
114
|
|
|
116
115
|
if (!node || node.nodeType !== 1) return "";
|
|
117
116
|
|
|
118
|
-
|
|
117
|
+
const segments: string[] = [];
|
|
119
118
|
let current: Element | null = node;
|
|
120
119
|
|
|
121
120
|
while (current && current.nodeType === 1) {
|
|
@@ -214,7 +213,7 @@ export async function getAnnotatedDOM(
|
|
|
214
213
|
node.setAttribute("ff-inspect", fireId);
|
|
215
214
|
node.setAttribute("ff-xpath", xpath);
|
|
216
215
|
|
|
217
|
-
xpaths[fireId] = xpath;
|
|
216
|
+
// xpaths[fireId] = xpath;
|
|
218
217
|
|
|
219
218
|
annotate(node);
|
|
220
219
|
}
|
|
@@ -300,7 +299,10 @@ export async function getAnnotatedDOM(
|
|
|
300
299
|
doc.documentElement
|
|
301
300
|
);
|
|
302
301
|
}
|
|
303
|
-
} catch {
|
|
302
|
+
} catch (error) {
|
|
303
|
+
|
|
304
|
+
logger.error("Attribute injection failed", error)
|
|
305
|
+
}
|
|
304
306
|
}
|
|
305
307
|
|
|
306
308
|
el.childNodes.forEach(child => {
|
|
@@ -314,9 +316,63 @@ export async function getAnnotatedDOM(
|
|
|
314
316
|
return {
|
|
315
317
|
dom:
|
|
316
318
|
"<!DOCTYPE html>\n" +
|
|
317
|
-
serializeNode(document.documentElement)
|
|
318
|
-
selectors: xpaths
|
|
319
|
+
serializeNode(document.documentElement)
|
|
320
|
+
// selectors: xpaths
|
|
319
321
|
};
|
|
320
322
|
|
|
321
323
|
});
|
|
322
324
|
}
|
|
325
|
+
|
|
326
|
+
import { DOMParser, XMLSerializer } from "@xmldom/xmldom";
|
|
327
|
+
|
|
328
|
+
export async function getAnnotatedDOMForMobile(
|
|
329
|
+
driver: WebdriverIO.Browser
|
|
330
|
+
): Promise<AnnotatedDOMResult> {
|
|
331
|
+
|
|
332
|
+
try {
|
|
333
|
+
|
|
334
|
+
// Wait like Python sleep(2)
|
|
335
|
+
await driver.pause(2000);
|
|
336
|
+
|
|
337
|
+
const pageSource = await driver.getPageSource();
|
|
338
|
+
|
|
339
|
+
if (!pageSource) {
|
|
340
|
+
throw new Error("Unable to capture DOM");
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// Parse XML DOM
|
|
344
|
+
const parser = new DOMParser();
|
|
345
|
+
const xmlDoc = parser.parseFromString(pageSource, "text/xml");
|
|
346
|
+
|
|
347
|
+
const allElements = xmlDoc.getElementsByTagName("*");
|
|
348
|
+
|
|
349
|
+
let index = 1;
|
|
350
|
+
|
|
351
|
+
for (const element of Array.from(allElements)) {
|
|
352
|
+
element.setAttribute("FF-inspecter", `Fire-Flink-${index}`);
|
|
353
|
+
index++;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
// Convert DOM back to string
|
|
357
|
+
const serializer = new XMLSerializer();
|
|
358
|
+
let annotatedXML = serializer.serializeToString(xmlDoc);
|
|
359
|
+
|
|
360
|
+
// Preserve XML declaration if present
|
|
361
|
+
if (pageSource.trim().startsWith("<?xml")) {
|
|
362
|
+
const declarationEnd = pageSource.indexOf("?>");
|
|
363
|
+
|
|
364
|
+
if (declarationEnd !== -1) {
|
|
365
|
+
const declaration = pageSource.substring(0, declarationEnd + 2).trim();
|
|
366
|
+
annotatedXML = `${declaration}\n${annotatedXML}`;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
return {
|
|
371
|
+
dom: annotatedXML
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
} catch (error: any) {
|
|
375
|
+
throw new Error(`Unable to annotate DOM: ${error.message}`, { cause: error });
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
|
|
2
|
+
export function getAiInstanceInfo(
|
|
3
|
+
responseObject: any
|
|
4
|
+
): Record<string, string> {
|
|
5
|
+
return {
|
|
6
|
+
serviceProvider: responseObject.serviceProvider,
|
|
7
|
+
apiKey: responseObject.instanceDetails.apiKey,
|
|
8
|
+
apiUrl: responseObject.instanceDetails.apiUrl,
|
|
9
|
+
visionApiKey: responseObject.instanceDetails.visionApiKey ?? "c2stcHJvai1zODVFenVfWkdnVUxoT1dNVVhRTmxuUW9ELUpnS3dEMGpvSmJZcDE0YWd4ZEZ3MWM5Mlh5NnlLUFJpYk1XckUtTTRTV1dzcHc0MFQzQmxia0ZKekVkWXRMTm1rWWlJQVRYTUwyTWhhTU5NR3FUWjhZekJYZHdkTHc0MHRVT084d0t6N19wRENYSERSX0NsSVRtTVpjR3VsY3ZlNEE=",
|
|
10
|
+
model: responseObject.model,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
import { IAlertChecker } from "./isAlertPresentInterface";
|
|
3
|
+
|
|
4
|
+
export const isAlertPresent: IAlertChecker = async (
|
|
5
|
+
driver,
|
|
6
|
+
timeout: number = 0
|
|
7
|
+
): Promise<boolean> => {
|
|
8
|
+
try {
|
|
9
|
+
if (!driver) return false;
|
|
10
|
+
|
|
11
|
+
await driver.waitUntil(
|
|
12
|
+
async () => await driver.isAlertOpen(),
|
|
13
|
+
{ timeout }
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
return true;
|
|
17
|
+
} catch {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import { JSDOM } from "jsdom";
|
|
2
|
+
import { DOMParser } from "@xmldom/xmldom";
|
|
3
|
+
import { getFFIndexAndXPath } from "./xpathcreation.js";
|
|
4
|
+
import { logger } from "../logger/logData.js";
|
|
5
|
+
import xpath from "xpath";
|
|
2
6
|
|
|
3
|
-
|
|
7
|
+
interface EnterActionResult {
|
|
4
8
|
ffNumber: number;
|
|
5
9
|
xpathPath: string;
|
|
6
10
|
}
|
|
11
|
+
interface EnterActionResultMob {
|
|
12
|
+
xpathPath: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
7
15
|
|
|
8
16
|
export const enterActionHelper = (
|
|
9
17
|
pageDOM: string,
|
|
@@ -32,7 +40,7 @@ export const enterActionHelper = (
|
|
|
32
40
|
return el?.getAttribute("ff-xpath") || "";
|
|
33
41
|
};
|
|
34
42
|
|
|
35
|
-
|
|
43
|
+
const element = doc.querySelector(
|
|
36
44
|
`[ff-inspect="Fire-Flink-${numericFF}"]`
|
|
37
45
|
);
|
|
38
46
|
|
|
@@ -92,3 +100,81 @@ export const enterActionHelper = (
|
|
|
92
100
|
xpathPath
|
|
93
101
|
};
|
|
94
102
|
};
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
export function enterActionHelperMob(
|
|
107
|
+
annotatedDom: string,
|
|
108
|
+
num: string,
|
|
109
|
+
): EnterActionResultMob {
|
|
110
|
+
|
|
111
|
+
const parser = new DOMParser();
|
|
112
|
+
const match = num.match(/\d+$/);
|
|
113
|
+
const numericFF = match ? parseInt(match[0], 10) : 0;
|
|
114
|
+
const xmlDoc = parser.parseFromString(annotatedDom, "text/xml");
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
const xpathQuery = `//*[@FF-inspecter='${num}']`;
|
|
118
|
+
|
|
119
|
+
const nodes = xpath.select(xpathQuery, xmlDoc) as Node[];
|
|
120
|
+
|
|
121
|
+
const element = nodes.length ? (nodes[0] as Element) : null;
|
|
122
|
+
|
|
123
|
+
let xpathPath = "";
|
|
124
|
+
|
|
125
|
+
if (element) {
|
|
126
|
+
|
|
127
|
+
const elementClass = (element.getAttribute("class") || "").toLowerCase();
|
|
128
|
+
|
|
129
|
+
if (
|
|
130
|
+
elementClass.includes("edittext") ||
|
|
131
|
+
elementClass.includes("autocompletetextview")
|
|
132
|
+
) {
|
|
133
|
+
|
|
134
|
+
xpathPath = getFFIndexAndXPath(annotatedDom, num);
|
|
135
|
+
|
|
136
|
+
} else {
|
|
137
|
+
|
|
138
|
+
// check immediate children
|
|
139
|
+
const children = Array.from(element.children);
|
|
140
|
+
|
|
141
|
+
let editableChild: Element | null = null;
|
|
142
|
+
|
|
143
|
+
for (const child of children) {
|
|
144
|
+
|
|
145
|
+
const childClass = (child.getAttribute("class") || "").toLowerCase();
|
|
146
|
+
|
|
147
|
+
if (
|
|
148
|
+
childClass.includes("edittext") ||
|
|
149
|
+
childClass.includes("autocompletetextview")
|
|
150
|
+
) {
|
|
151
|
+
editableChild = child;
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (editableChild) {
|
|
157
|
+
|
|
158
|
+
const childNum =
|
|
159
|
+
editableChild.getAttribute("FF-inspecter")?.split("-").pop();
|
|
160
|
+
|
|
161
|
+
if (childNum) {
|
|
162
|
+
xpathPath = getFFIndexAndXPath(annotatedDom, `Fire-Flink-${childNum}`);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
} else {
|
|
166
|
+
|
|
167
|
+
xpathPath = getFFIndexAndXPath(annotatedDom, num);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
} else {
|
|
173
|
+
logger.info(`No element found for ffNumber: ${numericFF} in MOB_Enter action`);
|
|
174
|
+
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return {
|
|
178
|
+
xpathPath
|
|
179
|
+
};
|
|
180
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ensures that a base64 string or Buffer has the correct data URI prefix for PNG images.
|
|
3
|
+
* @param image The base64 string or Buffer.
|
|
4
|
+
* @returns The base64 string with the `data:image/png;base64,` prefix.
|
|
5
|
+
*/
|
|
6
|
+
export function formatImageBase64(image: string | Buffer): string {
|
|
7
|
+
if (!image) return "";
|
|
8
|
+
const base64 = Buffer.isBuffer(image) ? image.toString("base64") : image;
|
|
9
|
+
return base64.startsWith("data:") ? base64 : `data:image/png;base64,${base64}`;
|
|
10
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export const sameActionHelper: Record<string, string> = {
|
|
2
|
+
MOB_Tap: "Click",
|
|
3
|
+
MOB_Enter: "SendKeys",
|
|
4
|
+
MOB_VerifyElementIsDisplayed: "VerifyElementIsDisplayed",
|
|
5
|
+
MOB_VerifyElementIsEnabled: "VerifyElementIsEnabled",
|
|
6
|
+
MOB_VerifyXLocationOfAndroidElement: "VerifyXLocationOfElement",
|
|
7
|
+
MOB_VerifyElementIsSelected: "VerifyElementIsSelected",
|
|
8
|
+
MOB_VerifyYLocationOfAndroidElement: "VerifyYLocationOfElement",
|
|
9
|
+
MOB_VerifyWidthOfElement: "VerifyWidthOfElement",
|
|
10
|
+
MOB_WaitAndClick: "WaitAndClick",
|
|
11
|
+
MOB_GetScreenshot: "GetScreenshot",
|
|
12
|
+
MOB_VerifyText: "VerifyText",
|
|
13
|
+
MOB_VerifyElementNotContainsText: "VerifyElementNotContainsText",
|
|
14
|
+
MOB_VerifyIfXAndYCoordinateOfElement: "VerifyIfXAndYCoordinateOfElement",
|
|
15
|
+
MOB_VerifyPartialAttributeValue: "VerifyPartialAttributeValue",
|
|
16
|
+
MOB_VerifyElementIsClickable: "VerifyElementIsClickable",
|
|
17
|
+
MOB_VerifyElementIsDisabled: "VerifyElementIsDisabled",
|
|
18
|
+
MOB_GetImplicitTimeOut: "GetImplicitTimeOut",
|
|
19
|
+
MOB_GetDriverInstance: "GetDriverInstance",
|
|
20
|
+
MOB_GetCurrentWindowHandle: "GetCurrentWindowHandle",
|
|
21
|
+
MOB_GetTagName: "GetTagName",
|
|
22
|
+
MOB_GetScreenshotAs: "GetScreenshotAs",
|
|
23
|
+
MOB_GetX: "GetXLocationOfWebElement",
|
|
24
|
+
MOB_GetLocation: "GetLocation",
|
|
25
|
+
MOB_GetY: "GetYLocationOfWebElement",
|
|
26
|
+
MOB_GetRect: "GetRect",
|
|
27
|
+
MOB_GetText: "GetText",
|
|
28
|
+
MOB_GetSize: "GetSize",
|
|
29
|
+
MOB_GetAttribute: "GetAttribute",
|
|
30
|
+
MOB_Clear: "Clear",
|
|
31
|
+
MOB_DoubleTap: "DoubleClick",
|
|
32
|
+
MOB_TapNTimes: "ClickNTimes",
|
|
33
|
+
MOB_VerifyPartialText: "VerifyPartialText",
|
|
34
|
+
MOB_VerifyAttributeValue: "VerifyAttributeValue",
|
|
35
|
+
MOB_ClearThenEnterInput: "ClearThenEnterInput",
|
|
36
|
+
MOB_EnterDataAndPressKey: "EnterDataAndPressKey",
|
|
37
|
+
MOB_WaitAndSendKeys: "WaitAndSendKeys",
|
|
38
|
+
MOB_VerifyHeightOfElement: "VerifyHeightOfWebElement",
|
|
39
|
+
MOB_WaitTillPresenceOfElement: "WaitTillPresenceOfElement",
|
|
40
|
+
MOB_WaitTillPresenceOfAllElements: "WaitTillPresenceOfAllElements",
|
|
41
|
+
MOB_WaitTillAttributeOfElementIsString: "WaitTillAttributeOfElementIsString",
|
|
42
|
+
MOB_EnterUrl: "EnterUrl",
|
|
43
|
+
MOB_SetClipBoardText: "SetClipBoardText",
|
|
44
|
+
MOB_PressAnyKeyNTimes: "PressAnyKeyNTimes",
|
|
45
|
+
MOB_FindElements: "FindElements",
|
|
46
|
+
MOB_WaitTillElementIsClickable: "WaitTillElementIsClickable",
|
|
47
|
+
MOB_CheckIfElementIsDisplayed: "CheckIfElementIsDisplayed",
|
|
48
|
+
MOB_PressAnyKey: "PressAnyKey",
|
|
49
|
+
MOB_WaitTillElementHasText: "WaitTillElementHasText",
|
|
50
|
+
MOB_WaitTillElementContainsText: "WaitTillElementContainsText",
|
|
51
|
+
MOB_PressEnterKey: "PressEnterKey"
|
|
52
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { DOMParser } from "@xmldom/xmldom";
|
|
2
|
+
import xpath from "xpath";
|
|
3
|
+
// import { logger } from "../logger/logData.js";
|
|
4
|
+
|
|
5
|
+
export function getFFIndexAndXPath(
|
|
6
|
+
annotatedDom: string,
|
|
7
|
+
fireflinkIndex: string
|
|
8
|
+
): string {
|
|
9
|
+
|
|
10
|
+
try{
|
|
11
|
+
|
|
12
|
+
const parser = new DOMParser();
|
|
13
|
+
const xmlDoc = parser.parseFromString(annotatedDom, "text/xml");
|
|
14
|
+
|
|
15
|
+
const xpathQuery = `//*[@FF-inspecter='${fireflinkIndex}']`;
|
|
16
|
+
|
|
17
|
+
const nodes = xpath.select(xpathQuery, xmlDoc) as Node[];
|
|
18
|
+
|
|
19
|
+
const element = nodes.length ? (nodes[0] as Element) : null;
|
|
20
|
+
|
|
21
|
+
function buildXPath(node: Node): string {
|
|
22
|
+
if (node.nodeType !== 1) return "";
|
|
23
|
+
|
|
24
|
+
const parts: string[] = [];
|
|
25
|
+
|
|
26
|
+
while (node && node.nodeType === 1) {
|
|
27
|
+
|
|
28
|
+
let index = 1;
|
|
29
|
+
let sibling = node.previousSibling;
|
|
30
|
+
|
|
31
|
+
while (sibling) {
|
|
32
|
+
if (
|
|
33
|
+
sibling.nodeType === 1 &&
|
|
34
|
+
(sibling as Element).tagName === (node as Element).tagName
|
|
35
|
+
) {
|
|
36
|
+
index++;
|
|
37
|
+
}
|
|
38
|
+
sibling = sibling.previousSibling;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
parts.unshift(`${(node as Element).tagName}[${index}]`);
|
|
42
|
+
node = node.parentNode!;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return "/" + parts.join("/");
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
let xpathPath = "";
|
|
49
|
+
|
|
50
|
+
if (element) {
|
|
51
|
+
xpathPath = buildXPath(element);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return xpathPath;
|
|
55
|
+
}
|
|
56
|
+
catch(error:any){
|
|
57
|
+
throw new Error( "Error in getFFIndexAndXPath",{cause : error} );
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { IFindElementUsingFF } from "./iframeInterface.js";
|
|
2
|
+
import { switchToIframeByMeta } from "./switchToIframeByMeta.js";
|
|
3
|
+
|
|
4
|
+
export const findElementUsingFF: (args: IFindElementUsingFF) => Promise<void> =
|
|
5
|
+
async (args) => {
|
|
6
|
+
|
|
7
|
+
await args.driver.switchToFrame(null);
|
|
8
|
+
|
|
9
|
+
const usedElementNames: string[] = [];
|
|
10
|
+
|
|
11
|
+
for (const frameMeta of args.frames) {
|
|
12
|
+
|
|
13
|
+
const xpathUsed = await switchToIframeByMeta(args.driver, frameMeta);
|
|
14
|
+
|
|
15
|
+
if (xpathUsed) {
|
|
16
|
+
|
|
17
|
+
let finalElementName = args.elementName;
|
|
18
|
+
|
|
19
|
+
if (finalElementName) {
|
|
20
|
+
const baseName = finalElementName;
|
|
21
|
+
let newName = baseName;
|
|
22
|
+
let count = 0;
|
|
23
|
+
|
|
24
|
+
while (usedElementNames.includes(newName)) {
|
|
25
|
+
count++;
|
|
26
|
+
newName = `${baseName}_${count}`;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
finalElementName = newName;
|
|
30
|
+
usedElementNames.push(finalElementName);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
args.scriptDataAppender.add(async () => ({
|
|
34
|
+
nlpName: 'SwitchToFrameByFrameElement',
|
|
35
|
+
stepInputs: [],
|
|
36
|
+
elementsData: [{
|
|
37
|
+
name: finalElementName,
|
|
38
|
+
type: args.elementType,
|
|
39
|
+
locators: [{ name: "xpath", value: xpathUsed }],
|
|
40
|
+
platform: args.platform
|
|
41
|
+
}]
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
import { ScriptDataAppender } from "../../fireflinkData/fireflinkScript/scriptGenrationData";
|
|
3
|
+
|
|
4
|
+
export interface FrameMeta {
|
|
5
|
+
id?: string;
|
|
6
|
+
name?: string;
|
|
7
|
+
title?: string;
|
|
8
|
+
aria?: string;
|
|
9
|
+
src?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface IFindElementUsingFF {
|
|
13
|
+
|
|
14
|
+
driver: WebdriverIO.Browser,
|
|
15
|
+
selector: string,
|
|
16
|
+
frames: FrameMeta[],
|
|
17
|
+
scriptDataAppender: ScriptDataAppender,
|
|
18
|
+
elementName: string,
|
|
19
|
+
elementType: string,
|
|
20
|
+
platform: string
|
|
21
|
+
|
|
22
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { FrameMeta } from "./iframeInterface.js";
|
|
2
|
+
|
|
3
|
+
export async function switchToIframeByMeta(driver: WebdriverIO.Browser, frameMeta: FrameMeta): Promise<string | null> {
|
|
4
|
+
const selectors = [
|
|
5
|
+
frameMeta.id && `//*[@id='${frameMeta.id}']`,
|
|
6
|
+
frameMeta.name && `//*[@name='${frameMeta.name}']`,
|
|
7
|
+
frameMeta.title && `//iframe[@title='${frameMeta.title}']`,
|
|
8
|
+
frameMeta.aria && `//iframe[@aria-label='${frameMeta.aria}']`,
|
|
9
|
+
frameMeta.src && `//iframe[contains(@src,'${frameMeta.src}')]`,
|
|
10
|
+
].filter(Boolean) as string[];
|
|
11
|
+
|
|
12
|
+
for (const selector of selectors) {
|
|
13
|
+
try {
|
|
14
|
+
const iframe = await driver.$(selector);
|
|
15
|
+
if (await iframe.isExisting()) {
|
|
16
|
+
await driver.switchToFrame(iframe);
|
|
17
|
+
return selector;
|
|
18
|
+
}
|
|
19
|
+
} catch { continue; }
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
@@ -9,10 +9,10 @@ export const Find_element_by_ff_js_script = `
|
|
|
9
9
|
// ---------------- FINDER ----------------
|
|
10
10
|
function findByFfInspect(root) {
|
|
11
11
|
const visited = new Set();
|
|
12
|
-
const stack = [{ node: root, frames: [] }];
|
|
12
|
+
const stack = [{ node: root, frames: [], currentDoc: root }];
|
|
13
13
|
|
|
14
14
|
while (stack.length > 0) {
|
|
15
|
-
const { node, frames } = stack.pop();
|
|
15
|
+
const { node, frames, currentDoc } = stack.pop();
|
|
16
16
|
if (!node) continue;
|
|
17
17
|
|
|
18
18
|
if (
|
|
@@ -26,36 +26,43 @@ export const Find_element_by_ff_js_script = `
|
|
|
26
26
|
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
27
27
|
|
|
28
28
|
if (node.getAttribute && node.getAttribute("ff-inspect") === target) {
|
|
29
|
-
return { node, frames };
|
|
29
|
+
return { node, frames, iframe_dom: currentDoc };
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
// Shadow DOM
|
|
32
33
|
if (node.shadowRoot) {
|
|
33
|
-
stack.push({
|
|
34
|
+
stack.push({
|
|
35
|
+
node: node.shadowRoot,
|
|
36
|
+
frames,
|
|
37
|
+
currentDoc
|
|
38
|
+
});
|
|
34
39
|
}
|
|
35
40
|
|
|
41
|
+
// Iframe traversal
|
|
36
42
|
if (node.tagName === "IFRAME") {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
43
|
+
try {
|
|
44
|
+
const doc = node.contentDocument || node.contentWindow?.document;
|
|
45
|
+
if (doc) {
|
|
46
|
+
const meta = {
|
|
47
|
+
id: node.id || null,
|
|
48
|
+
name: node.getAttribute("name") || null,
|
|
49
|
+
title: node.getAttribute("title") || null,
|
|
50
|
+
aria: node.getAttribute("aria-label") || null,
|
|
51
|
+
src: node.getAttribute("src") || null,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
stack.push({
|
|
55
|
+
node: doc,
|
|
56
|
+
frames: [...frames, meta],
|
|
57
|
+
currentDoc: doc
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
} catch (e) {}
|
|
54
61
|
}
|
|
55
62
|
|
|
56
63
|
const kids = node.children || node.childNodes;
|
|
57
64
|
for (let i = kids.length - 1; i >= 0; i--) {
|
|
58
|
-
stack.push({ node: kids[i], frames });
|
|
65
|
+
stack.push({ node: kids[i], frames, currentDoc });
|
|
59
66
|
}
|
|
60
67
|
}
|
|
61
68
|
|
|
@@ -65,7 +72,7 @@ export const Find_element_by_ff_js_script = `
|
|
|
65
72
|
) {
|
|
66
73
|
const kids = node.childNodes;
|
|
67
74
|
for (let i = kids.length - 1; i >= 0; i--) {
|
|
68
|
-
stack.push({ node: kids[i], frames });
|
|
75
|
+
stack.push({ node: kids[i], frames, currentDoc });
|
|
69
76
|
}
|
|
70
77
|
}
|
|
71
78
|
}
|
|
@@ -101,15 +108,15 @@ export const Find_element_by_ff_js_script = `
|
|
|
101
108
|
function buildXPath(el) {
|
|
102
109
|
if (!el) return null;
|
|
103
110
|
|
|
104
|
-
if (el.id) return
|
|
111
|
+
if (el.id) return "//*[@id=\\"" + el.id + "\\"]";
|
|
105
112
|
|
|
106
113
|
const name = el.getAttribute("name");
|
|
107
|
-
if (name) return
|
|
114
|
+
if (name) return "//*[@name=\\"" + name + "\\"]";
|
|
108
115
|
|
|
109
116
|
const text = el.textContent && el.textContent.trim();
|
|
110
117
|
if (text && text.length < 50) {
|
|
111
|
-
const escaped = text.replace(/"/g, '
|
|
112
|
-
const xp =
|
|
118
|
+
const escaped = text.replace(/"/g, '\\"');
|
|
119
|
+
const xp = "//*[text()=\\"" + escaped + "\\"]";
|
|
113
120
|
try {
|
|
114
121
|
const n = document.evaluate(xp, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
|
|
115
122
|
if (n.singleNodeValue === el) return xp;
|
|
@@ -150,12 +157,13 @@ export const Find_element_by_ff_js_script = `
|
|
|
150
157
|
if (inside) targetNode = inside;
|
|
151
158
|
}
|
|
152
159
|
|
|
153
|
-
const
|
|
160
|
+
const xpath_if = buildXPath(targetNode);
|
|
154
161
|
|
|
155
162
|
return callback({
|
|
156
163
|
success: true,
|
|
157
|
-
|
|
158
|
-
frames: found.frames
|
|
164
|
+
xpath_if,
|
|
165
|
+
frames: found.frames,
|
|
166
|
+
iframe_dom_html: found.iframe_dom?.documentElement?.outerHTML || null
|
|
159
167
|
});
|
|
160
168
|
})();
|
|
161
|
-
`;
|
|
169
|
+
`;
|
|
@@ -113,8 +113,8 @@ const path = arguments[0];
|
|
|
113
113
|
function resolve(path) {
|
|
114
114
|
|
|
115
115
|
function toCss(sel) {
|
|
116
|
-
return sel.replace(/(
|
|
117
|
-
(_, t, n) =>
|
|
116
|
+
return sel.replace(/(\\w+)\\[(\\d+)\\]/g,
|
|
117
|
+
(_, t, n) => \`\${t}:nth-of-type(\${n})\`);
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
const parts = path.split("/shadow/");
|
|
@@ -130,7 +130,7 @@ function resolve(path) {
|
|
|
130
130
|
for (let i = 1; i < parts.length; i++) {
|
|
131
131
|
if (!node || !node.shadowRoot) return null;
|
|
132
132
|
node = node.shadowRoot.querySelector(
|
|
133
|
-
toCss(parts[i].replace(
|
|
133
|
+
toCss(parts[i].replace(/\\//g, " > "))
|
|
134
134
|
);
|
|
135
135
|
}
|
|
136
136
|
|
|
@@ -149,8 +149,8 @@ const text = arguments[1];
|
|
|
149
149
|
function resolve(path) {
|
|
150
150
|
|
|
151
151
|
function toCss(sel) {
|
|
152
|
-
return sel.replace(/(
|
|
153
|
-
(_, t, n) =>
|
|
152
|
+
return sel.replace(/(\\w+)\\[(\\d+)\\]/g,
|
|
153
|
+
(_, t, n) => \`\${t}:nth-of-type(\${n})\`);
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
const parts = path.split("/shadow/");
|
|
@@ -166,7 +166,7 @@ function resolve(path) {
|
|
|
166
166
|
for (let i = 1; i < parts.length; i++) {
|
|
167
167
|
if (!node || !node.shadowRoot) return null;
|
|
168
168
|
node = node.shadowRoot.querySelector(
|
|
169
|
-
toCss(parts[i].replace(
|
|
169
|
+
toCss(parts[i].replace(/\\//g, " > "))
|
|
170
170
|
);
|
|
171
171
|
}
|
|
172
172
|
|
|
@@ -184,8 +184,8 @@ const expected = arguments[1];
|
|
|
184
184
|
function resolve(path) {
|
|
185
185
|
|
|
186
186
|
function toCss(sel) {
|
|
187
|
-
return sel.replace(/(
|
|
188
|
-
(_, t, n) =>
|
|
187
|
+
return sel.replace(/(\\w+)\\[(\\d+)\\]/g,
|
|
188
|
+
(_, t, n) => \`\${t}:nth-of-type(\${n})\`);
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
const parts = path.split("/shadow/");
|
|
@@ -201,7 +201,7 @@ function resolve(path) {
|
|
|
201
201
|
for (let i = 1; i < parts.length; i++) {
|
|
202
202
|
if (!node || !node.shadowRoot) return null;
|
|
203
203
|
node = node.shadowRoot.querySelector(
|
|
204
|
-
toCss(parts[i].replace(
|
|
204
|
+
toCss(parts[i].replace(/\\//g, " > "))
|
|
205
205
|
);
|
|
206
206
|
}
|
|
207
207
|
|