ff-automationv2 2.2.28 → 2.2.29
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/dist/ai/llmcalls/llmAction.d.ts +9 -4
- package/dist/ai/llmcalls/llmAction.js +173 -37
- package/dist/ai/llmcalls/parseLlmOputput.js +18 -6
- package/dist/ai/llmprompts/promptRegistry.js +11 -0
- package/dist/ai/llmprompts/systemPrompts/actionExtractorPrompt.js +19 -10
- package/dist/ai/llmprompts/systemPrompts/combinedActionExtractorPrompt.js +7 -6
- package/dist/ai/llmprompts/systemPrompts/combinedActionExtractorPromptMob.js +14 -13
- package/dist/ai/llmprompts/systemPrompts/errorDescriptionPrompt.js +6 -4
- package/dist/ai/llmprompts/systemPrompts/fireflinkElementIndexExtactors.js +120 -62
- package/dist/ai/llmprompts/systemPrompts/fireflinkElementIndexExtractor_Mob.js +33 -28
- package/dist/ai/llmprompts/systemPrompts/getActionExtractorPrompt.js +18 -16
- package/dist/ai/llmprompts/systemPrompts/getActionExtractorPromptMob.js +13 -13
- package/dist/ai/llmprompts/systemPrompts/mobileKeywordExtractor.js +13 -11
- package/dist/ai/llmprompts/systemPrompts/userStoryToListPrompt.js +1 -1
- package/dist/ai/llmprompts/systemPrompts/verifyActionExtractorPrompt.js +20 -18
- package/dist/ai/llmprompts/systemPrompts/verifyActionExtractorPromptMob.js +9 -9
- package/dist/ai/llmprompts/systemPrompts/visionPrompt.js +4 -2
- package/dist/ai/llmprompts/systemPrompts/visionPromptMobile.js +1 -0
- package/dist/ai/llmprompts/systemPrompts/waitActionExtractorPrompt.js +10 -9
- package/dist/ai/llmprompts/systemPrompts/waitActionExtractorPromptMob.js +8 -7
- package/dist/ai/llmprompts/userPrompts/userPrompt.js +7 -8
- package/dist/automation/actions/executor.d.ts +38 -34
- package/dist/automation/actions/executor.js +280 -166
- package/dist/automation/actions/interaction/alert/clickCancelOnAlertPopup.js +4 -4
- package/dist/automation/actions/interaction/alert/clickOkOnAlertPopup.js +4 -4
- package/dist/automation/actions/interaction/alert/enterDataToAlert.js +4 -3
- package/dist/automation/actions/interaction/alert/getTextPresentOnAlertPopup.js +4 -4
- package/dist/automation/actions/interaction/alert/verifyAlertPopUpMessageContainsString.js +4 -3
- package/dist/automation/actions/interaction/alert/verifyAlertPopupIsDisplayed.js +10 -4
- package/dist/automation/actions/interaction/alert/verifyTextPresentOnAlertPopup.js +4 -3
- package/dist/automation/actions/interaction/alert/waitTillAlertIsPresent.js +5 -5
- package/dist/automation/actions/interaction/clear/clear.js +33 -26
- package/dist/automation/actions/interaction/clear/clearAndEnter.js +33 -26
- package/dist/automation/actions/interaction/click/MOB_DoubleTapAtSpecifiedLocation.js +5 -6
- package/dist/automation/actions/interaction/click/click.js +57 -25
- package/dist/automation/actions/interaction/click/clickNtimes.js +29 -24
- package/dist/automation/actions/interaction/click/clickUsingJs.js +12 -12
- package/dist/automation/actions/interaction/click/doubleClick.js +32 -25
- package/dist/automation/actions/interaction/click/rightClick.js +18 -13
- package/dist/automation/actions/interaction/click/tapOnSpecifiedLocation.js +7 -5
- package/dist/automation/actions/interaction/click/waitAndClick.js +29 -27
- package/dist/automation/actions/interaction/dragAndDrop/dragAndDrop.js +2 -2
- package/dist/automation/actions/interaction/elementLessAction/MobCheckIfAppIsClosed.js +14 -9
- package/dist/automation/actions/interaction/elementLessAction/MobRunAppInBackgroundInterface.js +9 -9
- package/dist/automation/actions/interaction/elementlessActions/activateAppUsingAppPackage.d.ts +0 -3
- package/dist/automation/actions/interaction/elementlessActions/activateAppUsingAppPackage.js +8 -9
- package/dist/automation/actions/interaction/elementlessActions/installAPK.js +74 -33
- package/dist/automation/actions/interaction/elementlessActions/isAppInstalled.js +10 -8
- package/dist/automation/actions/interaction/elementlessActions/openAppWithApkFilePath.js +87 -68
- package/dist/automation/actions/interaction/elementlessActions/openMobileApplication.js +8 -6
- package/dist/automation/actions/interaction/elementlessActions/receiveMessageOnEmulator.js +4 -3
- package/dist/automation/actions/interaction/elementlessActions/terminateAppUsingAppPackage.js +8 -6
- package/dist/automation/actions/interaction/elementlessActions/uninstallAPK.js +76 -32
- package/dist/automation/actions/interaction/enterActions/EnterInputIntoElementFromClipBoardInterface_mob.js +17 -13
- package/dist/automation/actions/interaction/enterActions/enterInput.js +50 -30
- package/dist/automation/actions/interaction/enterActions/enterInputAndPress.js +32 -24
- package/dist/automation/actions/interaction/enterActions/enterUrl.js +22 -17
- package/dist/automation/actions/interaction/enterActions/enterusingJs.js +19 -13
- package/dist/automation/actions/interaction/enterActions/waitAndEnter.js +33 -26
- package/dist/automation/actions/interaction/find/MOB_FindElement.js +37 -21
- package/dist/automation/actions/interaction/find/findElements.js +49 -32
- package/dist/automation/actions/interaction/get/MOB_GetADBLogsForGivenAppPackage.js +5 -6
- package/dist/automation/actions/interaction/get/MOB_GetAllContexts.js +4 -6
- package/dist/automation/actions/interaction/get/MOB_GetAllWindowHandles.js +8 -9
- package/dist/automation/actions/interaction/get/MOB_GetAltitude.js +20 -10
- package/dist/automation/actions/interaction/get/MOB_GetBatteryPercentage.js +7 -9
- package/dist/automation/actions/interaction/get/MOB_GetBatteryStatus.js +4 -6
- package/dist/automation/actions/interaction/get/MOB_GetClipBoardText.js +4 -6
- package/dist/automation/actions/interaction/get/MOB_GetCurrentActivity.js +4 -6
- package/dist/automation/actions/interaction/get/MOB_GetCurrentAppPackage.js +4 -6
- package/dist/automation/actions/interaction/get/MOB_GetCurrentContext.js +4 -6
- package/dist/automation/actions/interaction/get/MOB_GetCurrentDeviceDate.js +4 -6
- package/dist/automation/actions/interaction/get/MOB_GetCurrentDeviceSettings.js +4 -6
- package/dist/automation/actions/interaction/get/MOB_GetCurrentDeviceStatus.js +4 -6
- package/dist/automation/actions/interaction/get/MOB_GetCurrentDeviceSystemBars.js +5 -6
- package/dist/automation/actions/interaction/get/MOB_GetCurrentDeviceTime.js +4 -6
- package/dist/automation/actions/interaction/get/MOB_GetCurrentOrientation.js +4 -6
- package/dist/automation/actions/interaction/get/MOB_GetCurrentSessionId.js +4 -6
- package/dist/automation/actions/interaction/get/MOB_GetDeviceLocation.js +20 -9
- package/dist/automation/actions/interaction/get/MOB_GetDeviceName.js +7 -8
- package/dist/automation/actions/interaction/get/MOB_GetDeviceOsVersion.js +4 -6
- package/dist/automation/actions/interaction/get/MOB_GetDeviceUdid.js +7 -8
- package/dist/automation/actions/interaction/get/MOB_GetHeightOfElement.js +12 -11
- package/dist/automation/actions/interaction/get/MOB_GetHeightOfScreen.js +4 -6
- package/dist/automation/actions/interaction/get/MOB_GetHourFromCurrentDeviceTime.js +4 -6
- package/dist/automation/actions/interaction/get/MOB_GetLatitude.js +20 -12
- package/dist/automation/actions/interaction/get/MOB_GetLongitude.js +20 -12
- package/dist/automation/actions/interaction/get/MOB_GetMinuteFromCurrentDeviceTime.js +4 -6
- package/dist/automation/actions/interaction/get/MOB_GetSecondFromCurrentDeviceTime.js +4 -6
- package/dist/automation/actions/interaction/get/MOB_GetSizeOfScreen.js +4 -6
- package/dist/automation/actions/interaction/get/MOB_GetSupportedPerformanceDataTypes.js +4 -6
- package/dist/automation/actions/interaction/get/MOB_GetTextFromElementAndSetToClipBoard.js +11 -8
- package/dist/automation/actions/interaction/get/MOB_GetWidthOfElement.js +12 -11
- package/dist/automation/actions/interaction/get/MOB_GetWidthOfScreen.js +4 -6
- package/dist/automation/actions/interaction/get/browserWindowGetPosition.js +4 -4
- package/dist/automation/actions/interaction/get/getAllBrokenImages.js +4 -4
- package/dist/automation/actions/interaction/get/getAllBrokenLinkCount.js +4 -4
- package/dist/automation/actions/interaction/get/getAllBrokenLinks.js +5 -5
- package/dist/automation/actions/interaction/get/getAllConsoleErrors.js +4 -4
- package/dist/automation/actions/interaction/get/getAllConsoleInformation.js +5 -5
- package/dist/automation/actions/interaction/get/getAllConsoleLogs.js +5 -5
- package/dist/automation/actions/interaction/get/getAllConsoleWarnings.js +5 -5
- package/dist/automation/actions/interaction/get/getAllCookieNames.js +5 -5
- package/dist/automation/actions/interaction/get/getAllCookieValues.js +5 -5
- package/dist/automation/actions/interaction/get/getAllSelectedOptions.js +12 -12
- package/dist/automation/actions/interaction/get/getAllTheOptionsFromListBoxAsText.js +12 -12
- package/dist/automation/actions/interaction/get/getAllTheOptionsFromListBoxAsTextInSortedOrder.js +12 -12
- package/dist/automation/actions/interaction/get/getAllTheSelectedOptionsFromListBoxAsText.js +12 -12
- package/dist/automation/actions/interaction/get/getAllWindowHandles.js +5 -5
- package/dist/automation/actions/interaction/get/getAttribute.js +27 -25
- package/dist/automation/actions/interaction/get/getAudioCurrentPlaybackRate.js +12 -12
- package/dist/automation/actions/interaction/get/getAudioCurrentSeekTime.js +12 -12
- package/dist/automation/actions/interaction/get/getAudioCurrentVolume.js +12 -12
- package/dist/automation/actions/interaction/get/getAudioDecodedByte.js +12 -12
- package/dist/automation/actions/interaction/get/getAudioDefaultPlaybackRate.js +12 -12
- package/dist/automation/actions/interaction/get/getAudioMediaLength.js +12 -12
- package/dist/automation/actions/interaction/get/getAudioMediaSource.js +12 -12
- package/dist/automation/actions/interaction/get/getBestPracticesScore.js +4 -3
- package/dist/automation/actions/interaction/get/getBrowserCount.js +4 -4
- package/dist/automation/actions/interaction/get/getBrowserVersion.js +4 -4
- package/dist/automation/actions/interaction/get/getCapabilityNames.js +4 -4
- package/dist/automation/actions/interaction/get/getClipBoardText.js +4 -4
- package/dist/automation/actions/interaction/get/getCollectiveApiResponseTime.js +5 -4
- package/dist/automation/actions/interaction/get/getCollectiveApiStatusCode.js +5 -4
- package/dist/automation/actions/interaction/get/getCssValue.js +12 -12
- package/dist/automation/actions/interaction/get/getCurrentDayOfTheWeek.js +4 -4
- package/dist/automation/actions/interaction/get/getCurrentSecondsFromCurrentSystemTime.js +5 -5
- package/dist/automation/actions/interaction/get/getCurrentSystemDate.js +4 -4
- package/dist/automation/actions/interaction/get/getCurrentSystemDay.js +5 -5
- package/dist/automation/actions/interaction/get/getCurrentSystemMonth.js +5 -5
- package/dist/automation/actions/interaction/get/getCurrentSystemTime.js +5 -5
- package/dist/automation/actions/interaction/get/getCurrentSystemYear.js +5 -5
- package/dist/automation/actions/interaction/get/getCurrentWindowHandle.js +9 -10
- package/dist/automation/actions/interaction/get/getDataFromApiRequestHeaderForJsonPath.js +5 -4
- package/dist/automation/actions/interaction/get/getDataFromApiResponseForJsonPath.js +5 -4
- package/dist/automation/actions/interaction/get/getDateWithGivenFormat.js +5 -4
- package/dist/automation/actions/interaction/get/getDriverInstance.js +12 -11
- package/dist/automation/actions/interaction/get/getFirstContentfulPaint.js +5 -5
- package/dist/automation/actions/interaction/get/getFirstSelectedOption.js +12 -12
- package/dist/automation/actions/interaction/get/getFullPaintTime.js +5 -5
- package/dist/automation/actions/interaction/get/getHTMLCodeOfPage.js +4 -4
- package/dist/automation/actions/interaction/get/getHeightOfBrowserWindow.js +4 -4
- package/dist/automation/actions/interaction/get/getHeightOfWebElement.js +12 -12
- package/dist/automation/actions/interaction/get/getHourFromCurrentSystemTime.js +4 -4
- package/dist/automation/actions/interaction/get/getImplicitTimeOut.js +11 -10
- package/dist/automation/actions/interaction/get/getLargestContentfulPaint.js +4 -4
- package/dist/automation/actions/interaction/get/getListBoxSize.js +12 -12
- package/dist/automation/actions/interaction/get/getListOfElementsFromLocatorTypeLocatorValue.js +90 -44
- package/dist/automation/actions/interaction/get/getLocation.js +32 -31
- package/dist/automation/actions/interaction/get/getMinuteFromCurrentSystemTime.js +4 -4
- package/dist/automation/actions/interaction/get/getNetworkRouteTime.js +4 -4
- package/dist/automation/actions/interaction/get/getNumberOfBrokenImages.js +4 -4
- package/dist/automation/actions/interaction/get/getNumberOfLinksPresentInCurrentPage.js +4 -4
- package/dist/automation/actions/interaction/get/getNumberOfWorkingLinksFromCurrentPage.js +4 -4
- package/dist/automation/actions/interaction/get/getOptions.js +12 -12
- package/dist/automation/actions/interaction/get/getPageTitle.js +5 -5
- package/dist/automation/actions/interaction/get/getPerformanceMetrics.js +5 -5
- package/dist/automation/actions/interaction/get/getPwaScore.js +5 -4
- package/dist/automation/actions/interaction/get/getRect.js +26 -23
- package/dist/automation/actions/interaction/get/getScreenshot.js +12 -18
- package/dist/automation/actions/interaction/get/getScreenshotAs.js +27 -32
- package/dist/automation/actions/interaction/get/getSeoScore.js +5 -4
- package/dist/automation/actions/interaction/get/getSingleApiRequestPayload.js +7 -6
- package/dist/automation/actions/interaction/get/getSingleApiResponse.js +12 -14
- package/dist/automation/actions/interaction/get/getSingleApiResponseTime.js +13 -13
- package/dist/automation/actions/interaction/get/getSingleApiStatusCode.d.ts +1 -1
- package/dist/automation/actions/interaction/get/getSingleApiStatusCode.js +21 -17
- package/dist/automation/actions/interaction/get/getSize.js +26 -24
- package/dist/automation/actions/interaction/get/getSizeOfBrowserWindow.js +5 -5
- package/dist/automation/actions/interaction/get/getStringDataFromLocalFile.js +11 -13
- package/dist/automation/actions/interaction/get/getSystemProperty.js +7 -33
- package/dist/automation/actions/interaction/get/getTagName.js +26 -24
- package/dist/automation/actions/interaction/get/getText.js +28 -25
- package/dist/automation/actions/interaction/get/getTheFirstSelectedOptionFromListBoxAsText.js +12 -12
- package/dist/automation/actions/interaction/get/getTotalNumberOfCookies.js +5 -5
- package/dist/automation/actions/interaction/get/getTunnelIdentifier.js +5 -4
- package/dist/automation/actions/interaction/get/getURLPresentInAddressBar.js +5 -5
- package/dist/automation/actions/interaction/get/getUserHomeDirectory.js +5 -5
- package/dist/automation/actions/interaction/get/getValueByCookieName.js +7 -11
- package/dist/automation/actions/interaction/get/getValueFromLocalStorage.js +7 -10
- package/dist/automation/actions/interaction/get/getValueOfSystemVariable.js +8 -6
- package/dist/automation/actions/interaction/get/getVideoCurrentPlaybackRate.js +12 -12
- package/dist/automation/actions/interaction/get/getVideoCurrentSeekTime.js +12 -12
- package/dist/automation/actions/interaction/get/getVideoCurrentVolume.js +12 -12
- package/dist/automation/actions/interaction/get/getVideoDecodedByte.js +12 -12
- package/dist/automation/actions/interaction/get/getVideoDefaultPlaybackRate.js +12 -12
- package/dist/automation/actions/interaction/get/getVideoMediaLength.js +12 -12
- package/dist/automation/actions/interaction/get/getVideoMediaSource.js +12 -12
- package/dist/automation/actions/interaction/get/getWidthOfBrowser.js +5 -5
- package/dist/automation/actions/interaction/get/getWidthOfWebElement.js +12 -12
- package/dist/automation/actions/interaction/get/getWorkingLinksFromCurrentPage.js +5 -5
- package/dist/automation/actions/interaction/get/getWrappedElement.js +12 -12
- package/dist/automation/actions/interaction/get/getWrappedOptionFromListBoxAsText.js +14 -14
- package/dist/automation/actions/interaction/get/getXLocationOfBrowserWindow.js +5 -4
- package/dist/automation/actions/interaction/get/getXLocationOfWebElement.js +26 -24
- package/dist/automation/actions/interaction/get/getYLocationOfBrowserWindow.js +5 -5
- package/dist/automation/actions/interaction/get/getYLocationOfWebElement.js +26 -24
- package/dist/automation/actions/interaction/iframe/switchToDefaultContent.js +5 -5
- package/dist/automation/actions/interaction/inputlessActions/AirplaneModeSwitchOff.js +5 -5
- package/dist/automation/actions/interaction/inputlessActions/AirplaneModeSwitchOn.js +5 -5
- package/dist/automation/actions/interaction/inputlessActions/Break.js +5 -5
- package/dist/automation/actions/interaction/inputlessActions/Continue.js +5 -5
- package/dist/automation/actions/interaction/inputlessActions/GpsSwitchOff.js +5 -5
- package/dist/automation/actions/interaction/inputlessActions/GpsSwitchOn.js +5 -5
- package/dist/automation/actions/interaction/inputlessActions/HideKeyboard.js +13 -7
- package/dist/automation/actions/interaction/inputlessActions/LockDevice.js +5 -5
- package/dist/automation/actions/interaction/inputlessActions/OpenChromeBrowser.js +18 -6
- package/dist/automation/actions/interaction/inputlessActions/OpenNotification.js +5 -5
- package/dist/automation/actions/interaction/inputlessActions/ResetApp.js +14 -7
- package/dist/automation/actions/interaction/inputlessActions/RestartCurrentDevice.js +5 -5
- package/dist/automation/actions/interaction/inputlessActions/SetDeviceOrientationAsLandscape.js +5 -5
- package/dist/automation/actions/interaction/inputlessActions/SetDeviceOrientationAsPortrait.js +5 -5
- package/dist/automation/actions/interaction/inputlessActions/SetEmulatorPowerStateOff.js +5 -5
- package/dist/automation/actions/interaction/inputlessActions/SetEmulatorPowerStateOn.js +5 -5
- package/dist/automation/actions/interaction/inputlessActions/WifiSwitchOff.js +5 -5
- package/dist/automation/actions/interaction/inputlessActions/WifiSwitchOn.js +5 -5
- package/dist/automation/actions/interaction/maximize/maximize.js +5 -5
- package/dist/automation/actions/interaction/maximize/minimize.js +5 -5
- package/dist/automation/actions/interaction/mouse/mouseClickOnCurrentCursorNTImes.d.ts +2 -0
- package/dist/automation/actions/interaction/mouse/mouseClickOnCurrentCursorNTImes.js +31 -0
- package/dist/automation/actions/interaction/mouse/mouseClickOnCurrentCursorPoint.d.ts +2 -0
- package/dist/automation/actions/interaction/mouse/mouseClickOnCurrentCursorPoint.js +27 -0
- package/dist/automation/actions/interaction/mouse/mouseDoubleClickAtCursorPoint.d.ts +2 -0
- package/dist/automation/actions/interaction/mouse/mouseDoubleClickAtCursorPoint.js +31 -0
- package/dist/automation/actions/interaction/mouse/mouseHover.d.ts +2 -0
- package/dist/automation/actions/interaction/mouse/mouseHover.js +36 -0
- package/dist/automation/actions/interaction/mouse/mouseReleaseLeftMouseButton.d.ts +2 -0
- package/dist/automation/actions/interaction/mouse/mouseReleaseLeftMouseButton.js +42 -0
- package/dist/automation/actions/interaction/mouse/pressAndHold.d.ts +2 -0
- package/dist/automation/actions/interaction/mouse/pressAndHold.js +47 -0
- package/dist/automation/actions/interaction/navigation/goBack.js +5 -5
- package/dist/automation/actions/interaction/navigation/navigate.js +5 -4
- package/dist/automation/actions/interaction/navigation/refresh.js +5 -5
- package/dist/automation/actions/interaction/pinch/PinchInByPercentMob.js +12 -13
- package/dist/automation/actions/interaction/pinch/PinchOutByPercentMob.js +12 -11
- package/dist/automation/actions/interaction/press/longPress.js +15 -11
- package/dist/automation/actions/interaction/press/mobPressBackKey.js +4 -6
- package/dist/automation/actions/interaction/press/mobPressBackSpaceKey.js +12 -8
- package/dist/automation/actions/interaction/press/mobPressSpaceKey.js +12 -8
- package/dist/automation/actions/interaction/press/pressAnyKey.js +25 -16
- package/dist/automation/actions/interaction/press/pressAnyKeyNTimes.js +23 -14
- package/dist/automation/actions/interaction/press/pressEnterKey.js +21 -14
- package/dist/automation/actions/interaction/press/pressHomeKey.js +16 -9
- package/dist/automation/actions/interaction/scroll/scrollHorizontallyTillElementIsVisible.js +20 -15
- package/dist/automation/actions/interaction/scroll/scrollPageToSpecificLocation.js +8 -7
- package/dist/automation/actions/interaction/scroll/scrollToElement.js +18 -13
- package/dist/automation/actions/interaction/scroll/scrollVerticallyTillElementIsVisible.js +20 -15
- package/dist/automation/actions/interaction/set/MOB_SetContext.js +5 -6
- package/dist/automation/actions/interaction/set/MOB_SetEmulatorPowerPercentage.js +5 -6
- package/dist/automation/actions/interaction/set/setClipBoardText.js +13 -13
- package/dist/automation/actions/interaction/shadowDom/shadowDomClick.js +5 -4
- package/dist/automation/actions/interaction/shadowDom/shadowDomEnter.js +5 -4
- package/dist/automation/actions/interaction/shadowDom/shadowDomGetText.js +6 -5
- package/dist/automation/actions/interaction/shadowDom/shadowDomUpload.js +13 -9
- package/dist/automation/actions/interaction/shadowDom/shadowDomVerifyPartialText.js +6 -5
- package/dist/automation/actions/interaction/shadowDom/shadowDomVerifyText.js +6 -5
- package/dist/automation/actions/interaction/swipe/swipeDirectionNTimes.js +12 -10
- package/dist/automation/actions/interaction/swipe/swipeDownToElement.js +13 -10
- package/dist/automation/actions/interaction/swipe/swipeIos.d.ts +2 -0
- package/dist/automation/actions/interaction/swipe/swipeIos.js +52 -0
- package/dist/automation/actions/interaction/swipe/swipeLeftToElement.js +16 -11
- package/dist/automation/actions/interaction/swipe/swipeRightToElement.js +15 -10
- package/dist/automation/actions/interaction/swipe/swipeUpToElement.js +12 -10
- package/dist/automation/actions/interaction/swipe/swipeUpToElementForMWeb.js +16 -13
- package/dist/automation/actions/interaction/swipe/swipeUsingReferenceElement.js +19 -16
- package/dist/automation/actions/interaction/switch/switchToNewTabBasedOnTitle.js +7 -6
- package/dist/automation/actions/interaction/switch/switchToNewWindowBasedOnTitle.js +6 -5
- package/dist/automation/actions/interaction/switch/switchToParentWindow.js +6 -6
- package/dist/automation/actions/interaction/switch/switchToTabBasedOnUrl.js +6 -5
- package/dist/automation/actions/interaction/switch/switchToWindowBasedOnURL.js +5 -4
- package/dist/automation/actions/interaction/switch/switchToWindowIfTitleContainsString.js +7 -6
- package/dist/automation/actions/interaction/switch/switchToWindowIfUrlContainsString.js +6 -5
- package/dist/automation/actions/interaction/upload/uploadfile.js +21 -18
- package/dist/automation/actions/interaction/verify/MOB_VerifyBatteryLevel.js +8 -8
- package/dist/automation/actions/interaction/verify/MOB_VerifyIfAirplaneModeOff.js +7 -7
- package/dist/automation/actions/interaction/verify/MOB_VerifyIfAirplaneModeOn.js +7 -7
- package/dist/automation/actions/interaction/verify/MOB_VerifyIfAppIsClosed.js +19 -10
- package/dist/automation/actions/interaction/verify/MOB_VerifyIfDeviceIsLocked.js +7 -6
- package/dist/automation/actions/interaction/verify/MOB_VerifyIfDeviceIsUnlocked.js +7 -7
- package/dist/automation/actions/interaction/verify/MOB_VerifyIfGpsOff.js +12 -8
- package/dist/automation/actions/interaction/verify/MOB_VerifyIfGpsOn.js +12 -8
- package/dist/automation/actions/interaction/verify/MOB_VerifyIfKeyboardIsHidden.js +7 -7
- package/dist/automation/actions/interaction/verify/MOB_VerifyIfKeyboardIsShown.js +8 -7
- package/dist/automation/actions/interaction/verify/MOB_VerifyIfWifiOff.js +8 -7
- package/dist/automation/actions/interaction/verify/MOB_VerifyIfWifiOn.js +8 -7
- package/dist/automation/actions/interaction/verify/VerifyAccessibilityScore.js +8 -7
- package/dist/automation/actions/interaction/verify/VerifyAllBrokenImages.js +6 -6
- package/dist/automation/actions/interaction/verify/VerifyAllBrowserWindowsClosed.js +12 -10
- package/dist/automation/actions/interaction/verify/VerifyAllOptionsAreDeSelected.js +19 -19
- package/dist/automation/actions/interaction/verify/VerifyAllOptionsAreSelected.js +12 -12
- package/dist/automation/actions/interaction/verify/VerifyAttributeValue.js +35 -53
- package/dist/automation/actions/interaction/verify/VerifyBestPracticesScore.js +6 -5
- package/dist/automation/actions/interaction/verify/VerifyBrowserHtmlCodeContainsString.js +6 -5
- package/dist/automation/actions/interaction/verify/VerifyBrowserWindowHeight.js +7 -6
- package/dist/automation/actions/interaction/verify/VerifyBrowserWindowTitleContainsString.js +7 -6
- package/dist/automation/actions/interaction/verify/VerifyBrowserWindowTitleIsString.js +7 -6
- package/dist/automation/actions/interaction/verify/VerifyBrowserWindowUrlContainsExpectedUrl.js +6 -5
- package/dist/automation/actions/interaction/verify/VerifyBrowserWindowUrlIsString.js +5 -4
- package/dist/automation/actions/interaction/verify/VerifyBrowserWindowWidth.js +6 -5
- package/dist/automation/actions/interaction/verify/VerifyBrowserWindowXLocation.js +6 -5
- package/dist/automation/actions/interaction/verify/VerifyBrowserWindowYLocation.js +7 -6
- package/dist/automation/actions/interaction/verify/VerifyCheckBoxIsNotSelected.js +12 -12
- package/dist/automation/actions/interaction/verify/VerifyCheckBoxIsSelected.js +12 -12
- package/dist/automation/actions/interaction/verify/VerifyCssAttributeValue.js +20 -14
- package/dist/automation/actions/interaction/verify/VerifyElementIsClickable.js +28 -25
- package/dist/automation/actions/interaction/verify/VerifyElementIsDisabled.js +29 -27
- package/dist/automation/actions/interaction/verify/VerifyElementIsDisplayed.js +26 -24
- package/dist/automation/actions/interaction/verify/VerifyElementIsEnabled.js +26 -24
- package/dist/automation/actions/interaction/verify/VerifyElementIsEnabledInSpecifiedTime.d.ts +2 -0
- package/dist/automation/actions/interaction/verify/VerifyElementIsEnabledInSpecifiedTime.js +84 -0
- package/dist/automation/actions/interaction/verify/VerifyElementIsNotDisplayed.js +51 -28
- package/dist/automation/actions/interaction/verify/VerifyElementIsSelected.js +39 -27
- package/dist/automation/actions/interaction/verify/VerifyElementIsSelectedInSpecifiedTime.d.ts +2 -0
- package/dist/automation/actions/interaction/verify/VerifyElementIsSelectedInSpecifiedTime.js +83 -0
- package/dist/automation/actions/interaction/verify/VerifyElementNotContainsText.js +23 -23
- package/dist/automation/actions/interaction/verify/VerifyHeightOfWebElement.js +23 -23
- package/dist/automation/actions/interaction/verify/VerifyHexCodeForGivenXYCoordinates.js +44 -14
- package/dist/automation/actions/interaction/verify/VerifyIfAllCookiesAreDeleted.js +4 -4
- package/dist/automation/actions/interaction/verify/VerifyIfAudioEnded.js +12 -12
- package/dist/automation/actions/interaction/verify/VerifyIfAudioIsMuted.js +12 -12
- package/dist/automation/actions/interaction/verify/VerifyIfAudioIsPaused.js +12 -12
- package/dist/automation/actions/interaction/verify/VerifyIfAudioIsPlaying.js +12 -12
- package/dist/automation/actions/interaction/verify/VerifyIfBrowserWindowIsClosed.js +8 -9
- package/dist/automation/actions/interaction/verify/VerifyIfCookieNameIsAdded.js +6 -5
- package/dist/automation/actions/interaction/verify/VerifyIfCookieNameIsDeleted.js +5 -4
- package/dist/automation/actions/interaction/verify/VerifyIfCookieObjectIsPresent.js +5 -5
- package/dist/automation/actions/interaction/verify/VerifyIfGivenOptionIsDuplicate.js +14 -14
- package/dist/automation/actions/interaction/verify/VerifyIfImageIsBroken.js +6 -5
- package/dist/automation/actions/interaction/verify/VerifyIfLinkIsBroken.js +6 -5
- package/dist/automation/actions/interaction/verify/VerifyIfLinkIsWorking.js +6 -5
- package/dist/automation/actions/interaction/verify/VerifyIfLinksAreBroken.js +5 -4
- package/dist/automation/actions/interaction/verify/VerifyIfLinksAreWorking.js +5 -4
- package/dist/automation/actions/interaction/verify/VerifyIfOptionWithIndexIsDeselectedInElement.js +13 -13
- package/dist/automation/actions/interaction/verify/VerifyIfOptionWithIndexIsSelectedInListBox.js +13 -13
- package/dist/automation/actions/interaction/verify/VerifyIfOptionWithTextIsDeselected.js +12 -12
- package/dist/automation/actions/interaction/verify/VerifyIfOptionWithValueIsDeselected.js +12 -12
- package/dist/automation/actions/interaction/verify/VerifyIfOptionWithValueIsSelected.js +12 -12
- package/dist/automation/actions/interaction/verify/VerifyIfOptionWithVisibleTextIsSelected.js +12 -12
- package/dist/automation/actions/interaction/verify/VerifyIfSpecifiedOptionIsSelected.js +12 -12
- package/dist/automation/actions/interaction/verify/VerifyIfStatusCodeOfALinkIsStatusCode.js +7 -6
- package/dist/automation/actions/interaction/verify/VerifyIfStatusCodesOfLinks.js +30 -22
- package/dist/automation/actions/interaction/verify/VerifyIfVideoEnded.js +12 -12
- package/dist/automation/actions/interaction/verify/VerifyIfVideoIsMuted.js +12 -12
- package/dist/automation/actions/interaction/verify/VerifyIfVideoIsPaused.js +12 -12
- package/dist/automation/actions/interaction/verify/VerifyIfVideoIsPlaying.js +12 -12
- package/dist/automation/actions/interaction/verify/VerifyIfVideoPlayingInMute.js +12 -12
- package/dist/automation/actions/interaction/verify/VerifyIfVideoPlayingInUnmute.js +12 -12
- package/dist/automation/actions/interaction/verify/VerifyIfXAndYCoordinateOfElement.js +25 -23
- package/dist/automation/actions/interaction/verify/VerifyLinkNavigatesToTitle.js +7 -6
- package/dist/automation/actions/interaction/verify/VerifyListBoxOptionsAreSorted.js +12 -12
- package/dist/automation/actions/interaction/verify/VerifyNavigateURL.js +6 -5
- package/dist/automation/actions/interaction/verify/VerifyNumberOfElementsByTagName.js +7 -5
- package/dist/automation/actions/interaction/verify/VerifyNumberOfElementsByXpath.js +13 -7
- package/dist/automation/actions/interaction/verify/VerifyPartialAttributeValue.js +33 -42
- package/dist/automation/actions/interaction/verify/VerifyPartialTitleOfCurrentPage.js +7 -6
- package/dist/automation/actions/interaction/verify/VerifyPerformanceScore.js +7 -6
- package/dist/automation/actions/interaction/verify/VerifyPwaScore.js +6 -5
- package/dist/automation/actions/interaction/verify/VerifyRadioButtonIsNotSelected.js +12 -12
- package/dist/automation/actions/interaction/verify/VerifyRadioButtonIsSelected.js +12 -12
- package/dist/automation/actions/interaction/verify/VerifySeoScore.js +6 -5
- package/dist/automation/actions/interaction/verify/VerifyTagName.js +12 -12
- package/dist/automation/actions/interaction/verify/VerifyThatSpecifiedOptionIsNotSelected.js +20 -31
- package/dist/automation/actions/interaction/verify/VerifyTitleInAllPage.js +8 -7
- package/dist/automation/actions/interaction/verify/VerifyTitleOfCurrentPage.js +6 -5
- package/dist/automation/actions/interaction/verify/VerifyValueOfElementContainsString.js +12 -12
- package/dist/automation/actions/interaction/verify/VerifyValueOfElementIsCleared.js +12 -12
- package/dist/automation/actions/interaction/verify/VerifyValueOfElementIsString.js +12 -12
- package/dist/automation/actions/interaction/verify/VerifyWidthOfElement.js +23 -23
- package/dist/automation/actions/interaction/verify/VerifyXLocationOfElement.js +23 -23
- package/dist/automation/actions/interaction/verify/VerifyYLocationOfElement.js +26 -23
- package/dist/automation/actions/interaction/verify/checkIfElementIsDisplayed.js +26 -22
- package/dist/automation/actions/interaction/verify/verifyElementIsDisplayedWithinSpecifiedTime.d.ts +2 -0
- package/dist/automation/actions/interaction/verify/verifyElementIsDisplayedWithinSpecifiedTime.js +85 -0
- package/dist/automation/actions/interaction/verify/verifypartialtext.js +28 -25
- package/dist/automation/actions/interaction/verify/verifytext.js +30 -30
- package/dist/automation/actions/interaction/wait/MOB_WaitTillAllElementsAreInvisible.ts.js +5 -6
- package/dist/automation/actions/interaction/wait/MOB_WaitTillAttributeOfElementContainsString.js +17 -14
- package/dist/automation/actions/interaction/wait/MOB_WaitTillElementIsEnabled.js +12 -11
- package/dist/automation/actions/interaction/wait/MOB_WaitTillElementIsInvisible.js +14 -12
- package/dist/automation/actions/interaction/wait/MOB_WaitTillElementIsSelected.js +12 -11
- package/dist/automation/actions/interaction/wait/MOB_WaitTillElementIsVisible.js +15 -13
- package/dist/automation/actions/interaction/wait/MOB_WaitTillStalenessOfElement.js +12 -11
- package/dist/automation/actions/interaction/wait/wait.js +5 -4
- package/dist/automation/actions/interaction/wait/waitTillAttributeOfElementIsString.js +26 -24
- package/dist/automation/actions/interaction/wait/waitTillElementContainsText.js +26 -24
- package/dist/automation/actions/interaction/wait/waitTillElementHasText.js +26 -24
- package/dist/automation/actions/interaction/wait/waitTillElementIsClickable.js +28 -25
- package/dist/automation/actions/interaction/wait/waitTillPresenceOfAllElements.js +32 -22
- package/dist/automation/actions/interaction/wait/waitTillPresenceOfElement.js +26 -24
- package/dist/automation/actions/interface/FireFlinkResponseSchema.d.ts +148 -0
- package/dist/automation/actions/interface/FireFlinkResponseSchema.js +209 -0
- package/dist/automation/actions/interface/alertActionInterface.d.ts +1 -0
- package/dist/automation/actions/interface/findActionInterface.d.ts +3 -0
- package/dist/automation/actions/interface/getActionInterface.d.ts +76 -66
- package/dist/automation/actions/interface/interactionActionInterface.d.ts +5 -0
- package/dist/automation/actions/interface/mouseActionsinterface.d.ts +51 -0
- package/dist/automation/actions/interface/mouseActionsinterface.js +2 -0
- package/dist/automation/actions/interface/pinchActionInterface.d.ts +7 -0
- package/dist/automation/actions/interface/pressActionInterface.d.ts +4 -0
- package/dist/automation/actions/interface/swipeActionInterface.d.ts +25 -10
- package/dist/automation/actions/interface/verifyActionInterface.d.ts +36 -0
- package/dist/automation/actions/interface/waitActionInterface.d.ts +19 -0
- package/dist/automation/browserSession/initiateBrowserSession.d.ts +1 -1
- package/dist/automation/browserSession/initiateBrowserSession.js +4 -4
- package/dist/automation/cloudSession/initiateCloudSession.js +3 -1
- package/dist/automation/mobileSession/initiateMobileSession.d.ts +25 -1
- package/dist/automation/mobileSession/initiateMobileSession.js +23 -10
- package/dist/core/constants/allAction.js +2 -1
- package/dist/core/constants/supportedActions.d.ts +1 -0
- package/dist/core/constants/supportedActions.js +17 -9
- package/dist/core/interfaces/actionInterface.d.ts +34 -33
- package/dist/core/interfaces/fireflinkScriptPayloadInterface.d.ts +4 -1
- package/dist/core/interfaces/llmConfigurationInterface.d.ts +3 -2
- package/dist/core/interfaces/llmResponseInterface.d.ts +10 -10
- package/dist/core/interfaces/scriptGenrationDataInterface.d.ts +14 -0
- package/dist/core/interfaces/simplifyAndFlattenInterface.d.ts +5 -0
- package/dist/core/main/actionHandlerFactory.js +134 -64
- package/dist/core/main/executionContext.d.ts +1 -1
- package/dist/core/main/executionContext.js +1 -1
- package/dist/core/main/runAutomationScript.d.ts +1 -0
- package/dist/core/main/runAutomationScript.js +207 -88
- package/dist/core/main/stepProcessor.d.ts +2 -1
- package/dist/core/main/stepProcessor.js +2 -2
- package/dist/core/types/scriptTypesType.d.ts +1 -1
- package/dist/core/types/visionllmInputType.d.ts +4 -5
- package/dist/domAnalysis/getRelaventElements.d.ts +5 -1
- package/dist/domAnalysis/getRelaventElements.js +14 -5
- package/dist/domAnalysis/relativeElementsFromDom.d.ts +2 -1
- package/dist/domAnalysis/relativeElementsFromDom.js +66 -1
- package/dist/domAnalysis/searchBest.d.ts +5 -1
- package/dist/domAnalysis/searchBest.js +153 -50
- package/dist/domAnalysis/simplifyAndFlatten.d.ts +3 -2
- package/dist/domAnalysis/simplifyAndFlatten.js +109 -16
- package/dist/fireflinkData/fireflinkLocators/getListOfLocators.js +17 -11
- package/dist/fireflinkData/fireflinkLocators/{elementsFromHTML.d.ts → parser/getElementsFromHTML.d.ts} +3 -9
- package/dist/fireflinkData/fireflinkLocators/parser/getElementsFromHTML.js +557 -0
- package/dist/fireflinkData/fireflinkLocators/types/locator.d.ts +17 -0
- package/dist/fireflinkData/fireflinkLocators/types/locator.js +2 -0
- package/dist/fireflinkData/fireflinkLocators/utils/androidSelector.d.ts +2 -0
- package/dist/fireflinkData/fireflinkLocators/utils/androidSelector.js +31 -0
- package/dist/fireflinkData/fireflinkLocators/utils/cssSelector.d.ts +19 -0
- package/dist/fireflinkData/fireflinkLocators/utils/cssSelector.js +192 -0
- package/dist/fireflinkData/fireflinkLocators/utils/iosSelector.d.ts +2 -0
- package/dist/fireflinkData/fireflinkLocators/utils/iosSelector.js +159 -0
- package/dist/fireflinkData/fireflinkLocators/utils/referenceXpath.d.ts +35 -0
- package/dist/fireflinkData/fireflinkLocators/utils/referenceXpath.js +590 -0
- package/dist/fireflinkData/fireflinkLocators/utils/xpath.d.ts +38 -0
- package/dist/fireflinkData/fireflinkLocators/utils/xpath.js +1182 -0
- package/dist/fireflinkData/fireflinkLocators/utils/xpathHelpers.d.ts +137 -0
- package/dist/fireflinkData/fireflinkLocators/utils/xpathHelpers.js +1647 -0
- package/dist/fireflinkData/fireflinkScript/appendScriptData.d.ts +2 -0
- package/dist/fireflinkData/fireflinkScript/appendScriptData.js +51 -0
- package/dist/fireflinkData/fireflinkScript/scriptGenrationData.js +4 -0
- package/dist/imageAnalysisMobile/annotatedScreenshotMobile.d.ts +4 -0
- package/dist/imageAnalysisMobile/annotatedScreenshotMobile.js +115 -7
- package/dist/imageAnalysisWeb/annotateScreenshot.js +4 -4
- package/dist/imageAnalysisWeb/generateAnnotatedScreenshots.d.ts +4 -1
- package/dist/imageAnalysisWeb/generateAnnotatedScreenshots.js +15 -17
- package/dist/llmConfig/llmConfiguration.d.ts +4 -3
- package/dist/llmConfig/llmConfiguration.js +41 -18
- package/dist/service/fireflink.service.d.ts +1 -1
- package/dist/service/fireflink.service.js +4 -4
- package/dist/tests/poc.d.ts +0 -1
- package/dist/tests/poc.js +211 -226
- package/dist/tests/test.d.ts +1 -0
- package/dist/tests/test.js +26 -0
- package/dist/tests/test12.js +19 -408
- package/dist/tests/testss.d.ts +1 -0
- package/dist/tests/testss.js +23 -0
- package/dist/utils/DomExtraction/jsForAttributeInjection.d.ts +2 -0
- package/dist/utils/DomExtraction/jsForAttributeInjection.js +220 -8
- package/dist/utils/InstancesDetails/getInstancesInfo.d.ts +26 -1
- package/dist/utils/InstancesDetails/getInstancesInfo.js +11 -5
- package/dist/utils/browserCap/capability.d.ts +10 -10
- package/dist/utils/browserCap/capability.js +21 -16
- package/dist/utils/frameWorkDetector/frameWorkDetector.d.ts +6 -0
- package/dist/utils/frameWorkDetector/frameWorkDetector.js +43 -0
- package/dist/utils/frameWorkDetector/frameWorkDetectorInterface.d.ts +10 -0
- package/dist/utils/frameWorkDetector/frameWorkDetectorInterface.js +2 -0
- package/dist/utils/helpers/enterActionHelper.d.ts +1 -0
- package/dist/utils/helpers/enterActionHelper.js +2 -1
- package/dist/utils/helpers/platformContext.d.ts +3 -0
- package/dist/utils/helpers/platformContext.js +11 -0
- package/dist/utils/helpers/platformSyntax.d.ts +1 -0
- package/dist/utils/helpers/platformSyntax.js +17 -0
- package/dist/utils/helpers/sameActionsHelper.js +7 -2
- package/dist/utils/helpers/xpathcreation.d.ts +5 -1
- package/dist/utils/helpers/xpathcreation.js +43 -4
- package/dist/utils/iframesExtraction/findElementUsingFF.js +12 -9
- package/dist/utils/iframesExtraction/iframeInterface.d.ts +4 -0
- package/dist/utils/javascript/jsForShadowRoot.d.ts +1 -1
- package/dist/utils/javascript/jsForShadowRoot.js +4 -0
- package/dist/utils/javascript/jsForVision.d.ts +2 -2
- package/dist/utils/javascript/jsForVision.js +17 -5
- package/dist/utils/logger/logData.d.ts +1 -0
- package/dist/utils/logger/logData.js +19 -0
- package/dist/utils/sslConfig/apiCallPatch.d.ts +1 -0
- package/dist/utils/sslConfig/apiCallPatch.js +33 -0
- package/dist/utils/sslConfig/getSecureAgent.d.ts +2 -0
- package/dist/utils/sslConfig/getSecureAgent.js +30 -0
- package/dist/utils/swipe/domSearchHelper.d.ts +1 -1
- package/dist/utils/swipe/domSearchHelper.js +43 -42
- package/dist/utils/swipe/swipeMovement.js +28 -19
- package/package.json +21 -6
- package/dist/automation/actions/interaction/get/getAudioDimension.d.ts +0 -2
- package/dist/automation/actions/interaction/get/getAudioDimension.js +0 -34
- package/dist/automation/actions/interaction/get/getAudioHeight.d.ts +0 -2
- package/dist/automation/actions/interaction/get/getAudioHeight.js +0 -30
- package/dist/automation/actions/interaction/get/getAudioWidth.d.ts +0 -2
- package/dist/automation/actions/interaction/get/getAudioWidth.js +0 -30
- package/dist/automation/actions/interaction/get/getVideoDimension.d.ts +0 -2
- package/dist/automation/actions/interaction/get/getVideoDimension.js +0 -31
- package/dist/automation/actions/interaction/get/getVideoHeight.d.ts +0 -2
- package/dist/automation/actions/interaction/get/getVideoHeight.js +0 -28
- package/dist/automation/actions/interaction/get/getVideoWidth.d.ts +0 -2
- package/dist/automation/actions/interaction/get/getVideoWidth.js +0 -28
- package/dist/fireflinkData/fireflinkLocators/elementsFromHTML.js +0 -514
- package/dist/fireflinkData/fireflinkLocators/typeList.d.ts +0 -1
- package/dist/fireflinkData/fireflinkLocators/typeList.js +0 -33
|
@@ -0,0 +1,1647 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.xpathUtils = exports.getPlatformFallbackXpath = exports.findMatchingParenthesis = exports.normalizeXPath = exports.getReferenceElementsXpath = exports.replaceActualAttributes = exports.getXpathString = exports.getTextXpathFunction = exports.getUniqueNodeAnchorXpaths = exports.getAxisNodeTest = exports.isExactUniqueXpath = exports.getFirstMatchedNode = exports.getTagOnlyXPath = exports.getOrAttributesXPath = exports.getContainsPropertyXPath = exports.getStartsWithPropertyXPath = exports.getNormalizedPropertyXPath = exports.getFilteredTextXPath = exports.intermediateXpathStep = exports.getAttributeCombinationXpath = exports.getCombinationXpath = exports.getRelativeXPath = exports.getAbsoluteXPath = exports.getPropertyXPath = exports.replaceTempAttributes = exports.isSvg = exports.getRelationship = exports.checkBlockedAttributes = exports.createShadowEvaluationContext = exports.getShadowRoot = exports.replaceWhiteSpaces = exports.findXpathWithIndex = exports.removeParenthesis = exports.escapeCharacters = exports.getCountOfXPath = exports.getFilteredText = exports.getTextContent = exports.buildPattern = exports.isNumberExist = exports.sanitizeAttributeValue = exports.modifiedElementAttributes = exports.evaluateXPathOnce = exports.clearXPathEvalCache = exports.timeLog = exports.cspEnabled = exports.reWhiteSpace = void 0;
|
|
4
|
+
exports.evaluateXPath = evaluateXPath;
|
|
5
|
+
exports.escapeAttrValue = escapeAttrValue;
|
|
6
|
+
exports.isUniqueInDOM = isUniqueInDOM;
|
|
7
|
+
const logData_1 = require("../../../utils/logger/logData");
|
|
8
|
+
exports.reWhiteSpace = /^[\S]+( [\S]+)*$/i;
|
|
9
|
+
exports.cspEnabled = false;
|
|
10
|
+
// const xpathCache: { [x: string]: number } = {};
|
|
11
|
+
const timeLog = (label, start) => {
|
|
12
|
+
const duration = performance.now() - start;
|
|
13
|
+
logData_1.logger.info(`⏱️ ${label}: ${duration.toFixed(2)}ms time`);
|
|
14
|
+
};
|
|
15
|
+
exports.timeLog = timeLog;
|
|
16
|
+
// cache per context node → avoids cross-context pollution
|
|
17
|
+
let xpathEvalCache = new WeakMap();
|
|
18
|
+
const getXPathContext = (docmt) => {
|
|
19
|
+
const owner = docmt.nodeType === 9
|
|
20
|
+
? docmt
|
|
21
|
+
: docmt.ownerDocument || document;
|
|
22
|
+
// valid XPath context nodes: Element(1), Document(9), DocumentFragment/ShadowRoot(11)
|
|
23
|
+
const contextNode = docmt.nodeType === 1 || docmt.nodeType === 9 || docmt.nodeType === 11
|
|
24
|
+
? docmt
|
|
25
|
+
: owner;
|
|
26
|
+
return contextNode;
|
|
27
|
+
};
|
|
28
|
+
const getMutationCacheContexts = (node) => {
|
|
29
|
+
const contexts = [];
|
|
30
|
+
const addContext = (candidate) => {
|
|
31
|
+
if (!candidate || contexts.includes(candidate))
|
|
32
|
+
return;
|
|
33
|
+
contexts.push(candidate);
|
|
34
|
+
};
|
|
35
|
+
addContext(node);
|
|
36
|
+
const rootNode = node.getRootNode?.();
|
|
37
|
+
if (rootNode instanceof Document || rootNode instanceof ShadowRoot) {
|
|
38
|
+
addContext(rootNode);
|
|
39
|
+
}
|
|
40
|
+
const ownerDocument = node.nodeType === 9
|
|
41
|
+
? node
|
|
42
|
+
: node.ownerDocument;
|
|
43
|
+
addContext(ownerDocument);
|
|
44
|
+
return contexts;
|
|
45
|
+
};
|
|
46
|
+
const clearXPathEvalCache = (node) => {
|
|
47
|
+
if (!node) {
|
|
48
|
+
xpathEvalCache = new WeakMap();
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
getMutationCacheContexts(node).forEach((contextNode) => {
|
|
52
|
+
xpathEvalCache.delete(contextNode);
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
exports.clearXPathEvalCache = clearXPathEvalCache;
|
|
56
|
+
function svgXPathFallback(xpath, root) {
|
|
57
|
+
const tag = xpath.match(/local-name\(\)\s*=\s*['"]([^'"]+)['"]/)?.[1];
|
|
58
|
+
if (!tag)
|
|
59
|
+
return [];
|
|
60
|
+
let elements = Array.from(root.querySelectorAll(tag));
|
|
61
|
+
// contains(@attr,'value')
|
|
62
|
+
const containsMatch = xpath.match(/contains\(@([^,]+),['"]([^'"]+)['"]\)/);
|
|
63
|
+
if (containsMatch) {
|
|
64
|
+
const [, attr, value] = containsMatch;
|
|
65
|
+
elements = elements.filter(el => el.getAttribute(attr)?.includes(value));
|
|
66
|
+
}
|
|
67
|
+
// starts-with(@attr,'value')
|
|
68
|
+
const startsWithMatch = xpath.match(/starts-with\(@([^,]+),['"]([^'"]+)['"]\)/);
|
|
69
|
+
if (startsWithMatch) {
|
|
70
|
+
const [, attr, value] = startsWithMatch;
|
|
71
|
+
elements = elements.filter(el => el.getAttribute(attr)?.startsWith(value));
|
|
72
|
+
}
|
|
73
|
+
// @attr='value'
|
|
74
|
+
const attrMatch = xpath.match(/@([^=]+)=['"]([^'"]+)['"]/);
|
|
75
|
+
if (attrMatch) {
|
|
76
|
+
const [, attr, value] = attrMatch;
|
|
77
|
+
elements = elements.filter(el => el.getAttribute(attr) === value);
|
|
78
|
+
}
|
|
79
|
+
return elements;
|
|
80
|
+
}
|
|
81
|
+
function evaluateXPath(xpath, contextNode, mode = "iterator") {
|
|
82
|
+
const owner = contextNode.nodeType === 9
|
|
83
|
+
? contextNode
|
|
84
|
+
: contextNode.ownerDocument;
|
|
85
|
+
try {
|
|
86
|
+
switch (mode) {
|
|
87
|
+
case "first":
|
|
88
|
+
return owner.evaluate(xpath, contextNode, null, owner.defaultView.XPathResult.FIRST_ORDERED_NODE_TYPE, null);
|
|
89
|
+
case "snapshot":
|
|
90
|
+
return owner.evaluate(xpath, contextNode, null, owner.defaultView.XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
|
|
91
|
+
default:
|
|
92
|
+
return owner.evaluate(xpath, contextNode, null, owner.defaultView.XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
catch (e) {
|
|
96
|
+
logData_1.logger.error(` Error in evaluating xpath: ${e.message}`);
|
|
97
|
+
const root = contextNode.nodeType === 9
|
|
98
|
+
? contextNode
|
|
99
|
+
: contextNode.ownerDocument;
|
|
100
|
+
const nodes = svgXPathFallback(xpath, root);
|
|
101
|
+
if (mode === "first") {
|
|
102
|
+
return {
|
|
103
|
+
singleNodeValue: nodes[0] ?? null
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
if (mode === "snapshot") {
|
|
107
|
+
return {
|
|
108
|
+
snapshotLength: nodes.length,
|
|
109
|
+
snapshotItem: (i) => nodes[i] ?? null
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
let index = 0;
|
|
113
|
+
return {
|
|
114
|
+
iterateNext: () => nodes[index++] ?? null
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
const evaluateXPathOnce = (xpath, docmt) => {
|
|
119
|
+
const contextNode = getXPathContext(docmt);
|
|
120
|
+
// get or create cache for this context node
|
|
121
|
+
let nodeCache = xpathEvalCache.get(contextNode);
|
|
122
|
+
if (!nodeCache) {
|
|
123
|
+
nodeCache = new Map();
|
|
124
|
+
xpathEvalCache.set(contextNode, nodeCache);
|
|
125
|
+
}
|
|
126
|
+
// cache hit
|
|
127
|
+
const cached = nodeCache.get(xpath);
|
|
128
|
+
if (cached)
|
|
129
|
+
return cached;
|
|
130
|
+
// evaluate once, stop after 2 nodes
|
|
131
|
+
// const result = owner.evaluate(
|
|
132
|
+
// xpath,
|
|
133
|
+
// contextNode,
|
|
134
|
+
// null,
|
|
135
|
+
// owner.defaultView!.XPathResult.ORDERED_NODE_ITERATOR_TYPE,
|
|
136
|
+
// null
|
|
137
|
+
// );
|
|
138
|
+
const result = evaluateXPath(xpath, contextNode);
|
|
139
|
+
const first = result.iterateNext();
|
|
140
|
+
const second = result.iterateNext();
|
|
141
|
+
const evalResult = { first, second };
|
|
142
|
+
nodeCache.set(xpath, evalResult);
|
|
143
|
+
return evalResult;
|
|
144
|
+
};
|
|
145
|
+
exports.evaluateXPathOnce = evaluateXPathOnce;
|
|
146
|
+
const relativeXPathCache = new Map();
|
|
147
|
+
exports.modifiedElementAttributes = [];
|
|
148
|
+
const INTERNAL_CLASS_TOKENS = new Set([
|
|
149
|
+
"marked-element-temp",
|
|
150
|
+
"removePointers"
|
|
151
|
+
]);
|
|
152
|
+
const normalizeClassTokens = (classValue) => (classValue || "")
|
|
153
|
+
.split(/\s+/)
|
|
154
|
+
.map((token) => token.trim())
|
|
155
|
+
.filter((token) => token && !INTERNAL_CLASS_TOKENS.has(token))
|
|
156
|
+
.sort();
|
|
157
|
+
const sanitizeAttributeValue = (attributeName, attributeValue) => {
|
|
158
|
+
if (!attributeValue) {
|
|
159
|
+
return "";
|
|
160
|
+
}
|
|
161
|
+
if (attributeName === "class" || attributeName === "className") {
|
|
162
|
+
return normalizeClassTokens(attributeValue).join(" ");
|
|
163
|
+
}
|
|
164
|
+
return attributeValue.replace("removePointers", "").trim();
|
|
165
|
+
};
|
|
166
|
+
exports.sanitizeAttributeValue = sanitizeAttributeValue;
|
|
167
|
+
const isNumberExist = (str) => {
|
|
168
|
+
const hasNumber = /\d/;
|
|
169
|
+
return hasNumber.test(str);
|
|
170
|
+
};
|
|
171
|
+
exports.isNumberExist = isNumberExist;
|
|
172
|
+
const buildPattern = (pattern, isSvg, tagName) => {
|
|
173
|
+
return isSvg
|
|
174
|
+
? `//*[local-name()='${tagName}' and ${pattern}]`
|
|
175
|
+
: `//${tagName}[${pattern}]`;
|
|
176
|
+
};
|
|
177
|
+
exports.buildPattern = buildPattern;
|
|
178
|
+
const getTextContent = (targetElement) => {
|
|
179
|
+
const textContent = targetElement?.textContent;
|
|
180
|
+
if (exports.cspEnabled) {
|
|
181
|
+
if (textContent) {
|
|
182
|
+
const tooltip = document.querySelector(".flntooltip");
|
|
183
|
+
if (tooltip) {
|
|
184
|
+
const lastIndex = textContent.lastIndexOf(tooltip.innerText);
|
|
185
|
+
if (lastIndex &&
|
|
186
|
+
textContent.length === lastIndex + tooltip.innerText.length) {
|
|
187
|
+
return textContent.substring(0, lastIndex);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
return textContent;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
return textContent;
|
|
197
|
+
}
|
|
198
|
+
return "";
|
|
199
|
+
};
|
|
200
|
+
exports.getTextContent = getTextContent;
|
|
201
|
+
const getFilteredText = (element) => {
|
|
202
|
+
return element?.childNodes[0]?.nodeValue || "";
|
|
203
|
+
};
|
|
204
|
+
exports.getFilteredText = getFilteredText;
|
|
205
|
+
const getCountOfXPath = (xpath, element, docmt, multiElementReferenceMode = false) => {
|
|
206
|
+
try {
|
|
207
|
+
const { first, second } = (0, exports.evaluateXPathOnce)(xpath, docmt);
|
|
208
|
+
if (!first)
|
|
209
|
+
return 0;
|
|
210
|
+
// exactly one match
|
|
211
|
+
if (!second) {
|
|
212
|
+
return first === element ? 1 : 0;
|
|
213
|
+
}
|
|
214
|
+
// multiple matches
|
|
215
|
+
if (multiElementReferenceMode && Array.isArray(element)) {
|
|
216
|
+
let matchCount = 0;
|
|
217
|
+
if (element.includes(first))
|
|
218
|
+
matchCount++;
|
|
219
|
+
if (element.includes(second))
|
|
220
|
+
matchCount++;
|
|
221
|
+
if (matchCount === 2)
|
|
222
|
+
return 2;
|
|
223
|
+
// const result = owner.evaluate(
|
|
224
|
+
// xpath,
|
|
225
|
+
// docmt,
|
|
226
|
+
// null,
|
|
227
|
+
// owner.defaultView!.XPathResult.ORDERED_NODE_ITERATOR_TYPE,
|
|
228
|
+
// null
|
|
229
|
+
// );
|
|
230
|
+
const result = evaluateXPath(xpath, docmt);
|
|
231
|
+
let node;
|
|
232
|
+
while ((node = result.iterateNext())) {
|
|
233
|
+
if (element.includes(node)) {
|
|
234
|
+
matchCount++;
|
|
235
|
+
if (matchCount === 2)
|
|
236
|
+
return 2;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return 0;
|
|
240
|
+
}
|
|
241
|
+
return 2;
|
|
242
|
+
}
|
|
243
|
+
catch (error) {
|
|
244
|
+
console.error(`Error evaluating XPath: ${xpath}`, error);
|
|
245
|
+
return 0;
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
exports.getCountOfXPath = getCountOfXPath;
|
|
249
|
+
const escapeCharacters = (text) => {
|
|
250
|
+
if (text) {
|
|
251
|
+
if (!(text.indexOf('"') === -1)) {
|
|
252
|
+
return `'${text}'`;
|
|
253
|
+
}
|
|
254
|
+
if (!(text.indexOf("'") === -1)) {
|
|
255
|
+
return `"${text}"`;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
return `'${text}'`;
|
|
259
|
+
};
|
|
260
|
+
exports.escapeCharacters = escapeCharacters;
|
|
261
|
+
const removeParenthesis = (xpath) => {
|
|
262
|
+
const charArr = xpath.split("");
|
|
263
|
+
let count = charArr.length;
|
|
264
|
+
const indexArray = [];
|
|
265
|
+
while (charArr[count - 2] !== "[") {
|
|
266
|
+
indexArray.push(charArr[count - 2]);
|
|
267
|
+
count--;
|
|
268
|
+
}
|
|
269
|
+
indexArray.reverse();
|
|
270
|
+
let finalStr = "";
|
|
271
|
+
for (let i = 0; i < indexArray.length; i++) {
|
|
272
|
+
finalStr += indexArray[i];
|
|
273
|
+
}
|
|
274
|
+
const endBracketLength = finalStr.length + 2;
|
|
275
|
+
let firstpart = xpath.slice(0, xpath.length - endBracketLength);
|
|
276
|
+
if (firstpart.startsWith("(") && firstpart.endsWith(")")) {
|
|
277
|
+
firstpart = firstpart.slice(1, -1);
|
|
278
|
+
}
|
|
279
|
+
else {
|
|
280
|
+
firstpart = xpath;
|
|
281
|
+
}
|
|
282
|
+
return firstpart;
|
|
283
|
+
};
|
|
284
|
+
exports.removeParenthesis = removeParenthesis;
|
|
285
|
+
const findXpathWithIndex = (val, node, docmt, count) => {
|
|
286
|
+
try {
|
|
287
|
+
let index = 0;
|
|
288
|
+
if (count) {
|
|
289
|
+
if ((0, exports.getCountOfXPath)(`${val}[${count}]`, node, docmt) === 1) {
|
|
290
|
+
return `${val}[${count}]`;
|
|
291
|
+
}
|
|
292
|
+
if ((0, exports.getCountOfXPath)(`(${val})[${count}]`, node, docmt) === 1) {
|
|
293
|
+
return `(${val})[${count}]`;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
// const nodes = owner.evaluate(val, docmt, null, owner.defaultView!.XPathResult.ANY_TYPE, null);
|
|
297
|
+
const nodes = evaluateXPath(val, docmt);
|
|
298
|
+
let nodex = null;
|
|
299
|
+
while ((nodex = nodes.iterateNext())) {
|
|
300
|
+
index++;
|
|
301
|
+
if (nodex.isSameNode(node)) {
|
|
302
|
+
if ((0, exports.getCountOfXPath)(`${val}[${index}]`, node, docmt) === 1) {
|
|
303
|
+
return `${val}[${index}]`;
|
|
304
|
+
}
|
|
305
|
+
if ((0, exports.getCountOfXPath)(`(${val})[${index}]`, node, docmt) === 1) {
|
|
306
|
+
return `(${val})[${index}]`;
|
|
307
|
+
}
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
catch (error) {
|
|
313
|
+
logData_1.logger.error(error);
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
exports.findXpathWithIndex = findXpathWithIndex;
|
|
317
|
+
const deleteLineGap = (a) => {
|
|
318
|
+
a && (a = a.split("\n")[0].length > 0 ? a.split("\n")[0] : a.split("\n")[1]);
|
|
319
|
+
return a;
|
|
320
|
+
};
|
|
321
|
+
const deleteGarbageFromInnerText = (a) => {
|
|
322
|
+
a = deleteLineGap(a);
|
|
323
|
+
a = a
|
|
324
|
+
.split(/[^\p{ASCII}\u0080-\u00FF]/u)
|
|
325
|
+
.reduce((b, c) => {
|
|
326
|
+
return b.length > c.length ? b : c;
|
|
327
|
+
}, "")
|
|
328
|
+
.trim();
|
|
329
|
+
return (a.split("/")[0].trim());
|
|
330
|
+
};
|
|
331
|
+
const replaceWhiteSpaces = (str) => {
|
|
332
|
+
if (str) {
|
|
333
|
+
return str.replace(/\s\s+/g, " ").trim();
|
|
334
|
+
}
|
|
335
|
+
return str;
|
|
336
|
+
};
|
|
337
|
+
exports.replaceWhiteSpaces = replaceWhiteSpaces;
|
|
338
|
+
const getShadowRoot = (el) => {
|
|
339
|
+
if (!el || !el?.getRootNode)
|
|
340
|
+
return null;
|
|
341
|
+
const root = el.getRootNode();
|
|
342
|
+
return root && root?.host ? root : null;
|
|
343
|
+
};
|
|
344
|
+
exports.getShadowRoot = getShadowRoot;
|
|
345
|
+
const isShadowRootNode = (node) => {
|
|
346
|
+
return node?.nodeType === 11 && "host" in node;
|
|
347
|
+
};
|
|
348
|
+
const getElementPathFromRoot = (root, element) => {
|
|
349
|
+
const path = [];
|
|
350
|
+
let current = element;
|
|
351
|
+
while (current && current.parentElement) {
|
|
352
|
+
const parent = current.parentElement;
|
|
353
|
+
path.unshift(Array.from(parent.children).indexOf(current));
|
|
354
|
+
current = parent;
|
|
355
|
+
}
|
|
356
|
+
if (!current || current.parentNode !== root) {
|
|
357
|
+
return null;
|
|
358
|
+
}
|
|
359
|
+
path.unshift(Array.from(root.children).indexOf(current));
|
|
360
|
+
return path;
|
|
361
|
+
};
|
|
362
|
+
const getElementAtPath = (container, path) => {
|
|
363
|
+
let current = container;
|
|
364
|
+
for (const index of path) {
|
|
365
|
+
const next = current.children.item(index);
|
|
366
|
+
if (!next) {
|
|
367
|
+
return null;
|
|
368
|
+
}
|
|
369
|
+
current = next;
|
|
370
|
+
}
|
|
371
|
+
return current;
|
|
372
|
+
};
|
|
373
|
+
const createShadowEvaluationContext = (root, element) => {
|
|
374
|
+
const tempDoc = root.ownerDocument.implementation.createHTMLDocument("shadow-xpath");
|
|
375
|
+
const wrapper = tempDoc.createElement("div");
|
|
376
|
+
wrapper.innerHTML = root.innerHTML;
|
|
377
|
+
tempDoc.body.appendChild(wrapper);
|
|
378
|
+
const cloneForElement = (candidate) => {
|
|
379
|
+
if (!candidate ||
|
|
380
|
+
!(candidate instanceof root.ownerDocument.defaultView.Element)) {
|
|
381
|
+
return null;
|
|
382
|
+
}
|
|
383
|
+
const path = getElementPathFromRoot(root, candidate);
|
|
384
|
+
return path ? getElementAtPath(wrapper, path) : null;
|
|
385
|
+
};
|
|
386
|
+
const cloneElements = Array.isArray(element)
|
|
387
|
+
? element.map((candidate) => cloneForElement(candidate)).filter(Boolean)
|
|
388
|
+
: [];
|
|
389
|
+
const cloneElement = Array.isArray(element)
|
|
390
|
+
? null
|
|
391
|
+
: cloneForElement(element ?? null);
|
|
392
|
+
return {
|
|
393
|
+
contextNode: wrapper,
|
|
394
|
+
cloneElement,
|
|
395
|
+
cloneElements
|
|
396
|
+
};
|
|
397
|
+
};
|
|
398
|
+
exports.createShadowEvaluationContext = createShadowEvaluationContext;
|
|
399
|
+
const checkBlockedAttributes = (attribute, targetElement, isTarget) => {
|
|
400
|
+
const sanitizedValue = (0, exports.sanitizeAttributeValue)(attribute.name, attribute.value);
|
|
401
|
+
if (!sanitizedValue || typeof attribute?.value === "boolean") {
|
|
402
|
+
return false;
|
|
403
|
+
}
|
|
404
|
+
const blockedValues = [
|
|
405
|
+
"true",
|
|
406
|
+
"false",
|
|
407
|
+
"on",
|
|
408
|
+
"off",
|
|
409
|
+
"flntooltip",
|
|
410
|
+
"flutter-highlight-overlay"
|
|
411
|
+
];
|
|
412
|
+
if (blockedValues.some((x) => x === sanitizedValue)) {
|
|
413
|
+
return false;
|
|
414
|
+
}
|
|
415
|
+
const blockedNames = [
|
|
416
|
+
"style",
|
|
417
|
+
"locator-data-tooltip",
|
|
418
|
+
"value",
|
|
419
|
+
"ff-inspect",
|
|
420
|
+
"ff-inspecter",
|
|
421
|
+
"ff-xpath"
|
|
422
|
+
];
|
|
423
|
+
if (blockedNames.some((x) => x.toLowerCase() === attribute.name.toLowerCase())) {
|
|
424
|
+
return false;
|
|
425
|
+
}
|
|
426
|
+
const isModified = exports.modifiedElementAttributes?.find((x) => x.doc === targetElement.ownerDocument &&
|
|
427
|
+
x.element === targetElement &&
|
|
428
|
+
x.attributeName === attribute.name);
|
|
429
|
+
if (isModified) {
|
|
430
|
+
return false;
|
|
431
|
+
}
|
|
432
|
+
if (attribute?.name?.indexOf("on") === 0 && attribute?.name?.length > 3) {
|
|
433
|
+
return false;
|
|
434
|
+
}
|
|
435
|
+
if (typeof attribute.value === "function") {
|
|
436
|
+
return false;
|
|
437
|
+
}
|
|
438
|
+
if (isTarget && (0, exports.isNumberExist)(sanitizedValue)) {
|
|
439
|
+
return false;
|
|
440
|
+
}
|
|
441
|
+
return true;
|
|
442
|
+
};
|
|
443
|
+
exports.checkBlockedAttributes = checkBlockedAttributes;
|
|
444
|
+
const getRelationship = (a, b) => {
|
|
445
|
+
const pos = a.compareDocumentPosition(b);
|
|
446
|
+
return pos === 2
|
|
447
|
+
? "preceding"
|
|
448
|
+
: pos === 4
|
|
449
|
+
? "following"
|
|
450
|
+
: pos === 8
|
|
451
|
+
? "ancestor"
|
|
452
|
+
: pos === 16
|
|
453
|
+
? "descendant"
|
|
454
|
+
: pos === 32
|
|
455
|
+
? "self"
|
|
456
|
+
: "";
|
|
457
|
+
};
|
|
458
|
+
exports.getRelationship = getRelationship;
|
|
459
|
+
const isSvg = (element) => {
|
|
460
|
+
return element instanceof element.ownerDocument.defaultView.SVGElement;
|
|
461
|
+
};
|
|
462
|
+
exports.isSvg = isSvg;
|
|
463
|
+
const replaceTempAttributes = (str) => {
|
|
464
|
+
if (!str)
|
|
465
|
+
return str;
|
|
466
|
+
return str.replace(/\b[a-zA-Z_]*disabled\b/gi, "disabled");
|
|
467
|
+
};
|
|
468
|
+
exports.replaceTempAttributes = replaceTempAttributes;
|
|
469
|
+
const getPropertyXPath = (element, docmt, prop, value, isIndex, isTarget, platform) => {
|
|
470
|
+
if (value) {
|
|
471
|
+
const { tagName } = element;
|
|
472
|
+
let count;
|
|
473
|
+
let combinePattern = "";
|
|
474
|
+
const mergePattern = [];
|
|
475
|
+
let pattern;
|
|
476
|
+
let elementTagName = element.tagName;
|
|
477
|
+
if (value && (!isTarget || !(0, exports.isNumberExist)(value))) {
|
|
478
|
+
if (!exports.reWhiteSpace.test(value)) {
|
|
479
|
+
if (platform == 'web') {
|
|
480
|
+
elementTagName = element.tagName.toLowerCase();
|
|
481
|
+
}
|
|
482
|
+
pattern = (0, exports.buildPattern)(`normalize-space(${prop})=${(0, exports.escapeCharacters)((0, exports.replaceWhiteSpaces)(value)).trim()}`, (0, exports.isSvg)(element), elementTagName);
|
|
483
|
+
}
|
|
484
|
+
else {
|
|
485
|
+
pattern = `//${elementTagName}[${prop}=${(0, exports.escapeCharacters)(value)}]`;
|
|
486
|
+
}
|
|
487
|
+
count = (0, exports.getCountOfXPath)(pattern, element, docmt);
|
|
488
|
+
if (count === 1 && !isIndex) {
|
|
489
|
+
return pattern;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
if (value && isTarget) {
|
|
493
|
+
const splitText = value.split(" ");
|
|
494
|
+
if (splitText?.length) {
|
|
495
|
+
if (splitText.length === 1) {
|
|
496
|
+
const contentRes = [...new Set(splitText[0].match(/([^0-9]+)/g))];
|
|
497
|
+
if (contentRes?.length >= 1) {
|
|
498
|
+
if (contentRes[0] &&
|
|
499
|
+
(0, exports.replaceWhiteSpaces)(contentRes[0].trim())?.length > 1) {
|
|
500
|
+
if (value.startsWith(contentRes[0])) {
|
|
501
|
+
if (!exports.reWhiteSpace.test(contentRes[0])) {
|
|
502
|
+
combinePattern = `starts-with(${prop},${(0, exports.escapeCharacters)((0, exports.replaceWhiteSpaces)(contentRes[0])).trim()})`;
|
|
503
|
+
}
|
|
504
|
+
else {
|
|
505
|
+
combinePattern = `starts-with(${prop},${(0, exports.escapeCharacters)(contentRes[0]).trim()})`;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
if (contentRes?.length > 1) {
|
|
511
|
+
if (contentRes[contentRes.length - 1] &&
|
|
512
|
+
(0, exports.replaceWhiteSpaces)(contentRes[contentRes.length - 1].trim())
|
|
513
|
+
?.length > 1) {
|
|
514
|
+
if (value.endsWith(contentRes[contentRes.length - 1])) {
|
|
515
|
+
if (!exports.reWhiteSpace.test(contentRes[contentRes.length - 1])) {
|
|
516
|
+
combinePattern = `ends-with(${prop},${(0, exports.escapeCharacters)((0, exports.replaceWhiteSpaces)(contentRes[contentRes.length - 1])).trim()})`;
|
|
517
|
+
}
|
|
518
|
+
else {
|
|
519
|
+
combinePattern = `ends-with(${prop},${(0, exports.escapeCharacters)(contentRes[contentRes.length - 1]).trim()})`;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
if (combinePattern?.length) {
|
|
525
|
+
if ((0, exports.isSvg)(element)) {
|
|
526
|
+
pattern = `//*[local-name()='${tagName}' and ${combinePattern}]`;
|
|
527
|
+
}
|
|
528
|
+
else {
|
|
529
|
+
pattern = `//${tagName}[${combinePattern}]`;
|
|
530
|
+
}
|
|
531
|
+
count = (0, exports.getCountOfXPath)(pattern, element, docmt);
|
|
532
|
+
if (count === 1 && !isIndex) {
|
|
533
|
+
return pattern;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
else {
|
|
538
|
+
const endIndex = splitText.length % 2 === 0
|
|
539
|
+
? splitText.length / 2
|
|
540
|
+
: splitText.length % 2;
|
|
541
|
+
const startIndexString = splitText.slice(0, endIndex).join(" ");
|
|
542
|
+
let contentRes = [...new Set(startIndexString.match(/([^0-9]+)/g))];
|
|
543
|
+
if (contentRes?.length) {
|
|
544
|
+
if (contentRes[0] &&
|
|
545
|
+
(0, exports.replaceWhiteSpaces)(contentRes[0].trim())?.length) {
|
|
546
|
+
if (value.startsWith(contentRes[0])) {
|
|
547
|
+
if (!exports.reWhiteSpace.test(contentRes[0])) {
|
|
548
|
+
combinePattern = `starts-with(${prop},${(0, exports.escapeCharacters)((0, exports.replaceWhiteSpaces)(contentRes[0])).trim()})`;
|
|
549
|
+
}
|
|
550
|
+
else {
|
|
551
|
+
combinePattern = `starts-with(${prop},${(0, exports.escapeCharacters)(contentRes[0]).trim()})`;
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
if (combinePattern?.length) {
|
|
557
|
+
if ((0, exports.isSvg)(element)) {
|
|
558
|
+
pattern = `//*[local-name()='${tagName}' and ${combinePattern}]`;
|
|
559
|
+
}
|
|
560
|
+
else {
|
|
561
|
+
pattern = `//${tagName}[${combinePattern}]`;
|
|
562
|
+
}
|
|
563
|
+
count = (0, exports.getCountOfXPath)(pattern, element, docmt);
|
|
564
|
+
if (count === 1 && !isIndex) {
|
|
565
|
+
return pattern;
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
const endIndexString = splitText
|
|
569
|
+
.slice(endIndex, splitText.length - 1)
|
|
570
|
+
.join(" ");
|
|
571
|
+
contentRes = [...new Set(endIndexString.match(/([^0-9]+)/g))];
|
|
572
|
+
if (contentRes?.length) {
|
|
573
|
+
if (contentRes[0] &&
|
|
574
|
+
(0, exports.replaceWhiteSpaces)(contentRes[0].trim())?.length > 3) {
|
|
575
|
+
if (value.endsWith(contentRes[0])) {
|
|
576
|
+
if (!exports.reWhiteSpace.test(contentRes[0])) {
|
|
577
|
+
combinePattern = `ends-with(${prop},${(0, exports.escapeCharacters)((0, exports.replaceWhiteSpaces)(contentRes[0])).trim()})`;
|
|
578
|
+
}
|
|
579
|
+
else {
|
|
580
|
+
combinePattern = `ends-with(${prop},${(0, exports.escapeCharacters)(contentRes[0]).trim()})`;
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
if (combinePattern?.length) {
|
|
586
|
+
if ((0, exports.isSvg)(element)) {
|
|
587
|
+
pattern = `//*[local-name()='${tagName}' and ${combinePattern}]`;
|
|
588
|
+
}
|
|
589
|
+
else {
|
|
590
|
+
pattern = `//${tagName}[${combinePattern}]`;
|
|
591
|
+
}
|
|
592
|
+
count = (0, exports.getCountOfXPath)(pattern, element, docmt);
|
|
593
|
+
if (count === 1 && !isIndex) {
|
|
594
|
+
return pattern;
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
if (value && isTarget && (0, exports.isNumberExist)(value)) {
|
|
601
|
+
const contentRes = [...new Set(value.match(/([^0-9]+)/g))];
|
|
602
|
+
if (contentRes?.length) {
|
|
603
|
+
for (let i = 0; i < contentRes?.length; i++) {
|
|
604
|
+
if (contentRes[i] &&
|
|
605
|
+
(0, exports.replaceWhiteSpaces)(contentRes[i].trim())?.length > 1) {
|
|
606
|
+
if (!exports.reWhiteSpace.test(contentRes[i])) {
|
|
607
|
+
mergePattern.push(`contains(${prop},${(0, exports.escapeCharacters)((0, exports.replaceWhiteSpaces)(contentRes[i])).trim()})`);
|
|
608
|
+
}
|
|
609
|
+
else {
|
|
610
|
+
mergePattern.push(`contains(${prop},${(0, exports.escapeCharacters)(contentRes[i].trim()).trim()})`);
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
if (mergePattern?.length) {
|
|
616
|
+
if ((0, exports.isSvg)(element)) {
|
|
617
|
+
pattern = `//*[local-name()='${tagName}' and ${mergePattern.join(" and ")}]`;
|
|
618
|
+
}
|
|
619
|
+
else {
|
|
620
|
+
pattern = `//${tagName}[${mergePattern.join(" and ")}]`;
|
|
621
|
+
}
|
|
622
|
+
count = (0, exports.getCountOfXPath)(pattern, element, docmt);
|
|
623
|
+
if (count === 1 && !isIndex) {
|
|
624
|
+
return pattern;
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
if ((0, exports.isSvg)(element)) {
|
|
629
|
+
pattern = `//*[local-name()='${tagName}' and text()]`;
|
|
630
|
+
}
|
|
631
|
+
else {
|
|
632
|
+
pattern = `//${tagName}[text()]`;
|
|
633
|
+
}
|
|
634
|
+
count = (0, exports.getCountOfXPath)(pattern, element, docmt);
|
|
635
|
+
if (count === 1 && !isIndex) {
|
|
636
|
+
return pattern;
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
};
|
|
640
|
+
exports.getPropertyXPath = getPropertyXPath;
|
|
641
|
+
const getAbsoluteXPath = (domNode, docmt) => {
|
|
642
|
+
try {
|
|
643
|
+
if (!domNode) {
|
|
644
|
+
return "";
|
|
645
|
+
}
|
|
646
|
+
let xpathe = (0, exports.isSvg)(domNode)
|
|
647
|
+
? `/*[local-name()='${domNode.tagName}']`
|
|
648
|
+
: `/${domNode.tagName}`;
|
|
649
|
+
// // If this node has siblings of the same tagName, get the index of this node
|
|
650
|
+
if (domNode.parentElement) {
|
|
651
|
+
// Get the siblings
|
|
652
|
+
const childNodes = Array.prototype.slice
|
|
653
|
+
.call(domNode.parentElement.children, 0)
|
|
654
|
+
.filter((childNode) => childNode.tagName === domNode.tagName);
|
|
655
|
+
// // If there's more than one sibling, append the index
|
|
656
|
+
if (childNodes.length > 1) {
|
|
657
|
+
const index = childNodes.indexOf(domNode);
|
|
658
|
+
xpathe += `[${index + 1}]`;
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
else if (domNode instanceof HTMLElement) {
|
|
662
|
+
if (domNode.offsetParent) {
|
|
663
|
+
const childNodes = Array.prototype.slice
|
|
664
|
+
.call(domNode.offsetParent.children, 0)
|
|
665
|
+
.filter((childNode) => childNode.tagName === domNode.tagName);
|
|
666
|
+
// // If there's more than one sibling, append the index
|
|
667
|
+
if (childNodes.length > 1) {
|
|
668
|
+
const index = childNodes.indexOf(domNode);
|
|
669
|
+
xpathe += `[${index + 1}]`;
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
// // Make a recursive call to this nodes parents and prepend it to this xpath
|
|
674
|
+
return (0, exports.getAbsoluteXPath)(domNode?.parentElement, docmt) + xpathe;
|
|
675
|
+
}
|
|
676
|
+
catch (error) {
|
|
677
|
+
// If there's an unexpected exception, abort and don't get an XPath
|
|
678
|
+
logData_1.logger.error("xpath", error);
|
|
679
|
+
return "";
|
|
680
|
+
}
|
|
681
|
+
};
|
|
682
|
+
exports.getAbsoluteXPath = getAbsoluteXPath;
|
|
683
|
+
const getRelativeXPath = (domNode, docmt, isIndex, isTarget = false, attributesArray) => {
|
|
684
|
+
try {
|
|
685
|
+
// Generate a cache key based on the node's identifier, index, and target flag
|
|
686
|
+
// Check if the result for this node is already cached
|
|
687
|
+
if (relativeXPathCache.has(domNode)) {
|
|
688
|
+
return relativeXPathCache.get(domNode);
|
|
689
|
+
}
|
|
690
|
+
// Initialize an array to hold parts of the XPath
|
|
691
|
+
const xpathParts = [];
|
|
692
|
+
let currentNode = domNode;
|
|
693
|
+
// Traverse up the DOM tree iteratively instead of using recursion
|
|
694
|
+
while (currentNode) {
|
|
695
|
+
let xpathe = "";
|
|
696
|
+
let hasUniqueAttr = false;
|
|
697
|
+
const attributes = domNode === currentNode
|
|
698
|
+
? (attributesArray ?? currentNode.attributes)
|
|
699
|
+
: currentNode.attributes;
|
|
700
|
+
// Loop through attributes to check for unique identifiers
|
|
701
|
+
for (const attrName of Array.from(attributes)) {
|
|
702
|
+
if ((0, exports.checkBlockedAttributes)(attrName, currentNode, isTarget)) {
|
|
703
|
+
const attrValue = (0, exports.sanitizeAttributeValue)(attrName.name, attrName.nodeValue);
|
|
704
|
+
const elementName = attrName.name;
|
|
705
|
+
// Construct an XPath based on attribute
|
|
706
|
+
xpathe = (0, exports.getXpathString)(currentNode, elementName, attrValue);
|
|
707
|
+
let othersWithAttr = 0;
|
|
708
|
+
if (xpathe) {
|
|
709
|
+
othersWithAttr = (0, exports.getCountOfXPath)(xpathe, currentNode, docmt);
|
|
710
|
+
if (othersWithAttr === 1) {
|
|
711
|
+
xpathParts.unshift((0, exports.replaceTempAttributes)(xpathe));
|
|
712
|
+
hasUniqueAttr = true;
|
|
713
|
+
break;
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
if (othersWithAttr > 1 && isIndex) {
|
|
717
|
+
xpathe = (0, exports.findXpathWithIndex)(xpathe, currentNode, docmt, othersWithAttr);
|
|
718
|
+
if (xpathe) {
|
|
719
|
+
xpathParts.unshift((0, exports.replaceTempAttributes)(xpathe));
|
|
720
|
+
hasUniqueAttr = true;
|
|
721
|
+
break;
|
|
722
|
+
}
|
|
723
|
+
// return replaceTempAttributes(xpathe);
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
if (currentNode.textContent) {
|
|
728
|
+
if (!isTarget ||
|
|
729
|
+
(isTarget && !(0, exports.isNumberExist)(currentNode.textContent))) {
|
|
730
|
+
const reWhiteSpace = new RegExp(/^[\S]+( [\S]+)*$/gi);
|
|
731
|
+
if (!reWhiteSpace.test(currentNode.textContent)) {
|
|
732
|
+
xpathe = (0, exports.isSvg)(currentNode)
|
|
733
|
+
? `//*[local-name()='${currentNode.tagName}' and normalize-space(.)=${(0, exports.escapeCharacters)((0, exports.getFilteredText)(currentNode))}]`
|
|
734
|
+
: `//${currentNode.tagName || "*"}[normalize-space(.)=${(0, exports.escapeCharacters)((0, exports.getFilteredText)(currentNode))}]`;
|
|
735
|
+
}
|
|
736
|
+
else {
|
|
737
|
+
xpathe = (0, exports.isSvg)(currentNode)
|
|
738
|
+
? `//*[local-name()='${currentNode.tagName}' and .=${(0, exports.escapeCharacters)((0, exports.getFilteredText)(currentNode))}]`
|
|
739
|
+
: `//${currentNode.tagName || "*"}[.=${(0, exports.escapeCharacters)((0, exports.getFilteredText)(currentNode))}]`;
|
|
740
|
+
}
|
|
741
|
+
const othersWithAttr = (0, exports.getCountOfXPath)(xpathe, currentNode, docmt);
|
|
742
|
+
if (othersWithAttr === 1) {
|
|
743
|
+
return xpathe;
|
|
744
|
+
}
|
|
745
|
+
if (othersWithAttr > 1 && isIndex) {
|
|
746
|
+
xpathe = (0, exports.findXpathWithIndex)(xpathe, currentNode, docmt, othersWithAttr);
|
|
747
|
+
return xpathe;
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
else {
|
|
751
|
+
const combinePattern = [];
|
|
752
|
+
const contentRes = [
|
|
753
|
+
...new Set((0, exports.getFilteredText)(currentNode).match(/([^0-9]+)/g))
|
|
754
|
+
];
|
|
755
|
+
const reWhiteSpace = new RegExp(/^[\S]+( [\S]+)*$/gi);
|
|
756
|
+
if (contentRes?.length) {
|
|
757
|
+
for (let i = 0; i < contentRes?.length; i++) {
|
|
758
|
+
if (contentRes[i] &&
|
|
759
|
+
(0, exports.replaceWhiteSpaces)(contentRes[i].trim())) {
|
|
760
|
+
if (!reWhiteSpace.test(contentRes[i])) {
|
|
761
|
+
combinePattern.push(`contains(.,${(0, exports.escapeCharacters)((0, exports.replaceWhiteSpaces)(contentRes[i])).trim()})`);
|
|
762
|
+
}
|
|
763
|
+
else {
|
|
764
|
+
combinePattern.push(`contains(.,${(0, exports.escapeCharacters)(contentRes[i].trim()).trim()})`);
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
if (combinePattern?.length) {
|
|
770
|
+
xpathe = (0, exports.isSvg)(currentNode)
|
|
771
|
+
? `//*[local-name()='${currentNode.tagName}' and ${combinePattern.join(" and ")}]`
|
|
772
|
+
: `//${currentNode.tagName || "*"}[${combinePattern.join(" and ")}]`;
|
|
773
|
+
const othersWithAttr = (0, exports.getCountOfXPath)(xpathe, currentNode, docmt);
|
|
774
|
+
if (othersWithAttr === 1) {
|
|
775
|
+
return xpathe;
|
|
776
|
+
}
|
|
777
|
+
if (othersWithAttr > 1 && isIndex) {
|
|
778
|
+
xpathe = (0, exports.findXpathWithIndex)(xpathe, currentNode, docmt, othersWithAttr);
|
|
779
|
+
return xpathe;
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
// If no unique attribute was found, construct XPath by tag name
|
|
785
|
+
if (!hasUniqueAttr) {
|
|
786
|
+
let tagBasedXPath = (0, exports.isSvg)(currentNode)
|
|
787
|
+
? `/*[local-name()='${currentNode.tagName}']`
|
|
788
|
+
: `/${currentNode.tagName}`;
|
|
789
|
+
// Handle sibling nodes
|
|
790
|
+
if (currentNode.parentElement) {
|
|
791
|
+
const siblings = Array.from(currentNode.parentElement.children).filter((childNode) => childNode.tagName === currentNode.tagName);
|
|
792
|
+
// Append index to distinguish between siblings
|
|
793
|
+
if (siblings.length > 1) {
|
|
794
|
+
const index = siblings.indexOf(currentNode);
|
|
795
|
+
tagBasedXPath += `[${index + 1}]`;
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
// Add the constructed tag-based XPath to the parts array
|
|
799
|
+
xpathParts.unshift(tagBasedXPath);
|
|
800
|
+
}
|
|
801
|
+
else {
|
|
802
|
+
break;
|
|
803
|
+
}
|
|
804
|
+
// Move up to the parent node for the next iteration
|
|
805
|
+
currentNode = currentNode.parentElement;
|
|
806
|
+
}
|
|
807
|
+
// Combine all parts into the final XPath
|
|
808
|
+
const finalXPath = `${xpathParts.join("")}`;
|
|
809
|
+
// Cache the final XPath for this node
|
|
810
|
+
relativeXPathCache.set(domNode, finalXPath);
|
|
811
|
+
return finalXPath;
|
|
812
|
+
}
|
|
813
|
+
catch (error) {
|
|
814
|
+
logData_1.logger.error(error);
|
|
815
|
+
return null;
|
|
816
|
+
}
|
|
817
|
+
};
|
|
818
|
+
exports.getRelativeXPath = getRelativeXPath;
|
|
819
|
+
const getCombinationXpath = (attribute, domNode) => {
|
|
820
|
+
const combinePattern = [];
|
|
821
|
+
let pattern;
|
|
822
|
+
if (attribute &&
|
|
823
|
+
!(0, exports.isNumberExist)(attribute.value) &&
|
|
824
|
+
typeof attribute.nodeValue !== "function" // &&
|
|
825
|
+
// !modifiedElementAttributes?.find(
|
|
826
|
+
// (x) => x.element === domNode && x.attributeName === attribute.name
|
|
827
|
+
// )
|
|
828
|
+
) {
|
|
829
|
+
const contentRes = [...new Set(attribute.value.match(/([^0-9]+)/g))];
|
|
830
|
+
if (contentRes?.length) {
|
|
831
|
+
for (let i = 0; i < contentRes?.length; i++) {
|
|
832
|
+
if (contentRes[i] &&
|
|
833
|
+
(0, exports.replaceWhiteSpaces)(contentRes[i].trim())?.length > 2) {
|
|
834
|
+
if (!exports.reWhiteSpace.test(contentRes[i])) {
|
|
835
|
+
combinePattern.push(`contains(@${attribute.name},${(0, exports.escapeCharacters)((0, exports.replaceWhiteSpaces)(contentRes[i])).trim()})`);
|
|
836
|
+
}
|
|
837
|
+
else {
|
|
838
|
+
combinePattern.push(`contains(@${attribute.name},${(0, exports.escapeCharacters)(contentRes[i].trim())})`);
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
if (combinePattern?.length) {
|
|
844
|
+
pattern = (0, exports.isSvg)(domNode)
|
|
845
|
+
? `//*[local-name()='${domNode.tagName}' and ${combinePattern.join(" and ")}]`
|
|
846
|
+
: `//${domNode.tagName}[${combinePattern.join(" and ")}]`;
|
|
847
|
+
return pattern;
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
};
|
|
851
|
+
exports.getCombinationXpath = getCombinationXpath;
|
|
852
|
+
const getAttributeCombinationXpath = (domNode, docmt, uniqueAttributes, isTarget, platform) => {
|
|
853
|
+
try {
|
|
854
|
+
const candidateAttributes = uniqueAttributes.filter((attr) => (0, exports.checkBlockedAttributes)(attr, domNode, isTarget));
|
|
855
|
+
const buildAttributeConditions = (attribute) => {
|
|
856
|
+
const attrValue = (0, exports.sanitizeAttributeValue)(attribute.name, attribute.nodeValue);
|
|
857
|
+
if (!attrValue)
|
|
858
|
+
return [];
|
|
859
|
+
if (attribute.name === "class") {
|
|
860
|
+
const classTokens = attrValue
|
|
861
|
+
.split(/\s+/)
|
|
862
|
+
.map((token) => token.trim())
|
|
863
|
+
.filter(Boolean);
|
|
864
|
+
if (!classTokens.length)
|
|
865
|
+
return [];
|
|
866
|
+
const rankedTokens = classTokens
|
|
867
|
+
.map((token) => {
|
|
868
|
+
const xpath = (0, exports.buildPattern)(`contains(@class,${(0, exports.escapeCharacters)(token)})`, (0, exports.isSvg)(domNode), platform === "web" ? domNode.tagName.toLowerCase() : domNode.localName);
|
|
869
|
+
return {
|
|
870
|
+
token,
|
|
871
|
+
count: getTagOnlyXpathCandidateCount(xpath, domNode, docmt)
|
|
872
|
+
};
|
|
873
|
+
})
|
|
874
|
+
.sort((left, right) => {
|
|
875
|
+
if (left.count !== right.count) {
|
|
876
|
+
return left.count - right.count;
|
|
877
|
+
}
|
|
878
|
+
return right.token.length - left.token.length;
|
|
879
|
+
});
|
|
880
|
+
return rankedTokens[0]?.token
|
|
881
|
+
? [`contains(@class,${(0, exports.escapeCharacters)(rankedTokens[0].token)})`]
|
|
882
|
+
: [];
|
|
883
|
+
}
|
|
884
|
+
if (!exports.reWhiteSpace.test(attrValue)) {
|
|
885
|
+
return [`normalize-space(@${attribute.name})="${attrValue}"`];
|
|
886
|
+
}
|
|
887
|
+
return [`@${attribute.name}="${attrValue}"`];
|
|
888
|
+
};
|
|
889
|
+
const getTextConditions = () => {
|
|
890
|
+
const rawText = (0, exports.replaceWhiteSpaces)((0, exports.getTextContent)(domNode)?.trim() || "");
|
|
891
|
+
if (!rawText || rawText.length > 80 || /^\d+$/.test(rawText)) {
|
|
892
|
+
return [];
|
|
893
|
+
}
|
|
894
|
+
const conditions = new Set();
|
|
895
|
+
if (exports.reWhiteSpace.test(rawText) && rawText.length <= 40) {
|
|
896
|
+
conditions.add(`text()=${(0, exports.escapeCharacters)(rawText)}`);
|
|
897
|
+
}
|
|
898
|
+
if (rawText.includes(" ")) {
|
|
899
|
+
conditions.add(`normalize-space(text())=${(0, exports.escapeCharacters)((0, exports.replaceWhiteSpaces)(rawText))}`);
|
|
900
|
+
}
|
|
901
|
+
conditions.add(`contains(text(),${(0, exports.escapeCharacters)(rawText)})`);
|
|
902
|
+
return Array.from(conditions);
|
|
903
|
+
};
|
|
904
|
+
const generateAttributeCombinations = (attributes, combinationSize) => {
|
|
905
|
+
const results = [];
|
|
906
|
+
const build = (startIndex, currentGroup) => {
|
|
907
|
+
if (currentGroup.length === combinationSize) {
|
|
908
|
+
results.push([...currentGroup]);
|
|
909
|
+
return;
|
|
910
|
+
}
|
|
911
|
+
for (let i = startIndex; i < attributes.length; i++) {
|
|
912
|
+
currentGroup.push(attributes[i]);
|
|
913
|
+
build(i + 1, currentGroup);
|
|
914
|
+
currentGroup.pop();
|
|
915
|
+
}
|
|
916
|
+
};
|
|
917
|
+
build(0, []);
|
|
918
|
+
return results;
|
|
919
|
+
};
|
|
920
|
+
const buildXPath = (conditions) => (0, exports.isSvg)(domNode)
|
|
921
|
+
? `//*[local-name()='${domNode.tagName}' and ${conditions.join(" and ")}]`
|
|
922
|
+
: `//${domNode.tagName}[${conditions.join(" and ")}]`;
|
|
923
|
+
const tryAttributeOnlyCombinations = () => {
|
|
924
|
+
if (candidateAttributes.length < 2) {
|
|
925
|
+
return undefined;
|
|
926
|
+
}
|
|
927
|
+
for (let combinationSize = 2; combinationSize <= candidateAttributes.length; combinationSize++) {
|
|
928
|
+
const attributeGroups = generateAttributeCombinations(candidateAttributes, combinationSize);
|
|
929
|
+
for (const attributeGroup of attributeGroups) {
|
|
930
|
+
const xpathConditions = [];
|
|
931
|
+
for (const attribute of attributeGroup) {
|
|
932
|
+
const attributeConditions = buildAttributeConditions(attribute);
|
|
933
|
+
if (!attributeConditions.length)
|
|
934
|
+
continue;
|
|
935
|
+
xpathConditions.push(...attributeConditions);
|
|
936
|
+
}
|
|
937
|
+
if (xpathConditions.length < 2)
|
|
938
|
+
continue;
|
|
939
|
+
const xpath = buildXPath(xpathConditions);
|
|
940
|
+
let matchCount;
|
|
941
|
+
try {
|
|
942
|
+
matchCount = (0, exports.getCountOfXPath)(xpath, domNode, docmt);
|
|
943
|
+
}
|
|
944
|
+
catch {
|
|
945
|
+
continue;
|
|
946
|
+
}
|
|
947
|
+
if (matchCount === 1) {
|
|
948
|
+
return xpath;
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
return undefined;
|
|
953
|
+
};
|
|
954
|
+
const attributeOnlyXpath = tryAttributeOnlyCombinations();
|
|
955
|
+
if (attributeOnlyXpath) {
|
|
956
|
+
return attributeOnlyXpath;
|
|
957
|
+
}
|
|
958
|
+
const textConditions = getTextConditions();
|
|
959
|
+
if (!textConditions.length || !candidateAttributes.length) {
|
|
960
|
+
return;
|
|
961
|
+
}
|
|
962
|
+
for (let combinationSize = 1; combinationSize <= candidateAttributes.length; combinationSize++) {
|
|
963
|
+
const attributeGroups = generateAttributeCombinations(candidateAttributes, combinationSize);
|
|
964
|
+
for (const attributeGroup of attributeGroups) {
|
|
965
|
+
const attributeConditions = [];
|
|
966
|
+
for (const attribute of attributeGroup) {
|
|
967
|
+
attributeConditions.push(...buildAttributeConditions(attribute));
|
|
968
|
+
}
|
|
969
|
+
if (!attributeConditions.length) {
|
|
970
|
+
continue;
|
|
971
|
+
}
|
|
972
|
+
for (const textCondition of textConditions) {
|
|
973
|
+
const xpathConditions = [...attributeConditions, textCondition];
|
|
974
|
+
const xpath = buildXPath(xpathConditions);
|
|
975
|
+
try {
|
|
976
|
+
if ((0, exports.getCountOfXPath)(xpath, domNode, docmt) === 1) {
|
|
977
|
+
return xpath;
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
catch {
|
|
981
|
+
continue;
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
catch (error) {
|
|
988
|
+
logData_1.logger.error(`XPath generation error: ${JSON.stringify(error, null, 2)}`);
|
|
989
|
+
}
|
|
990
|
+
};
|
|
991
|
+
exports.getAttributeCombinationXpath = getAttributeCombinationXpath;
|
|
992
|
+
const intermediateXpathStep = (targetElemt, attr, isTarget) => {
|
|
993
|
+
const isSvgElement = (0, exports.isSvg)(targetElemt);
|
|
994
|
+
let expression = "";
|
|
995
|
+
if ((0, exports.checkBlockedAttributes)(attr, targetElemt, isTarget)) {
|
|
996
|
+
const attrValue = (0, exports.sanitizeAttributeValue)(attr.name, attr.value);
|
|
997
|
+
const elementName = attr.name;
|
|
998
|
+
if (!exports.reWhiteSpace.test(attrValue)) {
|
|
999
|
+
expression = isSvgElement
|
|
1000
|
+
? `*[local-name()='${targetElemt.tagName}' and normalize-space(@${elementName})=${(0, exports.escapeCharacters)(attrValue)}]`
|
|
1001
|
+
: `${targetElemt.tagName || "*"}[normalize-space(@${elementName})=${(0, exports.escapeCharacters)(attrValue)}]`;
|
|
1002
|
+
}
|
|
1003
|
+
else {
|
|
1004
|
+
expression = isSvgElement
|
|
1005
|
+
? `*[local-name()='${targetElemt.tagName}' and @${elementName}=${(0, exports.escapeCharacters)(attrValue)}]`
|
|
1006
|
+
: `${targetElemt.tagName || "*"}[@${elementName}=${(0, exports.escapeCharacters)(attrValue)}]`;
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
return expression;
|
|
1010
|
+
};
|
|
1011
|
+
exports.intermediateXpathStep = intermediateXpathStep;
|
|
1012
|
+
const getFilteredTextXPath = (node) => {
|
|
1013
|
+
if (!node.textContent)
|
|
1014
|
+
return "";
|
|
1015
|
+
const filteredText = (0, exports.getFilteredText)(node);
|
|
1016
|
+
let xpathe;
|
|
1017
|
+
if (!exports.reWhiteSpace.test(filteredText)) {
|
|
1018
|
+
xpathe = (0, exports.isSvg)(node)
|
|
1019
|
+
? `//*[local-name()='${node.tagName}' and normalize-space(.)=${(0, exports.escapeCharacters)(filteredText)}]`
|
|
1020
|
+
: `//${node.tagName || "*"}[normalize-space(.)=${(0, exports.escapeCharacters)(filteredText)}]`;
|
|
1021
|
+
}
|
|
1022
|
+
else {
|
|
1023
|
+
xpathe = (0, exports.isSvg)(node)
|
|
1024
|
+
? `//*[local-name()='${node.tagName}' and .=${(0, exports.escapeCharacters)(filteredText)}]`
|
|
1025
|
+
: `//${node.tagName || "*"}[.=${(0, exports.escapeCharacters)(filteredText)}]`;
|
|
1026
|
+
}
|
|
1027
|
+
return xpathe;
|
|
1028
|
+
};
|
|
1029
|
+
exports.getFilteredTextXPath = getFilteredTextXPath;
|
|
1030
|
+
const getNormalizedPropertyXPath = (element, prop, value, platform) => {
|
|
1031
|
+
const elementTagName = platform === "web" ? element.tagName.toLowerCase() : element.localName;
|
|
1032
|
+
const xpath = (0, exports.buildPattern)(`normalize-space(${prop})=${(0, exports.escapeCharacters)((0, exports.replaceWhiteSpaces)(value)).trim()}`, (0, exports.isSvg)(element), elementTagName);
|
|
1033
|
+
// logger.info("normalizedPropertyXPath", xpath)
|
|
1034
|
+
return xpath;
|
|
1035
|
+
};
|
|
1036
|
+
exports.getNormalizedPropertyXPath = getNormalizedPropertyXPath;
|
|
1037
|
+
const getStartsWithPropertyXPath = (element, prop, value, platform) => {
|
|
1038
|
+
const elementTagName = platform === "web" ? element.tagName.toLowerCase() : element.localName;
|
|
1039
|
+
const xpath = (0, exports.buildPattern)(`starts-with(${prop},${(0, exports.escapeCharacters)((0, exports.replaceWhiteSpaces)(value)).trim()})`, (0, exports.isSvg)(element), elementTagName);
|
|
1040
|
+
// logger.info("getStartsWithPropertyXPath", xpath)
|
|
1041
|
+
return xpath;
|
|
1042
|
+
};
|
|
1043
|
+
exports.getStartsWithPropertyXPath = getStartsWithPropertyXPath;
|
|
1044
|
+
const getContainsPropertyXPath = (element, prop, value, platform) => {
|
|
1045
|
+
const elementTagName = platform === "web" ? element.tagName.toLowerCase() : element.localName;
|
|
1046
|
+
const xpath = (0, exports.buildPattern)(`contains(${prop},${(0, exports.escapeCharacters)((0, exports.replaceWhiteSpaces)(value)).trim()})`, (0, exports.isSvg)(element), elementTagName);
|
|
1047
|
+
// logger.info("getContainsPropertyXPath", xpath)
|
|
1048
|
+
return xpath;
|
|
1049
|
+
};
|
|
1050
|
+
exports.getContainsPropertyXPath = getContainsPropertyXPath;
|
|
1051
|
+
const getOrAttributesXPath = (element, attributes, platform) => {
|
|
1052
|
+
const elementTagName = platform === "web" ? element.tagName.toLowerCase() : element.localName;
|
|
1053
|
+
const buildAttributeCondition = (attribute) => {
|
|
1054
|
+
const attrValue = (0, exports.sanitizeAttributeValue)(attribute.name, attribute.value);
|
|
1055
|
+
if (!attrValue) {
|
|
1056
|
+
return null;
|
|
1057
|
+
}
|
|
1058
|
+
if (attribute.name === "class") {
|
|
1059
|
+
const classTokens = attrValue
|
|
1060
|
+
.split(/\s+/)
|
|
1061
|
+
.map((token) => token.trim())
|
|
1062
|
+
.filter(Boolean);
|
|
1063
|
+
const docmt = element.getRootNode?.() ??
|
|
1064
|
+
element.ownerDocument;
|
|
1065
|
+
const rankedToken = classTokens
|
|
1066
|
+
.map((token) => {
|
|
1067
|
+
const xpath = (0, exports.buildPattern)(`contains(@class,${(0, exports.escapeCharacters)(token)})`, (0, exports.isSvg)(element), elementTagName);
|
|
1068
|
+
return {
|
|
1069
|
+
token,
|
|
1070
|
+
count: getTagOnlyXpathCandidateCount(xpath, element, docmt)
|
|
1071
|
+
};
|
|
1072
|
+
})
|
|
1073
|
+
.sort((left, right) => {
|
|
1074
|
+
if (left.count !== right.count) {
|
|
1075
|
+
return left.count - right.count;
|
|
1076
|
+
}
|
|
1077
|
+
return right.token.length - left.token.length;
|
|
1078
|
+
})[0]?.token;
|
|
1079
|
+
return rankedToken
|
|
1080
|
+
? `contains(@class,${(0, exports.escapeCharacters)(rankedToken)})`
|
|
1081
|
+
: null;
|
|
1082
|
+
}
|
|
1083
|
+
if (!exports.reWhiteSpace.test(attrValue)) {
|
|
1084
|
+
return `normalize-space(@${attribute.name})=${(0, exports.escapeCharacters)(attrValue)}`;
|
|
1085
|
+
}
|
|
1086
|
+
return `@${attribute.name}=${(0, exports.escapeCharacters)(attrValue)}`;
|
|
1087
|
+
};
|
|
1088
|
+
const buildTextCondition = () => {
|
|
1089
|
+
const rawText = (0, exports.replaceWhiteSpaces)((0, exports.getTextContent)(element)?.trim() || "");
|
|
1090
|
+
if (!rawText || rawText.length > 80 || /^\d+$/.test(rawText)) {
|
|
1091
|
+
return null;
|
|
1092
|
+
}
|
|
1093
|
+
if (exports.reWhiteSpace.test(rawText) && rawText.length <= 40) {
|
|
1094
|
+
return `text()=${(0, exports.escapeCharacters)(rawText)}`;
|
|
1095
|
+
}
|
|
1096
|
+
if (rawText.includes(" ")) {
|
|
1097
|
+
return `normalize-space(text())=${(0, exports.escapeCharacters)(rawText)}`;
|
|
1098
|
+
}
|
|
1099
|
+
return `contains(text(),${(0, exports.escapeCharacters)(rawText)})`;
|
|
1100
|
+
};
|
|
1101
|
+
const attributeConditions = attributes
|
|
1102
|
+
.map((attribute) => buildAttributeCondition(attribute))
|
|
1103
|
+
.filter(Boolean);
|
|
1104
|
+
if (attributeConditions.length >= 2) {
|
|
1105
|
+
return (0, exports.buildPattern)(`${attributeConditions[0]} or ${attributeConditions[1]}`, (0, exports.isSvg)(element), elementTagName);
|
|
1106
|
+
}
|
|
1107
|
+
const textCondition = buildTextCondition();
|
|
1108
|
+
if (attributeConditions.length === 1 && textCondition) {
|
|
1109
|
+
return (0, exports.buildPattern)(`${attributeConditions[0]} or ${textCondition}`, (0, exports.isSvg)(element), elementTagName);
|
|
1110
|
+
}
|
|
1111
|
+
return "";
|
|
1112
|
+
};
|
|
1113
|
+
exports.getOrAttributesXPath = getOrAttributesXPath;
|
|
1114
|
+
const getTagOnlyXpathCandidateCount = (xpath, element, docmt) => {
|
|
1115
|
+
try {
|
|
1116
|
+
return (0, exports.getCountOfXPath)(xpath, element, docmt);
|
|
1117
|
+
}
|
|
1118
|
+
catch (_error) {
|
|
1119
|
+
logData_1.logger.error(`error in getTagOnlyXpathCandidateCount ${_error.message}`);
|
|
1120
|
+
return 0;
|
|
1121
|
+
}
|
|
1122
|
+
};
|
|
1123
|
+
const getAncestorAnchorCandidates = (node, docmt, platform) => {
|
|
1124
|
+
const anchors = [];
|
|
1125
|
+
const seen = new Set();
|
|
1126
|
+
const attributes = Array.from(node.attributes || []);
|
|
1127
|
+
const priorityAttrs = [
|
|
1128
|
+
"id",
|
|
1129
|
+
"data-testid",
|
|
1130
|
+
"data-test",
|
|
1131
|
+
"data-qa",
|
|
1132
|
+
"name",
|
|
1133
|
+
"aria-label",
|
|
1134
|
+
"role"
|
|
1135
|
+
];
|
|
1136
|
+
const orderedAttributes = [
|
|
1137
|
+
...priorityAttrs
|
|
1138
|
+
.map((attrName) => attributes.find((attr) => attr.name === attrName))
|
|
1139
|
+
.filter(Boolean),
|
|
1140
|
+
...attributes.filter((attr) => !priorityAttrs.includes(attr.name))
|
|
1141
|
+
];
|
|
1142
|
+
const pushAnchor = (xpath) => {
|
|
1143
|
+
if (!xpath || seen.has(xpath))
|
|
1144
|
+
return;
|
|
1145
|
+
if ((0, exports.isExactUniqueXpath)(xpath, node, docmt)) {
|
|
1146
|
+
seen.add(xpath);
|
|
1147
|
+
anchors.push(xpath);
|
|
1148
|
+
}
|
|
1149
|
+
};
|
|
1150
|
+
orderedAttributes.forEach((attr) => {
|
|
1151
|
+
if (!(0, exports.checkBlockedAttributes)(attr, node, false))
|
|
1152
|
+
return;
|
|
1153
|
+
const xpath = attr.name === "id"
|
|
1154
|
+
? `//*[@id=${(0, exports.escapeCharacters)((0, exports.sanitizeAttributeValue)(attr.name, attr.value))}]`
|
|
1155
|
+
: (0, exports.getXpathString)(node, attr.name, attr.value);
|
|
1156
|
+
if (xpath) {
|
|
1157
|
+
pushAnchor(xpath);
|
|
1158
|
+
}
|
|
1159
|
+
});
|
|
1160
|
+
const text = node.textContent?.trim();
|
|
1161
|
+
if (text && text.length < 40 && node.children.length === 0) {
|
|
1162
|
+
const textXpath = (0, exports.getFilteredTextXPath)(node);
|
|
1163
|
+
if (textXpath) {
|
|
1164
|
+
pushAnchor(textXpath);
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
if (attributes.length > 1) {
|
|
1168
|
+
const combinationXpath = (0, exports.getAttributeCombinationXpath)(node, docmt, attributes, false, platform);
|
|
1169
|
+
if (combinationXpath) {
|
|
1170
|
+
pushAnchor(combinationXpath);
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
return anchors;
|
|
1174
|
+
};
|
|
1175
|
+
const getStructuralPathFromAncestor = (ancestor, element, platform) => {
|
|
1176
|
+
const steps = [];
|
|
1177
|
+
let current = element;
|
|
1178
|
+
while (current && current !== ancestor) {
|
|
1179
|
+
steps.unshift((0, exports.getAxisNodeTest)(current, platform));
|
|
1180
|
+
current = current.parentElement;
|
|
1181
|
+
}
|
|
1182
|
+
return current === ancestor ? steps.join("/") : "";
|
|
1183
|
+
};
|
|
1184
|
+
const getTagOnlyXPath = (element, platform, docmt) => {
|
|
1185
|
+
const root = docmt ??
|
|
1186
|
+
(element.getRootNode?.() ||
|
|
1187
|
+
element.ownerDocument);
|
|
1188
|
+
const tagName = (0, exports.getAxisNodeTest)(element, platform);
|
|
1189
|
+
const elementTagName = platform === "web" ? element.tagName.toLowerCase() : element.localName;
|
|
1190
|
+
const fallbackXpath = (0, exports.isSvg)(element)
|
|
1191
|
+
? `//*[local-name()='${elementTagName}']`
|
|
1192
|
+
: `//${elementTagName}`;
|
|
1193
|
+
for (let ancestor = element.parentElement; ancestor; ancestor = ancestor.parentElement) {
|
|
1194
|
+
const ancestorAnchors = getAncestorAnchorCandidates(ancestor, root, platform);
|
|
1195
|
+
for (const ancestorXpath of ancestorAnchors) {
|
|
1196
|
+
// logger.info(`Trying ancestor XPath: ${ancestorXpath}`);
|
|
1197
|
+
const descendantXpath = `${ancestorXpath}/descendant::${tagName}`;
|
|
1198
|
+
// logger.info(`Trying descendant XPath: ${descendantXpath}`);
|
|
1199
|
+
const count = getTagOnlyXpathCandidateCount(descendantXpath, element, root);
|
|
1200
|
+
// logger.info(`Match count: ${count}`);
|
|
1201
|
+
if (count === 1 &&
|
|
1202
|
+
(0, exports.getFirstMatchedNode)(descendantXpath, root) === element) {
|
|
1203
|
+
// logger.info(`Selected XPath: ${descendantXpath}`);
|
|
1204
|
+
return descendantXpath;
|
|
1205
|
+
}
|
|
1206
|
+
const structuralPath = getStructuralPathFromAncestor(ancestor, element, platform);
|
|
1207
|
+
if (structuralPath) {
|
|
1208
|
+
const parentChainXpath = `${ancestorXpath}/${structuralPath}`;
|
|
1209
|
+
// logger.info(`Trying descendant XPath: ${parentChainXpath}`);
|
|
1210
|
+
const parentChainCount = getTagOnlyXpathCandidateCount(parentChainXpath, element, root);
|
|
1211
|
+
// logger.info(`Match count: ${parentChainCount}`);
|
|
1212
|
+
if (parentChainCount === 1 &&
|
|
1213
|
+
(0, exports.getFirstMatchedNode)(parentChainXpath, root) === element) {
|
|
1214
|
+
// logger.info(`Selected XPath: ${parentChainXpath}`);
|
|
1215
|
+
return parentChainXpath;
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
// logger.info(`Trying descendant XPath: ${fallbackXpath}`);
|
|
1221
|
+
const fallbackCount = getTagOnlyXpathCandidateCount(fallbackXpath, element, root);
|
|
1222
|
+
// logger.info(`Match count: ${fallbackCount}`);
|
|
1223
|
+
if (fallbackCount === 1 &&
|
|
1224
|
+
(0, exports.getFirstMatchedNode)(fallbackXpath, root) === element) {
|
|
1225
|
+
// logger.info(`Selected XPath: ${fallbackXpath}`);
|
|
1226
|
+
return fallbackXpath;
|
|
1227
|
+
}
|
|
1228
|
+
return "";
|
|
1229
|
+
};
|
|
1230
|
+
exports.getTagOnlyXPath = getTagOnlyXPath;
|
|
1231
|
+
const getFirstMatchedNode = (xpath, docmt) => {
|
|
1232
|
+
try {
|
|
1233
|
+
if (isShadowRootNode(docmt)) {
|
|
1234
|
+
const { contextNode, cloneElement } = (0, exports.createShadowEvaluationContext)(docmt);
|
|
1235
|
+
// const result = owner.evaluate(
|
|
1236
|
+
// xpath,
|
|
1237
|
+
// contextNode,
|
|
1238
|
+
// null,
|
|
1239
|
+
// owner.defaultView!.XPathResult.FIRST_ORDERED_NODE_TYPE,
|
|
1240
|
+
// null
|
|
1241
|
+
// );
|
|
1242
|
+
const result = evaluateXPath(xpath, contextNode, "first");
|
|
1243
|
+
return (result.singleNodeValue || cloneElement);
|
|
1244
|
+
}
|
|
1245
|
+
// const result = docmt.evaluate(
|
|
1246
|
+
// xpath,
|
|
1247
|
+
// docmt,
|
|
1248
|
+
// null,
|
|
1249
|
+
// docmt.defaultView!.XPathResult.FIRST_ORDERED_NODE_TYPE,
|
|
1250
|
+
// null
|
|
1251
|
+
// );
|
|
1252
|
+
const result = evaluateXPath(xpath, docmt, "first");
|
|
1253
|
+
return result.singleNodeValue;
|
|
1254
|
+
}
|
|
1255
|
+
catch (_error) {
|
|
1256
|
+
logData_1.logger.error(`error in getFirstMatchedNode ${_error.message}`);
|
|
1257
|
+
return null;
|
|
1258
|
+
}
|
|
1259
|
+
};
|
|
1260
|
+
exports.getFirstMatchedNode = getFirstMatchedNode;
|
|
1261
|
+
const isExactUniqueXpath = (xpath, element, docmt) => {
|
|
1262
|
+
try {
|
|
1263
|
+
const { first, second } = (0, exports.evaluateXPathOnce)(xpath, docmt);
|
|
1264
|
+
return !!first && !second && first === element;
|
|
1265
|
+
}
|
|
1266
|
+
catch {
|
|
1267
|
+
return false;
|
|
1268
|
+
}
|
|
1269
|
+
};
|
|
1270
|
+
exports.isExactUniqueXpath = isExactUniqueXpath;
|
|
1271
|
+
const getAxisNodeTest = (element, platform) => {
|
|
1272
|
+
const elementTagName = platform === "web" ? element.tagName.toLowerCase() : element.localName;
|
|
1273
|
+
return (0, exports.isSvg)(element)
|
|
1274
|
+
? `*[local-name()='${elementTagName}']`
|
|
1275
|
+
: elementTagName;
|
|
1276
|
+
};
|
|
1277
|
+
exports.getAxisNodeTest = getAxisNodeTest;
|
|
1278
|
+
const hasAnyNumber = (value) => /\d/.test(value);
|
|
1279
|
+
const getUniqueNodeAnchorXpaths = (node, docmt, isTarget, platform) => {
|
|
1280
|
+
if (!(node instanceof node.ownerDocument.defaultView.Element))
|
|
1281
|
+
return [];
|
|
1282
|
+
const seen = new Set();
|
|
1283
|
+
const anchors = [];
|
|
1284
|
+
const attributes = Array.from(node.attributes || []).filter((attribute) => attribute?.value &&
|
|
1285
|
+
!hasAnyNumber(attribute.value) &&
|
|
1286
|
+
(0, exports.checkBlockedAttributes)(attribute, node, isTarget));
|
|
1287
|
+
const pushAnchor = (key, value) => {
|
|
1288
|
+
if (!value || seen.has(value))
|
|
1289
|
+
return;
|
|
1290
|
+
seen.add(value);
|
|
1291
|
+
anchors.push({ key, value });
|
|
1292
|
+
};
|
|
1293
|
+
// Priority attributes
|
|
1294
|
+
const priorityAttrs = [
|
|
1295
|
+
"id",
|
|
1296
|
+
"data-testid",
|
|
1297
|
+
"data-test",
|
|
1298
|
+
"data-qa",
|
|
1299
|
+
"name",
|
|
1300
|
+
"aria-label",
|
|
1301
|
+
"role"
|
|
1302
|
+
];
|
|
1303
|
+
priorityAttrs.forEach((attrName) => {
|
|
1304
|
+
const attr = attributes.find((a) => a.name === attrName);
|
|
1305
|
+
if (!attr)
|
|
1306
|
+
return;
|
|
1307
|
+
const xpath = attrName === "id"
|
|
1308
|
+
? `//*[@id='${attr.value}']`
|
|
1309
|
+
: (0, exports.getXpathString)(node, attr.name, attr.value);
|
|
1310
|
+
if (xpath && (0, exports.isExactUniqueXpath)(xpath, node, docmt)) {
|
|
1311
|
+
pushAnchor(`anchor by ${attr.name}`, xpath);
|
|
1312
|
+
}
|
|
1313
|
+
});
|
|
1314
|
+
// Other attributes
|
|
1315
|
+
attributes.forEach((attribute) => {
|
|
1316
|
+
if (priorityAttrs.includes(attribute.name))
|
|
1317
|
+
return;
|
|
1318
|
+
const xpath = (0, exports.getXpathString)(node, attribute.name, attribute.value);
|
|
1319
|
+
if (xpath && (0, exports.isExactUniqueXpath)(xpath, node, docmt)) {
|
|
1320
|
+
pushAnchor(`anchor by ${attribute.name}`, xpath);
|
|
1321
|
+
}
|
|
1322
|
+
});
|
|
1323
|
+
// Text (controlled)
|
|
1324
|
+
const text = node.textContent?.trim();
|
|
1325
|
+
if (text && text.length < 40 && node.children.length === 0) {
|
|
1326
|
+
const textXpath = (0, exports.getFilteredTextXPath)(node);
|
|
1327
|
+
if (textXpath && (0, exports.isExactUniqueXpath)(textXpath, node, docmt)) {
|
|
1328
|
+
pushAnchor("anchor by text", textXpath);
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
// Combination
|
|
1332
|
+
if (attributes.length > 1) {
|
|
1333
|
+
const combinationXpath = (0, exports.getAttributeCombinationXpath)(node, docmt, attributes, isTarget, platform);
|
|
1334
|
+
if (combinationXpath && (0, exports.isExactUniqueXpath)(combinationXpath, node, docmt)) {
|
|
1335
|
+
pushAnchor("anchor by combination", combinationXpath);
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
// Tag (last fallback)
|
|
1339
|
+
const tagXpath = (0, exports.getTagOnlyXPath)(node, platform, docmt);
|
|
1340
|
+
if (tagXpath && (0, exports.isExactUniqueXpath)(tagXpath, node, docmt)) {
|
|
1341
|
+
pushAnchor("anchor by tag", tagXpath);
|
|
1342
|
+
}
|
|
1343
|
+
return anchors;
|
|
1344
|
+
};
|
|
1345
|
+
exports.getUniqueNodeAnchorXpaths = getUniqueNodeAnchorXpaths;
|
|
1346
|
+
const getTextXpathFunction = (domNode) => {
|
|
1347
|
+
const trimmedText = (0, exports.getTextContent)(domNode)?.trim();
|
|
1348
|
+
const filteredText = trimmedText
|
|
1349
|
+
? (0, exports.escapeCharacters)(deleteGarbageFromInnerText(trimmedText))
|
|
1350
|
+
: trimmedText;
|
|
1351
|
+
if (filteredText) {
|
|
1352
|
+
if (filteredText !== `'${trimmedText}'`) {
|
|
1353
|
+
return `contains(.,${filteredText})`;
|
|
1354
|
+
}
|
|
1355
|
+
return `normalize-space(.)='${trimmedText}'`;
|
|
1356
|
+
}
|
|
1357
|
+
};
|
|
1358
|
+
exports.getTextXpathFunction = getTextXpathFunction;
|
|
1359
|
+
const getXpathString = (node, attrName, attrValue) => {
|
|
1360
|
+
const reWhiteSpace = new RegExp(/^[\S]+( [\S]+)*$/gi);
|
|
1361
|
+
let xpathe = "";
|
|
1362
|
+
attrValue = (0, exports.sanitizeAttributeValue)(attrName, attrValue);
|
|
1363
|
+
if (attrValue) {
|
|
1364
|
+
if (!reWhiteSpace.test(attrValue)) {
|
|
1365
|
+
xpathe = (0, exports.isSvg)(node)
|
|
1366
|
+
? `//*[local-name()='${node.tagName}' and contains(@${attrName},${(0, exports.escapeCharacters)(attrValue)})]`
|
|
1367
|
+
: `//${node.tagName || "*"}[contains(@${attrName},${(0, exports.escapeCharacters)(attrValue)})]`;
|
|
1368
|
+
}
|
|
1369
|
+
else if (attrName === "class") {
|
|
1370
|
+
xpathe = (0, exports.isSvg)(node)
|
|
1371
|
+
? `//*[local-name()='${node.tagName}' and contains(@${attrName},${(0, exports.escapeCharacters)(attrValue)})]`
|
|
1372
|
+
: `//${node.tagName || "*"}[contains(@${attrName},${(0, exports.escapeCharacters)(attrValue)})]`;
|
|
1373
|
+
}
|
|
1374
|
+
else {
|
|
1375
|
+
xpathe = (0, exports.isSvg)(node)
|
|
1376
|
+
? `//*[local-name()='${node.tagName}' and @${attrName}=${(0, exports.escapeCharacters)(attrValue)}]`
|
|
1377
|
+
: `//${node.tagName || "*"}[@${attrName}=${(0, exports.escapeCharacters)(attrValue)}]`;
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
return xpathe;
|
|
1381
|
+
};
|
|
1382
|
+
exports.getXpathString = getXpathString;
|
|
1383
|
+
const replaceActualAttributes = (str) => {
|
|
1384
|
+
if (str) {
|
|
1385
|
+
return str.replace(/\bdisabled\b/gi, "flndisabled");
|
|
1386
|
+
}
|
|
1387
|
+
return str;
|
|
1388
|
+
};
|
|
1389
|
+
exports.replaceActualAttributes = replaceActualAttributes;
|
|
1390
|
+
const addAttributeSplitCombineXpaths = (attributes, targetElemt, docmt, isTarget) => {
|
|
1391
|
+
const attributesArray = Array.prototype.slice.call(attributes);
|
|
1392
|
+
const xpaths = [];
|
|
1393
|
+
try {
|
|
1394
|
+
attributesArray.map((element) => {
|
|
1395
|
+
if ((0, exports.checkBlockedAttributes)(element, targetElemt, isTarget)) {
|
|
1396
|
+
const xpth = (0, exports.getCombinationXpath)(element, targetElemt);
|
|
1397
|
+
if (xpth) {
|
|
1398
|
+
xpaths.push({
|
|
1399
|
+
key: `split xpath by ${element.name}`,
|
|
1400
|
+
value: xpth
|
|
1401
|
+
});
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
});
|
|
1405
|
+
}
|
|
1406
|
+
catch (error) {
|
|
1407
|
+
logData_1.logger.error(`error in addAttributeSplitCombineXpaths ${error.message}`);
|
|
1408
|
+
}
|
|
1409
|
+
return xpaths;
|
|
1410
|
+
};
|
|
1411
|
+
const getReferenceElementsXpath = (domNode, docmt, isTarget, platform) => {
|
|
1412
|
+
let nodeXpath1;
|
|
1413
|
+
const xpaths1 = [];
|
|
1414
|
+
if (domNode.textContent &&
|
|
1415
|
+
(!isTarget || (isTarget && !(0, exports.isNumberExist)(domNode.textContent)))) {
|
|
1416
|
+
if (!exports.reWhiteSpace.test(domNode.textContent)) {
|
|
1417
|
+
nodeXpath1 = (0, exports.isSvg)(domNode)
|
|
1418
|
+
? `*[local-name()='${domNode.tagName}' and ${(0, exports.getTextXpathFunction)(domNode)})]`
|
|
1419
|
+
: `${domNode.tagName}[${(0, exports.getTextXpathFunction)(domNode)}]`;
|
|
1420
|
+
if (nodeXpath1) {
|
|
1421
|
+
xpaths1.push({ key: "getReferenceElementsXpath", value: nodeXpath1 });
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
else {
|
|
1425
|
+
nodeXpath1 = (0, exports.isSvg)(domNode)
|
|
1426
|
+
? `*[local-name()='${domNode.tagName}' and .=${(0, exports.escapeCharacters)((0, exports.getTextContent)(domNode))}]`
|
|
1427
|
+
: `${domNode.tagName}[.=${(0, exports.escapeCharacters)((0, exports.getTextContent)(domNode))}]`;
|
|
1428
|
+
if (nodeXpath1) {
|
|
1429
|
+
xpaths1.push({ key: "getReferenceElementsXpath", value: nodeXpath1 });
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
if (domNode.attributes) {
|
|
1434
|
+
for (const attrName of Array.from(domNode.attributes)) {
|
|
1435
|
+
if ((0, exports.checkBlockedAttributes)(attrName, domNode, isTarget)) {
|
|
1436
|
+
let attrValue = attrName.nodeValue;
|
|
1437
|
+
if (attrValue) {
|
|
1438
|
+
attrValue = (0, exports.sanitizeAttributeValue)(attrName.name, attrValue);
|
|
1439
|
+
const elementName = attrName.name;
|
|
1440
|
+
if (elementName === "class") {
|
|
1441
|
+
nodeXpath1 = (0, exports.isSvg)(domNode)
|
|
1442
|
+
? `*[local-name()='${domNode.tagName}' and contains(@${elementName},${(0, exports.escapeCharacters)(attrValue)})]`
|
|
1443
|
+
: `${domNode.tagName}[contains(@${elementName},${(0, exports.escapeCharacters)(attrValue)})]`;
|
|
1444
|
+
}
|
|
1445
|
+
else {
|
|
1446
|
+
nodeXpath1 = (0, exports.isSvg)(domNode)
|
|
1447
|
+
? `*[local-name()='${domNode.tagName}' and @${elementName}=${(0, exports.escapeCharacters)(attrValue)}]`
|
|
1448
|
+
: `${domNode.tagName}[@${elementName}=${(0, exports.escapeCharacters)(attrValue)}]`;
|
|
1449
|
+
}
|
|
1450
|
+
if (nodeXpath1) {
|
|
1451
|
+
xpaths1.push({
|
|
1452
|
+
key: "getReferenceElementsXpath",
|
|
1453
|
+
value: nodeXpath1
|
|
1454
|
+
});
|
|
1455
|
+
}
|
|
1456
|
+
}
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
if (!xpaths1?.length) {
|
|
1461
|
+
const attributesArray = Array.prototype.slice.call(domNode.attributes);
|
|
1462
|
+
if (attributesArray?.length > 1) {
|
|
1463
|
+
const combinationXpath = (0, exports.getAttributeCombinationXpath)(domNode, docmt, Array.prototype.slice.call(domNode.attributes), isTarget, platform);
|
|
1464
|
+
if (combinationXpath) {
|
|
1465
|
+
xpaths1.push({
|
|
1466
|
+
key: "getReferenceElementsXpath",
|
|
1467
|
+
value: combinationXpath
|
|
1468
|
+
});
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
if (!xpaths1?.length) {
|
|
1473
|
+
const combinePattern = [];
|
|
1474
|
+
let pattern;
|
|
1475
|
+
const tag = (0, exports.isSvg)(domNode);
|
|
1476
|
+
if (domNode.textContent && isTarget && (0, exports.isNumberExist)(domNode.textContent)) {
|
|
1477
|
+
const contentRes = [...new Set(domNode.textContent.match(/([^0-9]+)/g))];
|
|
1478
|
+
if (contentRes?.length) {
|
|
1479
|
+
for (let i = 0; i < contentRes?.length; i++) {
|
|
1480
|
+
if (contentRes[i] &&
|
|
1481
|
+
(0, exports.replaceWhiteSpaces)(contentRes[i].trim())?.length > 1) {
|
|
1482
|
+
if (!exports.reWhiteSpace.test(contentRes[i])) {
|
|
1483
|
+
combinePattern.push(`contains(.,${(0, exports.escapeCharacters)((0, exports.replaceWhiteSpaces)(contentRes[i])).trim()})`);
|
|
1484
|
+
}
|
|
1485
|
+
else {
|
|
1486
|
+
combinePattern.push(`contains(.,${(0, exports.escapeCharacters)(contentRes[i]).trim()})`);
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
if (combinePattern?.length) {
|
|
1492
|
+
if (tag) {
|
|
1493
|
+
pattern = `//*[local-name()='${tag}' and ${combinePattern.join(" and ")}]`;
|
|
1494
|
+
}
|
|
1495
|
+
else {
|
|
1496
|
+
pattern = `//${tag}[${combinePattern.join(" and ")}]`;
|
|
1497
|
+
}
|
|
1498
|
+
if (pattern)
|
|
1499
|
+
xpaths1.push({ key: "getReferenceElementsXpath", value: pattern });
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
if (!xpaths1?.length) {
|
|
1504
|
+
const xpaths = addAttributeSplitCombineXpaths(domNode.attributes, domNode, docmt, isTarget);
|
|
1505
|
+
if (xpaths?.length) {
|
|
1506
|
+
xpaths1.concat(xpaths);
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
return xpaths1;
|
|
1510
|
+
};
|
|
1511
|
+
exports.getReferenceElementsXpath = getReferenceElementsXpath;
|
|
1512
|
+
const normalizeXPath = (xpath) => {
|
|
1513
|
+
// Replace text() = "value" or text()='value'
|
|
1514
|
+
xpath = xpath.replace(/text\(\)\s*=\s*(['"])(.*?)\1/g, "normalize-space(.)=$1$2$1");
|
|
1515
|
+
// Replace . = "value" or .='value'
|
|
1516
|
+
xpath = xpath.replace(/\.\s*=\s*(['"])(.*?)\1/g, "normalize-space(.)=$1$2$1");
|
|
1517
|
+
return xpath;
|
|
1518
|
+
};
|
|
1519
|
+
exports.normalizeXPath = normalizeXPath;
|
|
1520
|
+
const findMatchingParenthesis = (text, openPos) => {
|
|
1521
|
+
let closePos = openPos;
|
|
1522
|
+
let counter = 1;
|
|
1523
|
+
while (counter > 0) {
|
|
1524
|
+
const c = text[++closePos];
|
|
1525
|
+
if (c == "(") {
|
|
1526
|
+
counter++;
|
|
1527
|
+
}
|
|
1528
|
+
else if (c == ")") {
|
|
1529
|
+
counter--;
|
|
1530
|
+
}
|
|
1531
|
+
}
|
|
1532
|
+
return closePos;
|
|
1533
|
+
};
|
|
1534
|
+
exports.findMatchingParenthesis = findMatchingParenthesis;
|
|
1535
|
+
function escapeAttrValue(value) {
|
|
1536
|
+
return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/ /g, "\\ ");
|
|
1537
|
+
}
|
|
1538
|
+
function isUniqueInDOM(docmt, name, value, element) {
|
|
1539
|
+
const root = element?.getRootNode?.() ?? docmt;
|
|
1540
|
+
const queryAll = (selector) => {
|
|
1541
|
+
try {
|
|
1542
|
+
return Array.from(root.querySelectorAll(selector));
|
|
1543
|
+
}
|
|
1544
|
+
catch {
|
|
1545
|
+
return [];
|
|
1546
|
+
}
|
|
1547
|
+
};
|
|
1548
|
+
try {
|
|
1549
|
+
switch (name) {
|
|
1550
|
+
case "id":
|
|
1551
|
+
return queryAll(`#${escapeAttrValue(value)}`).length === 1;
|
|
1552
|
+
case "name":
|
|
1553
|
+
return queryAll(`[name="${escapeAttrValue(value)}"]`).length === 1;
|
|
1554
|
+
case "className":
|
|
1555
|
+
return queryAll(`.${value}`).length === 1;
|
|
1556
|
+
case "tagName":
|
|
1557
|
+
return queryAll(value).length === 1;
|
|
1558
|
+
case "linkText":
|
|
1559
|
+
return (queryAll("a").filter((a) => a.textContent?.trim() === value)
|
|
1560
|
+
.length === 1);
|
|
1561
|
+
case "partialLinkText":
|
|
1562
|
+
return (queryAll("a").filter((a) => a.textContent?.includes(value)).length ===
|
|
1563
|
+
1);
|
|
1564
|
+
case "cssSelector":
|
|
1565
|
+
return queryAll(value).length === 1;
|
|
1566
|
+
default:
|
|
1567
|
+
return false;
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1570
|
+
catch {
|
|
1571
|
+
return false;
|
|
1572
|
+
}
|
|
1573
|
+
}
|
|
1574
|
+
const getPlatformFallbackXpath = (element, platform) => {
|
|
1575
|
+
const tag = element.tagName;
|
|
1576
|
+
if (platform === "android") {
|
|
1577
|
+
const bounds = element.getAttribute("bounds");
|
|
1578
|
+
const index = element.getAttribute("index");
|
|
1579
|
+
if (bounds) {
|
|
1580
|
+
return index
|
|
1581
|
+
? `//${tag}[@index="${index}" and @bounds="${bounds}"]`
|
|
1582
|
+
: `//${tag}[@bounds="${bounds}"]`;
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1585
|
+
if (platform === "ios") {
|
|
1586
|
+
const name = element.getAttribute("name");
|
|
1587
|
+
if (name) {
|
|
1588
|
+
return `//${tag}[@name="${name}"]`;
|
|
1589
|
+
}
|
|
1590
|
+
const label = element.getAttribute("label");
|
|
1591
|
+
if (label) {
|
|
1592
|
+
return `//${tag}[@label="${label}"]`;
|
|
1593
|
+
}
|
|
1594
|
+
const value = element.getAttribute("value");
|
|
1595
|
+
if (value) {
|
|
1596
|
+
return `//${tag}[@value="${value}"]`;
|
|
1597
|
+
}
|
|
1598
|
+
const x = element.getAttribute("x");
|
|
1599
|
+
const y = element.getAttribute("y");
|
|
1600
|
+
const width = element.getAttribute("width");
|
|
1601
|
+
const height = element.getAttribute("height");
|
|
1602
|
+
if (x && y && width && height) {
|
|
1603
|
+
return `//${tag}[@x="${x}" and @y="${y}" and @width="${width}" and @height="${height}"]`;
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
return null;
|
|
1607
|
+
};
|
|
1608
|
+
exports.getPlatformFallbackXpath = getPlatformFallbackXpath;
|
|
1609
|
+
exports.xpathUtils = {
|
|
1610
|
+
getReferenceElementsXpath: exports.getReferenceElementsXpath,
|
|
1611
|
+
getAbsoluteXPath: exports.getAbsoluteXPath,
|
|
1612
|
+
getRelativeXPath: exports.getRelativeXPath,
|
|
1613
|
+
getCombinationXpath: exports.getCombinationXpath,
|
|
1614
|
+
getAttributeCombinationXpath: exports.getAttributeCombinationXpath,
|
|
1615
|
+
isSvg: exports.isSvg,
|
|
1616
|
+
getPlatformFallbackXpath: exports.getPlatformFallbackXpath,
|
|
1617
|
+
findXpathWithIndex: exports.findXpathWithIndex,
|
|
1618
|
+
isNumberExist: exports.isNumberExist,
|
|
1619
|
+
getTextContent: exports.getTextContent,
|
|
1620
|
+
getCountOfXPath: exports.getCountOfXPath,
|
|
1621
|
+
normalizeXPath: exports.normalizeXPath,
|
|
1622
|
+
getShadowRoot: exports.getShadowRoot,
|
|
1623
|
+
escapeCharacters: exports.escapeCharacters,
|
|
1624
|
+
removeParenthesis: exports.removeParenthesis,
|
|
1625
|
+
checkBlockedAttributes: exports.checkBlockedAttributes,
|
|
1626
|
+
getRelationship: exports.getRelationship,
|
|
1627
|
+
findMatchingParenthesis: exports.findMatchingParenthesis,
|
|
1628
|
+
deleteGarbageFromInnerText,
|
|
1629
|
+
replaceTempAttributes: exports.replaceTempAttributes,
|
|
1630
|
+
// createObserver,
|
|
1631
|
+
// startObserver,
|
|
1632
|
+
// stopObserver,
|
|
1633
|
+
modifiedElementAttributes: exports.modifiedElementAttributes,
|
|
1634
|
+
cspEnabled: exports.cspEnabled,
|
|
1635
|
+
getNormalizedPropertyXPath: exports.getNormalizedPropertyXPath,
|
|
1636
|
+
getStartsWithPropertyXPath: exports.getStartsWithPropertyXPath,
|
|
1637
|
+
getContainsPropertyXPath: exports.getContainsPropertyXPath,
|
|
1638
|
+
getOrAttributesXPath: exports.getOrAttributesXPath,
|
|
1639
|
+
getTagOnlyXPath: exports.getTagOnlyXPath,
|
|
1640
|
+
getFirstMatchedNode: exports.getFirstMatchedNode,
|
|
1641
|
+
isExactUniqueXpath: exports.isExactUniqueXpath,
|
|
1642
|
+
getAxisNodeTest: exports.getAxisNodeTest,
|
|
1643
|
+
getUniqueNodeAnchorXpaths: exports.getUniqueNodeAnchorXpaths,
|
|
1644
|
+
escapeAttrValue,
|
|
1645
|
+
isUniqueInDOM,
|
|
1646
|
+
sanitizeAttributeValue: exports.sanitizeAttributeValue
|
|
1647
|
+
};
|