ff-automationv2 2.2.28 → 2.2.30

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