ff-automationv2 2.2.28 → 2.2.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (519) hide show
  1. package/dist/ai/llmcalls/llmAction.d.ts +9 -4
  2. package/dist/ai/llmcalls/llmAction.js +173 -37
  3. package/dist/ai/llmcalls/parseLlmOputput.js +18 -6
  4. package/dist/ai/llmprompts/promptRegistry.js +11 -0
  5. package/dist/ai/llmprompts/systemPrompts/actionExtractorPrompt.js +19 -10
  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 +120 -62
  10. package/dist/ai/llmprompts/systemPrompts/fireflinkElementIndexExtractor_Mob.js +33 -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 +13 -11
  14. package/dist/ai/llmprompts/systemPrompts/userStoryToListPrompt.js +1 -1
  15. package/dist/ai/llmprompts/systemPrompts/verifyActionExtractorPrompt.js +20 -18
  16. package/dist/ai/llmprompts/systemPrompts/verifyActionExtractorPromptMob.js +9 -9
  17. package/dist/ai/llmprompts/systemPrompts/visionPrompt.js +4 -2
  18. package/dist/ai/llmprompts/systemPrompts/visionPromptMobile.js +1 -0
  19. package/dist/ai/llmprompts/systemPrompts/waitActionExtractorPrompt.js +10 -9
  20. package/dist/ai/llmprompts/systemPrompts/waitActionExtractorPromptMob.js +8 -7
  21. package/dist/ai/llmprompts/userPrompts/userPrompt.js +7 -8
  22. package/dist/automation/actions/executor.d.ts +38 -34
  23. package/dist/automation/actions/executor.js +280 -166
  24. package/dist/automation/actions/interaction/alert/clickCancelOnAlertPopup.js +4 -4
  25. package/dist/automation/actions/interaction/alert/clickOkOnAlertPopup.js +4 -4
  26. package/dist/automation/actions/interaction/alert/enterDataToAlert.js +4 -3
  27. package/dist/automation/actions/interaction/alert/getTextPresentOnAlertPopup.js +4 -4
  28. package/dist/automation/actions/interaction/alert/verifyAlertPopUpMessageContainsString.js +4 -3
  29. package/dist/automation/actions/interaction/alert/verifyAlertPopupIsDisplayed.js +10 -4
  30. package/dist/automation/actions/interaction/alert/verifyTextPresentOnAlertPopup.js +4 -3
  31. package/dist/automation/actions/interaction/alert/waitTillAlertIsPresent.js +5 -5
  32. package/dist/automation/actions/interaction/clear/clear.js +33 -26
  33. package/dist/automation/actions/interaction/clear/clearAndEnter.js +33 -26
  34. package/dist/automation/actions/interaction/click/MOB_DoubleTapAtSpecifiedLocation.js +5 -6
  35. package/dist/automation/actions/interaction/click/click.js +57 -25
  36. package/dist/automation/actions/interaction/click/clickNtimes.js +29 -24
  37. package/dist/automation/actions/interaction/click/clickUsingJs.js +12 -12
  38. package/dist/automation/actions/interaction/click/doubleClick.js +32 -25
  39. package/dist/automation/actions/interaction/click/rightClick.js +18 -13
  40. package/dist/automation/actions/interaction/click/tapOnSpecifiedLocation.js +7 -5
  41. package/dist/automation/actions/interaction/click/waitAndClick.js +29 -27
  42. package/dist/automation/actions/interaction/dragAndDrop/dragAndDrop.js +2 -2
  43. package/dist/automation/actions/interaction/elementLessAction/MobCheckIfAppIsClosed.js +14 -9
  44. package/dist/automation/actions/interaction/elementLessAction/MobRunAppInBackgroundInterface.js +9 -9
  45. package/dist/automation/actions/interaction/elementlessActions/activateAppUsingAppPackage.d.ts +0 -3
  46. package/dist/automation/actions/interaction/elementlessActions/activateAppUsingAppPackage.js +8 -9
  47. package/dist/automation/actions/interaction/elementlessActions/installAPK.js +74 -33
  48. package/dist/automation/actions/interaction/elementlessActions/isAppInstalled.js +10 -8
  49. package/dist/automation/actions/interaction/elementlessActions/openAppWithApkFilePath.js +87 -68
  50. package/dist/automation/actions/interaction/elementlessActions/openMobileApplication.js +8 -6
  51. package/dist/automation/actions/interaction/elementlessActions/receiveMessageOnEmulator.js +4 -3
  52. package/dist/automation/actions/interaction/elementlessActions/terminateAppUsingAppPackage.js +8 -6
  53. package/dist/automation/actions/interaction/elementlessActions/uninstallAPK.js +76 -32
  54. package/dist/automation/actions/interaction/enterActions/EnterInputIntoElementFromClipBoardInterface_mob.js +17 -13
  55. package/dist/automation/actions/interaction/enterActions/enterInput.js +50 -30
  56. package/dist/automation/actions/interaction/enterActions/enterInputAndPress.js +32 -24
  57. package/dist/automation/actions/interaction/enterActions/enterUrl.js +22 -17
  58. package/dist/automation/actions/interaction/enterActions/enterusingJs.js +19 -13
  59. package/dist/automation/actions/interaction/enterActions/waitAndEnter.js +33 -26
  60. package/dist/automation/actions/interaction/find/MOB_FindElement.js +37 -21
  61. package/dist/automation/actions/interaction/find/findElements.js +49 -32
  62. package/dist/automation/actions/interaction/get/MOB_GetADBLogsForGivenAppPackage.js +5 -6
  63. package/dist/automation/actions/interaction/get/MOB_GetAllContexts.js +4 -6
  64. package/dist/automation/actions/interaction/get/MOB_GetAllWindowHandles.js +8 -9
  65. package/dist/automation/actions/interaction/get/MOB_GetAltitude.js +20 -10
  66. package/dist/automation/actions/interaction/get/MOB_GetBatteryPercentage.js +7 -9
  67. package/dist/automation/actions/interaction/get/MOB_GetBatteryStatus.js +4 -6
  68. package/dist/automation/actions/interaction/get/MOB_GetClipBoardText.js +4 -6
  69. package/dist/automation/actions/interaction/get/MOB_GetCurrentActivity.js +4 -6
  70. package/dist/automation/actions/interaction/get/MOB_GetCurrentAppPackage.js +4 -6
  71. package/dist/automation/actions/interaction/get/MOB_GetCurrentContext.js +4 -6
  72. package/dist/automation/actions/interaction/get/MOB_GetCurrentDeviceDate.js +4 -6
  73. package/dist/automation/actions/interaction/get/MOB_GetCurrentDeviceSettings.js +4 -6
  74. package/dist/automation/actions/interaction/get/MOB_GetCurrentDeviceStatus.js +4 -6
  75. package/dist/automation/actions/interaction/get/MOB_GetCurrentDeviceSystemBars.js +5 -6
  76. package/dist/automation/actions/interaction/get/MOB_GetCurrentDeviceTime.js +4 -6
  77. package/dist/automation/actions/interaction/get/MOB_GetCurrentOrientation.js +4 -6
  78. package/dist/automation/actions/interaction/get/MOB_GetCurrentSessionId.js +4 -6
  79. package/dist/automation/actions/interaction/get/MOB_GetDeviceLocation.js +20 -9
  80. package/dist/automation/actions/interaction/get/MOB_GetDeviceName.js +7 -8
  81. package/dist/automation/actions/interaction/get/MOB_GetDeviceOsVersion.js +4 -6
  82. package/dist/automation/actions/interaction/get/MOB_GetDeviceUdid.js +7 -8
  83. package/dist/automation/actions/interaction/get/MOB_GetHeightOfElement.js +12 -11
  84. package/dist/automation/actions/interaction/get/MOB_GetHeightOfScreen.js +4 -6
  85. package/dist/automation/actions/interaction/get/MOB_GetHourFromCurrentDeviceTime.js +4 -6
  86. package/dist/automation/actions/interaction/get/MOB_GetLatitude.js +20 -12
  87. package/dist/automation/actions/interaction/get/MOB_GetLongitude.js +20 -12
  88. package/dist/automation/actions/interaction/get/MOB_GetMinuteFromCurrentDeviceTime.js +4 -6
  89. package/dist/automation/actions/interaction/get/MOB_GetSecondFromCurrentDeviceTime.js +4 -6
  90. package/dist/automation/actions/interaction/get/MOB_GetSizeOfScreen.js +4 -6
  91. package/dist/automation/actions/interaction/get/MOB_GetSupportedPerformanceDataTypes.js +4 -6
  92. package/dist/automation/actions/interaction/get/MOB_GetTextFromElementAndSetToClipBoard.js +11 -8
  93. package/dist/automation/actions/interaction/get/MOB_GetWidthOfElement.js +12 -11
  94. package/dist/automation/actions/interaction/get/MOB_GetWidthOfScreen.js +4 -6
  95. package/dist/automation/actions/interaction/get/browserWindowGetPosition.js +4 -4
  96. package/dist/automation/actions/interaction/get/getAllBrokenImages.js +4 -4
  97. package/dist/automation/actions/interaction/get/getAllBrokenLinkCount.js +4 -4
  98. package/dist/automation/actions/interaction/get/getAllBrokenLinks.js +5 -5
  99. package/dist/automation/actions/interaction/get/getAllConsoleErrors.js +4 -4
  100. package/dist/automation/actions/interaction/get/getAllConsoleInformation.js +5 -5
  101. package/dist/automation/actions/interaction/get/getAllConsoleLogs.js +5 -5
  102. package/dist/automation/actions/interaction/get/getAllConsoleWarnings.js +5 -5
  103. package/dist/automation/actions/interaction/get/getAllCookieNames.js +5 -5
  104. package/dist/automation/actions/interaction/get/getAllCookieValues.js +5 -5
  105. package/dist/automation/actions/interaction/get/getAllSelectedOptions.js +12 -12
  106. package/dist/automation/actions/interaction/get/getAllTheOptionsFromListBoxAsText.js +12 -12
  107. package/dist/automation/actions/interaction/get/getAllTheOptionsFromListBoxAsTextInSortedOrder.js +12 -12
  108. package/dist/automation/actions/interaction/get/getAllTheSelectedOptionsFromListBoxAsText.js +12 -12
  109. package/dist/automation/actions/interaction/get/getAllWindowHandles.js +5 -5
  110. package/dist/automation/actions/interaction/get/getAttribute.js +27 -25
  111. package/dist/automation/actions/interaction/get/getAudioCurrentPlaybackRate.js +12 -12
  112. package/dist/automation/actions/interaction/get/getAudioCurrentSeekTime.js +12 -12
  113. package/dist/automation/actions/interaction/get/getAudioCurrentVolume.js +12 -12
  114. package/dist/automation/actions/interaction/get/getAudioDecodedByte.js +12 -12
  115. package/dist/automation/actions/interaction/get/getAudioDefaultPlaybackRate.js +12 -12
  116. package/dist/automation/actions/interaction/get/getAudioMediaLength.js +12 -12
  117. package/dist/automation/actions/interaction/get/getAudioMediaSource.js +12 -12
  118. package/dist/automation/actions/interaction/get/getBestPracticesScore.js +4 -3
  119. package/dist/automation/actions/interaction/get/getBrowserCount.js +4 -4
  120. package/dist/automation/actions/interaction/get/getBrowserVersion.js +4 -4
  121. package/dist/automation/actions/interaction/get/getCapabilityNames.js +4 -4
  122. package/dist/automation/actions/interaction/get/getClipBoardText.js +4 -4
  123. package/dist/automation/actions/interaction/get/getCollectiveApiResponseTime.js +5 -4
  124. package/dist/automation/actions/interaction/get/getCollectiveApiStatusCode.js +5 -4
  125. package/dist/automation/actions/interaction/get/getCssValue.js +12 -12
  126. package/dist/automation/actions/interaction/get/getCurrentDayOfTheWeek.js +4 -4
  127. package/dist/automation/actions/interaction/get/getCurrentSecondsFromCurrentSystemTime.js +5 -5
  128. package/dist/automation/actions/interaction/get/getCurrentSystemDate.js +4 -4
  129. package/dist/automation/actions/interaction/get/getCurrentSystemDay.js +5 -5
  130. package/dist/automation/actions/interaction/get/getCurrentSystemMonth.js +5 -5
  131. package/dist/automation/actions/interaction/get/getCurrentSystemTime.js +5 -5
  132. package/dist/automation/actions/interaction/get/getCurrentSystemYear.js +5 -5
  133. package/dist/automation/actions/interaction/get/getCurrentWindowHandle.js +9 -10
  134. package/dist/automation/actions/interaction/get/getDataFromApiRequestHeaderForJsonPath.js +5 -4
  135. package/dist/automation/actions/interaction/get/getDataFromApiResponseForJsonPath.js +5 -4
  136. package/dist/automation/actions/interaction/get/getDateWithGivenFormat.js +5 -4
  137. package/dist/automation/actions/interaction/get/getDriverInstance.js +12 -11
  138. package/dist/automation/actions/interaction/get/getFirstContentfulPaint.js +5 -5
  139. package/dist/automation/actions/interaction/get/getFirstSelectedOption.js +12 -12
  140. package/dist/automation/actions/interaction/get/getFullPaintTime.js +5 -5
  141. package/dist/automation/actions/interaction/get/getHTMLCodeOfPage.js +4 -4
  142. package/dist/automation/actions/interaction/get/getHeightOfBrowserWindow.js +4 -4
  143. package/dist/automation/actions/interaction/get/getHeightOfWebElement.js +12 -12
  144. package/dist/automation/actions/interaction/get/getHourFromCurrentSystemTime.js +4 -4
  145. package/dist/automation/actions/interaction/get/getImplicitTimeOut.js +11 -10
  146. package/dist/automation/actions/interaction/get/getLargestContentfulPaint.js +4 -4
  147. package/dist/automation/actions/interaction/get/getListBoxSize.js +12 -12
  148. package/dist/automation/actions/interaction/get/getListOfElementsFromLocatorTypeLocatorValue.js +90 -44
  149. package/dist/automation/actions/interaction/get/getLocation.js +32 -31
  150. package/dist/automation/actions/interaction/get/getMinuteFromCurrentSystemTime.js +4 -4
  151. package/dist/automation/actions/interaction/get/getNetworkRouteTime.js +4 -4
  152. package/dist/automation/actions/interaction/get/getNumberOfBrokenImages.js +4 -4
  153. package/dist/automation/actions/interaction/get/getNumberOfLinksPresentInCurrentPage.js +4 -4
  154. package/dist/automation/actions/interaction/get/getNumberOfWorkingLinksFromCurrentPage.js +4 -4
  155. package/dist/automation/actions/interaction/get/getOptions.js +12 -12
  156. package/dist/automation/actions/interaction/get/getPageTitle.js +5 -5
  157. package/dist/automation/actions/interaction/get/getPerformanceMetrics.js +5 -5
  158. package/dist/automation/actions/interaction/get/getPwaScore.js +5 -4
  159. package/dist/automation/actions/interaction/get/getRect.js +26 -23
  160. package/dist/automation/actions/interaction/get/getScreenshot.js +12 -18
  161. package/dist/automation/actions/interaction/get/getScreenshotAs.js +27 -32
  162. package/dist/automation/actions/interaction/get/getSeoScore.js +5 -4
  163. package/dist/automation/actions/interaction/get/getSingleApiRequestPayload.js +7 -6
  164. package/dist/automation/actions/interaction/get/getSingleApiResponse.js +12 -14
  165. package/dist/automation/actions/interaction/get/getSingleApiResponseTime.js +13 -13
  166. package/dist/automation/actions/interaction/get/getSingleApiStatusCode.d.ts +1 -1
  167. package/dist/automation/actions/interaction/get/getSingleApiStatusCode.js +21 -17
  168. package/dist/automation/actions/interaction/get/getSize.js +26 -24
  169. package/dist/automation/actions/interaction/get/getSizeOfBrowserWindow.js +5 -5
  170. package/dist/automation/actions/interaction/get/getStringDataFromLocalFile.js +11 -13
  171. package/dist/automation/actions/interaction/get/getSystemProperty.js +7 -33
  172. package/dist/automation/actions/interaction/get/getTagName.js +26 -24
  173. package/dist/automation/actions/interaction/get/getText.js +28 -25
  174. package/dist/automation/actions/interaction/get/getTheFirstSelectedOptionFromListBoxAsText.js +12 -12
  175. package/dist/automation/actions/interaction/get/getTotalNumberOfCookies.js +5 -5
  176. package/dist/automation/actions/interaction/get/getTunnelIdentifier.js +5 -4
  177. package/dist/automation/actions/interaction/get/getURLPresentInAddressBar.js +5 -5
  178. package/dist/automation/actions/interaction/get/getUserHomeDirectory.js +5 -5
  179. package/dist/automation/actions/interaction/get/getValueByCookieName.js +7 -11
  180. package/dist/automation/actions/interaction/get/getValueFromLocalStorage.js +7 -10
  181. package/dist/automation/actions/interaction/get/getValueOfSystemVariable.js +8 -6
  182. package/dist/automation/actions/interaction/get/getVideoCurrentPlaybackRate.js +12 -12
  183. package/dist/automation/actions/interaction/get/getVideoCurrentSeekTime.js +12 -12
  184. package/dist/automation/actions/interaction/get/getVideoCurrentVolume.js +12 -12
  185. package/dist/automation/actions/interaction/get/getVideoDecodedByte.js +12 -12
  186. package/dist/automation/actions/interaction/get/getVideoDefaultPlaybackRate.js +12 -12
  187. package/dist/automation/actions/interaction/get/getVideoMediaLength.js +12 -12
  188. package/dist/automation/actions/interaction/get/getVideoMediaSource.js +12 -12
  189. package/dist/automation/actions/interaction/get/getWidthOfBrowser.js +5 -5
  190. package/dist/automation/actions/interaction/get/getWidthOfWebElement.js +12 -12
  191. package/dist/automation/actions/interaction/get/getWorkingLinksFromCurrentPage.js +5 -5
  192. package/dist/automation/actions/interaction/get/getWrappedElement.js +12 -12
  193. package/dist/automation/actions/interaction/get/getWrappedOptionFromListBoxAsText.js +14 -14
  194. package/dist/automation/actions/interaction/get/getXLocationOfBrowserWindow.js +5 -4
  195. package/dist/automation/actions/interaction/get/getXLocationOfWebElement.js +26 -24
  196. package/dist/automation/actions/interaction/get/getYLocationOfBrowserWindow.js +5 -5
  197. package/dist/automation/actions/interaction/get/getYLocationOfWebElement.js +26 -24
  198. package/dist/automation/actions/interaction/iframe/switchToDefaultContent.js +5 -5
  199. package/dist/automation/actions/interaction/inputlessActions/AirplaneModeSwitchOff.js +5 -5
  200. package/dist/automation/actions/interaction/inputlessActions/AirplaneModeSwitchOn.js +5 -5
  201. package/dist/automation/actions/interaction/inputlessActions/Break.js +5 -5
  202. package/dist/automation/actions/interaction/inputlessActions/Continue.js +5 -5
  203. package/dist/automation/actions/interaction/inputlessActions/GpsSwitchOff.js +5 -5
  204. package/dist/automation/actions/interaction/inputlessActions/GpsSwitchOn.js +5 -5
  205. package/dist/automation/actions/interaction/inputlessActions/HideKeyboard.js +13 -7
  206. package/dist/automation/actions/interaction/inputlessActions/LockDevice.js +5 -5
  207. package/dist/automation/actions/interaction/inputlessActions/OpenChromeBrowser.js +18 -6
  208. package/dist/automation/actions/interaction/inputlessActions/OpenNotification.js +5 -5
  209. package/dist/automation/actions/interaction/inputlessActions/ResetApp.js +14 -7
  210. package/dist/automation/actions/interaction/inputlessActions/RestartCurrentDevice.js +5 -5
  211. package/dist/automation/actions/interaction/inputlessActions/SetDeviceOrientationAsLandscape.js +5 -5
  212. package/dist/automation/actions/interaction/inputlessActions/SetDeviceOrientationAsPortrait.js +5 -5
  213. package/dist/automation/actions/interaction/inputlessActions/SetEmulatorPowerStateOff.js +5 -5
  214. package/dist/automation/actions/interaction/inputlessActions/SetEmulatorPowerStateOn.js +5 -5
  215. package/dist/automation/actions/interaction/inputlessActions/WifiSwitchOff.js +5 -5
  216. package/dist/automation/actions/interaction/inputlessActions/WifiSwitchOn.js +5 -5
  217. package/dist/automation/actions/interaction/maximize/maximize.js +5 -5
  218. package/dist/automation/actions/interaction/maximize/minimize.js +5 -5
  219. package/dist/automation/actions/interaction/mouse/mouseClickOnCurrentCursorNTImes.d.ts +2 -0
  220. package/dist/automation/actions/interaction/mouse/mouseClickOnCurrentCursorNTImes.js +31 -0
  221. package/dist/automation/actions/interaction/mouse/mouseClickOnCurrentCursorPoint.d.ts +2 -0
  222. package/dist/automation/actions/interaction/mouse/mouseClickOnCurrentCursorPoint.js +27 -0
  223. package/dist/automation/actions/interaction/mouse/mouseDoubleClickAtCursorPoint.d.ts +2 -0
  224. package/dist/automation/actions/interaction/mouse/mouseDoubleClickAtCursorPoint.js +31 -0
  225. package/dist/automation/actions/interaction/mouse/mouseHover.d.ts +2 -0
  226. package/dist/automation/actions/interaction/mouse/mouseHover.js +36 -0
  227. package/dist/automation/actions/interaction/mouse/mouseReleaseLeftMouseButton.d.ts +2 -0
  228. package/dist/automation/actions/interaction/mouse/mouseReleaseLeftMouseButton.js +42 -0
  229. package/dist/automation/actions/interaction/mouse/pressAndHold.d.ts +2 -0
  230. package/dist/automation/actions/interaction/mouse/pressAndHold.js +47 -0
  231. package/dist/automation/actions/interaction/navigation/goBack.js +5 -5
  232. package/dist/automation/actions/interaction/navigation/navigate.js +5 -4
  233. package/dist/automation/actions/interaction/navigation/refresh.js +5 -5
  234. package/dist/automation/actions/interaction/pinch/PinchInByPercentMob.js +12 -13
  235. package/dist/automation/actions/interaction/pinch/PinchOutByPercentMob.js +12 -11
  236. package/dist/automation/actions/interaction/press/longPress.js +15 -11
  237. package/dist/automation/actions/interaction/press/mobPressBackKey.js +4 -6
  238. package/dist/automation/actions/interaction/press/mobPressBackSpaceKey.js +12 -8
  239. package/dist/automation/actions/interaction/press/mobPressSpaceKey.js +12 -8
  240. package/dist/automation/actions/interaction/press/pressAnyKey.js +25 -16
  241. package/dist/automation/actions/interaction/press/pressAnyKeyNTimes.js +23 -14
  242. package/dist/automation/actions/interaction/press/pressEnterKey.js +21 -14
  243. package/dist/automation/actions/interaction/press/pressHomeKey.js +16 -9
  244. package/dist/automation/actions/interaction/scroll/scrollHorizontallyTillElementIsVisible.js +20 -15
  245. package/dist/automation/actions/interaction/scroll/scrollPageToSpecificLocation.js +8 -7
  246. package/dist/automation/actions/interaction/scroll/scrollToElement.js +18 -13
  247. package/dist/automation/actions/interaction/scroll/scrollVerticallyTillElementIsVisible.js +20 -15
  248. package/dist/automation/actions/interaction/set/MOB_SetContext.js +5 -6
  249. package/dist/automation/actions/interaction/set/MOB_SetEmulatorPowerPercentage.js +5 -6
  250. package/dist/automation/actions/interaction/set/setClipBoardText.js +13 -13
  251. package/dist/automation/actions/interaction/shadowDom/shadowDomClick.js +5 -4
  252. package/dist/automation/actions/interaction/shadowDom/shadowDomEnter.js +5 -4
  253. package/dist/automation/actions/interaction/shadowDom/shadowDomGetText.js +6 -5
  254. package/dist/automation/actions/interaction/shadowDom/shadowDomUpload.js +13 -9
  255. package/dist/automation/actions/interaction/shadowDom/shadowDomVerifyPartialText.js +6 -5
  256. package/dist/automation/actions/interaction/shadowDom/shadowDomVerifyText.js +6 -5
  257. package/dist/automation/actions/interaction/swipe/swipeDirectionNTimes.js +12 -10
  258. package/dist/automation/actions/interaction/swipe/swipeDownToElement.js +13 -10
  259. package/dist/automation/actions/interaction/swipe/swipeIos.d.ts +2 -0
  260. package/dist/automation/actions/interaction/swipe/swipeIos.js +52 -0
  261. package/dist/automation/actions/interaction/swipe/swipeLeftToElement.js +16 -11
  262. package/dist/automation/actions/interaction/swipe/swipeRightToElement.js +15 -10
  263. package/dist/automation/actions/interaction/swipe/swipeUpToElement.js +12 -10
  264. package/dist/automation/actions/interaction/swipe/swipeUpToElementForMWeb.js +16 -13
  265. package/dist/automation/actions/interaction/swipe/swipeUsingReferenceElement.js +19 -16
  266. package/dist/automation/actions/interaction/switch/switchToNewTabBasedOnTitle.js +7 -6
  267. package/dist/automation/actions/interaction/switch/switchToNewWindowBasedOnTitle.js +6 -5
  268. package/dist/automation/actions/interaction/switch/switchToParentWindow.js +6 -6
  269. package/dist/automation/actions/interaction/switch/switchToTabBasedOnUrl.js +6 -5
  270. package/dist/automation/actions/interaction/switch/switchToWindowBasedOnURL.js +5 -4
  271. package/dist/automation/actions/interaction/switch/switchToWindowIfTitleContainsString.js +7 -6
  272. package/dist/automation/actions/interaction/switch/switchToWindowIfUrlContainsString.js +6 -5
  273. package/dist/automation/actions/interaction/upload/uploadfile.js +21 -18
  274. package/dist/automation/actions/interaction/verify/MOB_VerifyBatteryLevel.js +8 -8
  275. package/dist/automation/actions/interaction/verify/MOB_VerifyIfAirplaneModeOff.js +7 -7
  276. package/dist/automation/actions/interaction/verify/MOB_VerifyIfAirplaneModeOn.js +7 -7
  277. package/dist/automation/actions/interaction/verify/MOB_VerifyIfAppIsClosed.js +19 -10
  278. package/dist/automation/actions/interaction/verify/MOB_VerifyIfDeviceIsLocked.js +7 -6
  279. package/dist/automation/actions/interaction/verify/MOB_VerifyIfDeviceIsUnlocked.js +7 -7
  280. package/dist/automation/actions/interaction/verify/MOB_VerifyIfGpsOff.js +12 -8
  281. package/dist/automation/actions/interaction/verify/MOB_VerifyIfGpsOn.js +12 -8
  282. package/dist/automation/actions/interaction/verify/MOB_VerifyIfKeyboardIsHidden.js +7 -7
  283. package/dist/automation/actions/interaction/verify/MOB_VerifyIfKeyboardIsShown.js +8 -7
  284. package/dist/automation/actions/interaction/verify/MOB_VerifyIfWifiOff.js +8 -7
  285. package/dist/automation/actions/interaction/verify/MOB_VerifyIfWifiOn.js +8 -7
  286. package/dist/automation/actions/interaction/verify/VerifyAccessibilityScore.js +8 -7
  287. package/dist/automation/actions/interaction/verify/VerifyAllBrokenImages.js +6 -6
  288. package/dist/automation/actions/interaction/verify/VerifyAllBrowserWindowsClosed.js +12 -10
  289. package/dist/automation/actions/interaction/verify/VerifyAllOptionsAreDeSelected.js +19 -19
  290. package/dist/automation/actions/interaction/verify/VerifyAllOptionsAreSelected.js +12 -12
  291. package/dist/automation/actions/interaction/verify/VerifyAttributeValue.js +35 -53
  292. package/dist/automation/actions/interaction/verify/VerifyBestPracticesScore.js +6 -5
  293. package/dist/automation/actions/interaction/verify/VerifyBrowserHtmlCodeContainsString.js +6 -5
  294. package/dist/automation/actions/interaction/verify/VerifyBrowserWindowHeight.js +7 -6
  295. package/dist/automation/actions/interaction/verify/VerifyBrowserWindowTitleContainsString.js +7 -6
  296. package/dist/automation/actions/interaction/verify/VerifyBrowserWindowTitleIsString.js +7 -6
  297. package/dist/automation/actions/interaction/verify/VerifyBrowserWindowUrlContainsExpectedUrl.js +6 -5
  298. package/dist/automation/actions/interaction/verify/VerifyBrowserWindowUrlIsString.js +5 -4
  299. package/dist/automation/actions/interaction/verify/VerifyBrowserWindowWidth.js +6 -5
  300. package/dist/automation/actions/interaction/verify/VerifyBrowserWindowXLocation.js +6 -5
  301. package/dist/automation/actions/interaction/verify/VerifyBrowserWindowYLocation.js +7 -6
  302. package/dist/automation/actions/interaction/verify/VerifyCheckBoxIsNotSelected.js +12 -12
  303. package/dist/automation/actions/interaction/verify/VerifyCheckBoxIsSelected.js +12 -12
  304. package/dist/automation/actions/interaction/verify/VerifyCssAttributeValue.js +20 -14
  305. package/dist/automation/actions/interaction/verify/VerifyElementIsClickable.js +28 -25
  306. package/dist/automation/actions/interaction/verify/VerifyElementIsDisabled.js +29 -27
  307. package/dist/automation/actions/interaction/verify/VerifyElementIsDisplayed.js +26 -24
  308. package/dist/automation/actions/interaction/verify/VerifyElementIsEnabled.js +26 -24
  309. package/dist/automation/actions/interaction/verify/VerifyElementIsEnabledInSpecifiedTime.d.ts +2 -0
  310. package/dist/automation/actions/interaction/verify/VerifyElementIsEnabledInSpecifiedTime.js +84 -0
  311. package/dist/automation/actions/interaction/verify/VerifyElementIsNotDisplayed.js +51 -28
  312. package/dist/automation/actions/interaction/verify/VerifyElementIsSelected.js +39 -27
  313. package/dist/automation/actions/interaction/verify/VerifyElementIsSelectedInSpecifiedTime.d.ts +2 -0
  314. package/dist/automation/actions/interaction/verify/VerifyElementIsSelectedInSpecifiedTime.js +83 -0
  315. package/dist/automation/actions/interaction/verify/VerifyElementNotContainsText.js +23 -23
  316. package/dist/automation/actions/interaction/verify/VerifyHeightOfWebElement.js +23 -23
  317. package/dist/automation/actions/interaction/verify/VerifyHexCodeForGivenXYCoordinates.js +44 -14
  318. package/dist/automation/actions/interaction/verify/VerifyIfAllCookiesAreDeleted.js +4 -4
  319. package/dist/automation/actions/interaction/verify/VerifyIfAudioEnded.js +12 -12
  320. package/dist/automation/actions/interaction/verify/VerifyIfAudioIsMuted.js +12 -12
  321. package/dist/automation/actions/interaction/verify/VerifyIfAudioIsPaused.js +12 -12
  322. package/dist/automation/actions/interaction/verify/VerifyIfAudioIsPlaying.js +12 -12
  323. package/dist/automation/actions/interaction/verify/VerifyIfBrowserWindowIsClosed.js +8 -9
  324. package/dist/automation/actions/interaction/verify/VerifyIfCookieNameIsAdded.js +6 -5
  325. package/dist/automation/actions/interaction/verify/VerifyIfCookieNameIsDeleted.js +5 -4
  326. package/dist/automation/actions/interaction/verify/VerifyIfCookieObjectIsPresent.js +5 -5
  327. package/dist/automation/actions/interaction/verify/VerifyIfGivenOptionIsDuplicate.js +14 -14
  328. package/dist/automation/actions/interaction/verify/VerifyIfImageIsBroken.js +6 -5
  329. package/dist/automation/actions/interaction/verify/VerifyIfLinkIsBroken.js +6 -5
  330. package/dist/automation/actions/interaction/verify/VerifyIfLinkIsWorking.js +6 -5
  331. package/dist/automation/actions/interaction/verify/VerifyIfLinksAreBroken.js +5 -4
  332. package/dist/automation/actions/interaction/verify/VerifyIfLinksAreWorking.js +5 -4
  333. package/dist/automation/actions/interaction/verify/VerifyIfOptionWithIndexIsDeselectedInElement.js +13 -13
  334. package/dist/automation/actions/interaction/verify/VerifyIfOptionWithIndexIsSelectedInListBox.js +13 -13
  335. package/dist/automation/actions/interaction/verify/VerifyIfOptionWithTextIsDeselected.js +12 -12
  336. package/dist/automation/actions/interaction/verify/VerifyIfOptionWithValueIsDeselected.js +12 -12
  337. package/dist/automation/actions/interaction/verify/VerifyIfOptionWithValueIsSelected.js +12 -12
  338. package/dist/automation/actions/interaction/verify/VerifyIfOptionWithVisibleTextIsSelected.js +12 -12
  339. package/dist/automation/actions/interaction/verify/VerifyIfSpecifiedOptionIsSelected.js +12 -12
  340. package/dist/automation/actions/interaction/verify/VerifyIfStatusCodeOfALinkIsStatusCode.js +7 -6
  341. package/dist/automation/actions/interaction/verify/VerifyIfStatusCodesOfLinks.js +30 -22
  342. package/dist/automation/actions/interaction/verify/VerifyIfVideoEnded.js +12 -12
  343. package/dist/automation/actions/interaction/verify/VerifyIfVideoIsMuted.js +12 -12
  344. package/dist/automation/actions/interaction/verify/VerifyIfVideoIsPaused.js +12 -12
  345. package/dist/automation/actions/interaction/verify/VerifyIfVideoIsPlaying.js +12 -12
  346. package/dist/automation/actions/interaction/verify/VerifyIfVideoPlayingInMute.js +12 -12
  347. package/dist/automation/actions/interaction/verify/VerifyIfVideoPlayingInUnmute.js +12 -12
  348. package/dist/automation/actions/interaction/verify/VerifyIfXAndYCoordinateOfElement.js +25 -23
  349. package/dist/automation/actions/interaction/verify/VerifyLinkNavigatesToTitle.js +7 -6
  350. package/dist/automation/actions/interaction/verify/VerifyListBoxOptionsAreSorted.js +12 -12
  351. package/dist/automation/actions/interaction/verify/VerifyNavigateURL.js +6 -5
  352. package/dist/automation/actions/interaction/verify/VerifyNumberOfElementsByTagName.js +7 -5
  353. package/dist/automation/actions/interaction/verify/VerifyNumberOfElementsByXpath.js +13 -7
  354. package/dist/automation/actions/interaction/verify/VerifyPartialAttributeValue.js +33 -42
  355. package/dist/automation/actions/interaction/verify/VerifyPartialTitleOfCurrentPage.js +7 -6
  356. package/dist/automation/actions/interaction/verify/VerifyPerformanceScore.js +7 -6
  357. package/dist/automation/actions/interaction/verify/VerifyPwaScore.js +6 -5
  358. package/dist/automation/actions/interaction/verify/VerifyRadioButtonIsNotSelected.js +12 -12
  359. package/dist/automation/actions/interaction/verify/VerifyRadioButtonIsSelected.js +12 -12
  360. package/dist/automation/actions/interaction/verify/VerifySeoScore.js +6 -5
  361. package/dist/automation/actions/interaction/verify/VerifyTagName.js +12 -12
  362. package/dist/automation/actions/interaction/verify/VerifyThatSpecifiedOptionIsNotSelected.js +20 -31
  363. package/dist/automation/actions/interaction/verify/VerifyTitleInAllPage.js +8 -7
  364. package/dist/automation/actions/interaction/verify/VerifyTitleOfCurrentPage.js +6 -5
  365. package/dist/automation/actions/interaction/verify/VerifyValueOfElementContainsString.js +12 -12
  366. package/dist/automation/actions/interaction/verify/VerifyValueOfElementIsCleared.js +12 -12
  367. package/dist/automation/actions/interaction/verify/VerifyValueOfElementIsString.js +12 -12
  368. package/dist/automation/actions/interaction/verify/VerifyWidthOfElement.js +23 -23
  369. package/dist/automation/actions/interaction/verify/VerifyXLocationOfElement.js +23 -23
  370. package/dist/automation/actions/interaction/verify/VerifyYLocationOfElement.js +26 -23
  371. package/dist/automation/actions/interaction/verify/checkIfElementIsDisplayed.js +26 -22
  372. package/dist/automation/actions/interaction/verify/verifyElementIsDisplayedWithinSpecifiedTime.d.ts +2 -0
  373. package/dist/automation/actions/interaction/verify/verifyElementIsDisplayedWithinSpecifiedTime.js +85 -0
  374. package/dist/automation/actions/interaction/verify/verifypartialtext.js +28 -25
  375. package/dist/automation/actions/interaction/verify/verifytext.js +30 -30
  376. package/dist/automation/actions/interaction/wait/MOB_WaitTillAllElementsAreInvisible.ts.js +5 -6
  377. package/dist/automation/actions/interaction/wait/MOB_WaitTillAttributeOfElementContainsString.js +17 -14
  378. package/dist/automation/actions/interaction/wait/MOB_WaitTillElementIsEnabled.js +12 -11
  379. package/dist/automation/actions/interaction/wait/MOB_WaitTillElementIsInvisible.js +14 -12
  380. package/dist/automation/actions/interaction/wait/MOB_WaitTillElementIsSelected.js +12 -11
  381. package/dist/automation/actions/interaction/wait/MOB_WaitTillElementIsVisible.js +15 -13
  382. package/dist/automation/actions/interaction/wait/MOB_WaitTillStalenessOfElement.js +12 -11
  383. package/dist/automation/actions/interaction/wait/wait.js +5 -4
  384. package/dist/automation/actions/interaction/wait/waitTillAttributeOfElementIsString.js +26 -24
  385. package/dist/automation/actions/interaction/wait/waitTillElementContainsText.js +26 -24
  386. package/dist/automation/actions/interaction/wait/waitTillElementHasText.js +26 -24
  387. package/dist/automation/actions/interaction/wait/waitTillElementIsClickable.js +28 -25
  388. package/dist/automation/actions/interaction/wait/waitTillPresenceOfAllElements.js +32 -22
  389. package/dist/automation/actions/interaction/wait/waitTillPresenceOfElement.js +26 -24
  390. package/dist/automation/actions/interface/FireFlinkResponseSchema.d.ts +148 -0
  391. package/dist/automation/actions/interface/FireFlinkResponseSchema.js +209 -0
  392. package/dist/automation/actions/interface/alertActionInterface.d.ts +1 -0
  393. package/dist/automation/actions/interface/findActionInterface.d.ts +3 -0
  394. package/dist/automation/actions/interface/getActionInterface.d.ts +76 -66
  395. package/dist/automation/actions/interface/interactionActionInterface.d.ts +5 -0
  396. package/dist/automation/actions/interface/mouseActionsinterface.d.ts +51 -0
  397. package/dist/automation/actions/interface/mouseActionsinterface.js +2 -0
  398. package/dist/automation/actions/interface/pinchActionInterface.d.ts +7 -0
  399. package/dist/automation/actions/interface/pressActionInterface.d.ts +4 -0
  400. package/dist/automation/actions/interface/swipeActionInterface.d.ts +25 -10
  401. package/dist/automation/actions/interface/verifyActionInterface.d.ts +36 -0
  402. package/dist/automation/actions/interface/waitActionInterface.d.ts +19 -0
  403. package/dist/automation/browserSession/initiateBrowserSession.d.ts +1 -1
  404. package/dist/automation/browserSession/initiateBrowserSession.js +4 -4
  405. package/dist/automation/cloudSession/initiateCloudSession.js +3 -1
  406. package/dist/automation/mobileSession/initiateMobileSession.d.ts +25 -1
  407. package/dist/automation/mobileSession/initiateMobileSession.js +23 -10
  408. package/dist/core/constants/allAction.js +2 -1
  409. package/dist/core/constants/supportedActions.d.ts +1 -0
  410. package/dist/core/constants/supportedActions.js +17 -9
  411. package/dist/core/interfaces/actionInterface.d.ts +34 -33
  412. package/dist/core/interfaces/fireflinkScriptPayloadInterface.d.ts +4 -1
  413. package/dist/core/interfaces/llmConfigurationInterface.d.ts +3 -2
  414. package/dist/core/interfaces/llmResponseInterface.d.ts +10 -10
  415. package/dist/core/interfaces/scriptGenrationDataInterface.d.ts +14 -0
  416. package/dist/core/interfaces/simplifyAndFlattenInterface.d.ts +5 -0
  417. package/dist/core/main/actionHandlerFactory.js +134 -64
  418. package/dist/core/main/executionContext.d.ts +1 -1
  419. package/dist/core/main/executionContext.js +1 -1
  420. package/dist/core/main/runAutomationScript.d.ts +1 -0
  421. package/dist/core/main/runAutomationScript.js +207 -88
  422. package/dist/core/main/stepProcessor.d.ts +2 -1
  423. package/dist/core/main/stepProcessor.js +2 -2
  424. package/dist/core/types/scriptTypesType.d.ts +1 -1
  425. package/dist/core/types/visionllmInputType.d.ts +4 -5
  426. package/dist/domAnalysis/getRelaventElements.d.ts +5 -1
  427. package/dist/domAnalysis/getRelaventElements.js +14 -5
  428. package/dist/domAnalysis/relativeElementsFromDom.d.ts +2 -1
  429. package/dist/domAnalysis/relativeElementsFromDom.js +66 -1
  430. package/dist/domAnalysis/searchBest.d.ts +5 -1
  431. package/dist/domAnalysis/searchBest.js +153 -50
  432. package/dist/domAnalysis/simplifyAndFlatten.d.ts +3 -2
  433. package/dist/domAnalysis/simplifyAndFlatten.js +109 -16
  434. package/dist/fireflinkData/fireflinkLocators/getListOfLocators.js +17 -11
  435. package/dist/fireflinkData/fireflinkLocators/{elementsFromHTML.d.ts → parser/getElementsFromHTML.d.ts} +3 -9
  436. package/dist/fireflinkData/fireflinkLocators/parser/getElementsFromHTML.js +557 -0
  437. package/dist/fireflinkData/fireflinkLocators/types/locator.d.ts +17 -0
  438. package/dist/fireflinkData/fireflinkLocators/types/locator.js +2 -0
  439. package/dist/fireflinkData/fireflinkLocators/utils/androidSelector.d.ts +2 -0
  440. package/dist/fireflinkData/fireflinkLocators/utils/androidSelector.js +31 -0
  441. package/dist/fireflinkData/fireflinkLocators/utils/cssSelector.d.ts +19 -0
  442. package/dist/fireflinkData/fireflinkLocators/utils/cssSelector.js +192 -0
  443. package/dist/fireflinkData/fireflinkLocators/utils/iosSelector.d.ts +2 -0
  444. package/dist/fireflinkData/fireflinkLocators/utils/iosSelector.js +159 -0
  445. package/dist/fireflinkData/fireflinkLocators/utils/referenceXpath.d.ts +35 -0
  446. package/dist/fireflinkData/fireflinkLocators/utils/referenceXpath.js +590 -0
  447. package/dist/fireflinkData/fireflinkLocators/utils/xpath.d.ts +38 -0
  448. package/dist/fireflinkData/fireflinkLocators/utils/xpath.js +1182 -0
  449. package/dist/fireflinkData/fireflinkLocators/utils/xpathHelpers.d.ts +137 -0
  450. package/dist/fireflinkData/fireflinkLocators/utils/xpathHelpers.js +1647 -0
  451. package/dist/fireflinkData/fireflinkScript/appendScriptData.d.ts +2 -0
  452. package/dist/fireflinkData/fireflinkScript/appendScriptData.js +51 -0
  453. package/dist/fireflinkData/fireflinkScript/scriptGenrationData.js +4 -0
  454. package/dist/imageAnalysisMobile/annotatedScreenshotMobile.d.ts +4 -0
  455. package/dist/imageAnalysisMobile/annotatedScreenshotMobile.js +115 -7
  456. package/dist/imageAnalysisWeb/annotateScreenshot.js +4 -4
  457. package/dist/imageAnalysisWeb/generateAnnotatedScreenshots.d.ts +4 -1
  458. package/dist/imageAnalysisWeb/generateAnnotatedScreenshots.js +15 -17
  459. package/dist/llmConfig/llmConfiguration.d.ts +4 -3
  460. package/dist/llmConfig/llmConfiguration.js +41 -18
  461. package/dist/service/fireflink.service.d.ts +1 -1
  462. package/dist/service/fireflink.service.js +4 -4
  463. package/dist/tests/poc.d.ts +0 -1
  464. package/dist/tests/poc.js +211 -226
  465. package/dist/tests/test.d.ts +1 -0
  466. package/dist/tests/test.js +26 -0
  467. package/dist/tests/test12.js +19 -408
  468. package/dist/tests/testss.d.ts +1 -0
  469. package/dist/tests/testss.js +23 -0
  470. package/dist/utils/DomExtraction/jsForAttributeInjection.d.ts +2 -0
  471. package/dist/utils/DomExtraction/jsForAttributeInjection.js +220 -8
  472. package/dist/utils/InstancesDetails/getInstancesInfo.d.ts +26 -1
  473. package/dist/utils/InstancesDetails/getInstancesInfo.js +11 -5
  474. package/dist/utils/browserCap/capability.d.ts +10 -10
  475. package/dist/utils/browserCap/capability.js +21 -16
  476. package/dist/utils/frameWorkDetector/frameWorkDetector.d.ts +6 -0
  477. package/dist/utils/frameWorkDetector/frameWorkDetector.js +43 -0
  478. package/dist/utils/frameWorkDetector/frameWorkDetectorInterface.d.ts +10 -0
  479. package/dist/utils/frameWorkDetector/frameWorkDetectorInterface.js +2 -0
  480. package/dist/utils/helpers/enterActionHelper.d.ts +1 -0
  481. package/dist/utils/helpers/enterActionHelper.js +2 -1
  482. package/dist/utils/helpers/platformContext.d.ts +3 -0
  483. package/dist/utils/helpers/platformContext.js +11 -0
  484. package/dist/utils/helpers/platformSyntax.d.ts +1 -0
  485. package/dist/utils/helpers/platformSyntax.js +17 -0
  486. package/dist/utils/helpers/sameActionsHelper.js +7 -2
  487. package/dist/utils/helpers/xpathcreation.d.ts +5 -1
  488. package/dist/utils/helpers/xpathcreation.js +43 -4
  489. package/dist/utils/iframesExtraction/findElementUsingFF.js +12 -9
  490. package/dist/utils/iframesExtraction/iframeInterface.d.ts +4 -0
  491. package/dist/utils/javascript/jsForShadowRoot.d.ts +1 -1
  492. package/dist/utils/javascript/jsForShadowRoot.js +4 -0
  493. package/dist/utils/javascript/jsForVision.d.ts +2 -2
  494. package/dist/utils/javascript/jsForVision.js +17 -5
  495. package/dist/utils/logger/logData.d.ts +1 -0
  496. package/dist/utils/logger/logData.js +19 -0
  497. package/dist/utils/sslConfig/apiCallPatch.d.ts +1 -0
  498. package/dist/utils/sslConfig/apiCallPatch.js +33 -0
  499. package/dist/utils/sslConfig/getSecureAgent.d.ts +2 -0
  500. package/dist/utils/sslConfig/getSecureAgent.js +30 -0
  501. package/dist/utils/swipe/domSearchHelper.d.ts +1 -1
  502. package/dist/utils/swipe/domSearchHelper.js +43 -42
  503. package/dist/utils/swipe/swipeMovement.js +28 -19
  504. package/package.json +21 -6
  505. package/dist/automation/actions/interaction/get/getAudioDimension.d.ts +0 -2
  506. package/dist/automation/actions/interaction/get/getAudioDimension.js +0 -34
  507. package/dist/automation/actions/interaction/get/getAudioHeight.d.ts +0 -2
  508. package/dist/automation/actions/interaction/get/getAudioHeight.js +0 -30
  509. package/dist/automation/actions/interaction/get/getAudioWidth.d.ts +0 -2
  510. package/dist/automation/actions/interaction/get/getAudioWidth.js +0 -30
  511. package/dist/automation/actions/interaction/get/getVideoDimension.d.ts +0 -2
  512. package/dist/automation/actions/interaction/get/getVideoDimension.js +0 -31
  513. package/dist/automation/actions/interaction/get/getVideoHeight.d.ts +0 -2
  514. package/dist/automation/actions/interaction/get/getVideoHeight.js +0 -28
  515. package/dist/automation/actions/interaction/get/getVideoWidth.d.ts +0 -2
  516. package/dist/automation/actions/interaction/get/getVideoWidth.js +0 -28
  517. package/dist/fireflinkData/fireflinkLocators/elementsFromHTML.js +0 -514
  518. package/dist/fireflinkData/fireflinkLocators/typeList.d.ts +0 -1
  519. package/dist/fireflinkData/fireflinkLocators/typeList.js +0 -33
@@ -0,0 +1,1182 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseDOM = exports.getTextXPath = exports.getUniqueClassName = exports.attributesBasedXPath = exports.generateIndexedXpaths = void 0;
4
+ const logData_js_1 = require("../../../utils/logger/logData.js");
5
+ const xpathHelpers_js_1 = require("./xpathHelpers.js");
6
+ const androidSelector_js_1 = require("./androidSelector.js");
7
+ const iosSelector_js_1 = require("./iosSelector.js");
8
+ let xpathData = [];
9
+ const xpathDataWithIndex = [];
10
+ const referenceElementMode = false;
11
+ const xpathCache = new Map();
12
+ const cache = new Map();
13
+ const parentXpathCache = new Map();
14
+ const STRATEGY_MAP = {
15
+ andConditions: "and",
16
+ orConditions: "or",
17
+ contains: "contains",
18
+ startsWith: "startsWith",
19
+ normalizeSpace: "normalizeSpace",
20
+ axes: "axes",
21
+ index: "index",
22
+ hardCodedText: "text",
23
+ tillTag: "tag"
24
+ };
25
+ const getStrategyName = (strategy) => {
26
+ return STRATEGY_MAP[strategy] || strategy;
27
+ };
28
+ const withStrategyKey = (strategy, entries) => {
29
+ return entries.map((entry) => ({
30
+ ...entry,
31
+ key: entry?.key?.includes(strategy)
32
+ ? entry.key
33
+ : `${strategy} ${entry.key}`.trim()
34
+ }));
35
+ };
36
+ const getUniqueXpathEntries = (entries) => {
37
+ const seen = new Set();
38
+ return entries.filter((entry) => {
39
+ if (!entry?.value || seen.has(entry.value)) {
40
+ return false;
41
+ }
42
+ seen.add(entry.value);
43
+ return true;
44
+ });
45
+ };
46
+ const getNormalizedText = (element) => {
47
+ return element?.textContent?.replace(/\s+/g, " ")?.trim() || "";
48
+ };
49
+ const buildTextStrategyXpaths = (element, docmt, strategy, platform) => {
50
+ const text = getNormalizedText(element);
51
+ if (!text) {
52
+ return [];
53
+ }
54
+ if (strategy === "text") {
55
+ const textXpath = (0, xpathHelpers_js_1.getFilteredTextXPath)(element) ||
56
+ (0, exports.getTextXPath)(element, docmt, false, false, platform);
57
+ return textXpath ? [{ key: "xpath by text", value: textXpath }] : [];
58
+ }
59
+ return [];
60
+ };
61
+ const buildPropertyStrategyXpaths = (element, isTarget, strategy, platform) => {
62
+ const xpaths = [];
63
+ const attributes = Array.from(element.attributes || []).filter((attribute) => attribute?.value && (0, xpathHelpers_js_1.checkBlockedAttributes)(attribute, element, isTarget));
64
+ const text = getNormalizedText(element);
65
+ const getStrategyXPath = strategy === "contains"
66
+ ? xpathHelpers_js_1.getContainsPropertyXPath
67
+ : strategy === "startsWith"
68
+ ? xpathHelpers_js_1.getStartsWithPropertyXPath
69
+ : strategy === "normalizeSpace"
70
+ ? xpathHelpers_js_1.getNormalizedPropertyXPath
71
+ : null;
72
+ if (!getStrategyXPath) {
73
+ return xpaths;
74
+ }
75
+ attributes.forEach((attribute) => {
76
+ const xpath = getStrategyXPath(element, `@${attribute.name}`, attribute.value, platform);
77
+ if (xpath) {
78
+ xpaths.push({
79
+ key: `xpath by ${strategy} ${attribute.name}`,
80
+ value: xpath
81
+ });
82
+ }
83
+ });
84
+ if (text) {
85
+ const xpath = getStrategyXPath(element, ".", text, platform);
86
+ if (xpath) {
87
+ xpaths.push({
88
+ key: `xpath by ${strategy} text`,
89
+ value: xpath
90
+ });
91
+ }
92
+ }
93
+ return xpaths;
94
+ };
95
+ const buildConditionStrategyXpaths = (element, docmt, isTarget, strategy, platform) => {
96
+ const attributes = Array.from(element.attributes || []).filter((attribute) => attribute?.value && (0, xpathHelpers_js_1.checkBlockedAttributes)(attribute, element, isTarget));
97
+ if (strategy === "and") {
98
+ const combinationXpath = (0, xpathHelpers_js_1.getAttributeCombinationXpath)(element, docmt, attributes, isTarget, platform);
99
+ return combinationXpath
100
+ ? [{ key: "xpath by combination", value: combinationXpath }]
101
+ : [];
102
+ }
103
+ if (strategy === "or" && attributes.length >= 1) {
104
+ const xpath = (0, xpathHelpers_js_1.getOrAttributesXPath)(element, attributes, platform);
105
+ return xpath ? [{ key: "xpath by or", value: xpath }] : [];
106
+ }
107
+ return [];
108
+ };
109
+ const collectSubtreeElements = (root) => {
110
+ const view = root?.ownerDocument?.defaultView;
111
+ if (!root || !view || !(root instanceof view.Element))
112
+ return [];
113
+ const nodes = [];
114
+ const queue = Array.from(root.children || []);
115
+ while (queue.length) {
116
+ const currentNode = queue.shift();
117
+ if (currentNode.classList?.contains("flntooltip")) {
118
+ continue;
119
+ }
120
+ nodes.push(currentNode);
121
+ queue.push(...Array.from(currentNode.children || []));
122
+ }
123
+ return nodes;
124
+ };
125
+ const getSiblingNodes = (element, direction) => {
126
+ const nodes = [];
127
+ let currentNode = direction === "previous"
128
+ ? element.previousElementSibling
129
+ : element.nextElementSibling;
130
+ while (currentNode) {
131
+ if (!currentNode.classList?.contains("flntooltip")) {
132
+ nodes.push(currentNode);
133
+ }
134
+ currentNode =
135
+ direction === "previous"
136
+ ? currentNode.previousElementSibling
137
+ : currentNode.nextElementSibling;
138
+ }
139
+ return nodes;
140
+ };
141
+ const getDirectionalAxisSeedNodes = (element, direction) => {
142
+ const nodes = [];
143
+ for (let currentNode = element; currentNode?.parentElement; currentNode = currentNode.parentElement) {
144
+ let sibling = direction === "previous"
145
+ ? currentNode.previousElementSibling
146
+ : currentNode.nextElementSibling;
147
+ while (sibling) {
148
+ if (!sibling.classList?.contains("flntooltip")) {
149
+ nodes.push(sibling);
150
+ nodes.push({
151
+ node: sibling,
152
+ expand: () => collectSubtreeElements(sibling)
153
+ });
154
+ }
155
+ sibling =
156
+ direction === "previous"
157
+ ? sibling.previousElementSibling
158
+ : sibling.nextElementSibling;
159
+ }
160
+ }
161
+ return nodes;
162
+ };
163
+ const isLowQualityNode = (node) => {
164
+ const view = node?.ownerDocument?.defaultView;
165
+ if (!view || !(node instanceof view.Element))
166
+ return true;
167
+ const text = node.textContent?.trim();
168
+ return (!node.id &&
169
+ !node.className &&
170
+ node.attributes.length === 0 &&
171
+ (!text || text.length > 60) &&
172
+ node.children.length > 2);
173
+ };
174
+ const buildAxisXpathsForNodes = (nodes, axis, targetElement, docmt, isTarget, key, isIndex, platform) => {
175
+ const targetNodeTest = (0, xpathHelpers_js_1.getAxisNodeTest)(targetElement, platform);
176
+ const MAX_INDEX_TRY = 3;
177
+ const MAX_CANDIDATES = 5;
178
+ const candidates = [];
179
+ let processed = 0;
180
+ const MAX_PROCESS = axis.includes("descendant") ? 10 : 20;
181
+ for (const nodeItem of nodes) {
182
+ if (processed++ > MAX_PROCESS)
183
+ break;
184
+ if (candidates.length >= MAX_CANDIDATES)
185
+ break;
186
+ const node = "node" in nodeItem ? nodeItem.node : nodeItem;
187
+ const view = node.ownerDocument?.defaultView;
188
+ if (!view || !(node instanceof view.Element))
189
+ continue;
190
+ if (isLowQualityNode(node))
191
+ continue;
192
+ const anchorStages = [
193
+ () => (0, xpathHelpers_js_1.getUniqueNodeAnchorXpaths)(node, docmt, isTarget, platform),
194
+ () => {
195
+ const anchors = [];
196
+ const element = node;
197
+ const attributes = Array.from(element.attributes || []).filter((attr) => attr.value &&
198
+ !/\d/.test(attr.value) &&
199
+ (0, xpathHelpers_js_1.checkBlockedAttributes)(attr, element, isTarget));
200
+ for (const attr of attributes) {
201
+ const value = attr.value;
202
+ if (!value)
203
+ continue;
204
+ const containsXpath = (0, xpathHelpers_js_1.getContainsPropertyXPath)(node, `@${attr.name}`, value, platform);
205
+ if (containsXpath) {
206
+ anchors.push({ key: "contains", value: containsXpath });
207
+ }
208
+ const startsWithXpath = (0, xpathHelpers_js_1.getStartsWithPropertyXPath)(node, `@${attr.name}`, value, platform);
209
+ if (startsWithXpath) {
210
+ anchors.push({ key: "starts-with", value: startsWithXpath });
211
+ }
212
+ }
213
+ return anchors;
214
+ },
215
+ () => [{ key: "tag", value: (0, xpathHelpers_js_1.getTagOnlyXPath)(node, platform, docmt) }]
216
+ ];
217
+ for (let stageIndex = 0; stageIndex < anchorStages.length; stageIndex++) {
218
+ let anchors = anchorStages[stageIndex]();
219
+ if (!anchors.length)
220
+ continue;
221
+ if (!isIndex) {
222
+ anchors = anchors.filter((a) => !/\[\d+\]/.test(a.value));
223
+ }
224
+ const seen = new Set();
225
+ anchors = anchors.filter((a) => {
226
+ if (seen.has(a.value))
227
+ return false;
228
+ seen.add(a.value);
229
+ return true;
230
+ });
231
+ anchors = anchors.slice(0, 5);
232
+ for (const anchor of anchors) {
233
+ const xpath = `${anchor.value}/${axis}::${targetNodeTest}`;
234
+ if ((0, xpathHelpers_js_1.isExactUniqueXpath)(xpath, targetElement, docmt)) {
235
+ candidates.push({ key, value: xpath });
236
+ if (candidates.length >= 2) {
237
+ return candidates;
238
+ }
239
+ if (candidates.length >= MAX_CANDIDATES) {
240
+ return candidates;
241
+ }
242
+ }
243
+ }
244
+ if (isIndex && stageIndex === anchorStages.length - 1) {
245
+ for (const anchor of anchors) {
246
+ const count = (0, xpathHelpers_js_1.getCountOfXPath)(anchor.value, node, docmt);
247
+ for (let i = 1; i <= Math.min(count, MAX_INDEX_TRY); i++) {
248
+ const xpath = `(${anchor.value})[${i}]/${axis}::${targetNodeTest}`;
249
+ if ((0, xpathHelpers_js_1.isExactUniqueXpath)(xpath, targetElement, docmt)) {
250
+ candidates.push({ key, value: xpath });
251
+ if (candidates.length >= 2) {
252
+ return candidates;
253
+ }
254
+ if (candidates.length >= MAX_CANDIDATES) {
255
+ return candidates;
256
+ }
257
+ }
258
+ }
259
+ }
260
+ }
261
+ }
262
+ if ("expand" in nodeItem && nodeItem.expand) {
263
+ const expanded = nodeItem.expand();
264
+ let childCount = 0;
265
+ for (const child of expanded) {
266
+ if (childCount++ > 15)
267
+ break;
268
+ if (candidates.length >= MAX_CANDIDATES)
269
+ break;
270
+ const view = child.ownerDocument?.defaultView;
271
+ if (!view || !(child instanceof view.Element))
272
+ continue;
273
+ if (isLowQualityNode(child))
274
+ continue;
275
+ const anchors = (0, xpathHelpers_js_1.getUniqueNodeAnchorXpaths)(child, docmt, isTarget, platform);
276
+ for (const anchor of anchors.slice(0, 5)) {
277
+ const xpath = `${anchor.value}/${axis}::${targetNodeTest}`;
278
+ if ((0, xpathHelpers_js_1.isExactUniqueXpath)(xpath, targetElement, docmt)) {
279
+ candidates.push({ key, value: xpath });
280
+ if (candidates.length >= 2) {
281
+ return candidates;
282
+ }
283
+ if (candidates.length >= MAX_CANDIDATES) {
284
+ return candidates;
285
+ }
286
+ }
287
+ }
288
+ }
289
+ }
290
+ }
291
+ return candidates;
292
+ };
293
+ const buildAxesStrategyXpaths = (element, docmt, isTarget, isIndex, platform) => {
294
+ const ancestors = [];
295
+ for (let currentNode = element.parentElement; currentNode; currentNode = currentNode.parentElement) {
296
+ ancestors.push(currentNode);
297
+ }
298
+ const descendants = collectSubtreeElements(element);
299
+ const previousSiblings = getSiblingNodes(element, "previous");
300
+ const nextSiblings = getSiblingNodes(element, "next");
301
+ const precedingSeeds = getDirectionalAxisSeedNodes(element, "previous");
302
+ const followingSeeds = getDirectionalAxisSeedNodes(element, "next");
303
+ const limitNodes = (nodes, limit = 20) => {
304
+ return nodes.length > limit ? nodes.slice(0, limit) : nodes;
305
+ };
306
+ const tiers = [
307
+ [
308
+ {
309
+ nodes: limitNodes(nextSiblings),
310
+ axis: "preceding-sibling",
311
+ key: "preceding-sibling"
312
+ },
313
+ {
314
+ nodes: limitNodes(previousSiblings),
315
+ axis: "following-sibling",
316
+ key: "following-sibling"
317
+ }
318
+ ],
319
+ [
320
+ { nodes: limitNodes(ancestors), axis: "child", key: "child" },
321
+ {
322
+ nodes: limitNodes(descendants, 15),
323
+ axis: "parent",
324
+ key: "parent"
325
+ }
326
+ ],
327
+ [
328
+ { nodes: limitNodes(ancestors), axis: "descendant", key: "descendant" },
329
+ {
330
+ nodes: limitNodes(ancestors),
331
+ axis: "descendant-or-self",
332
+ key: "descendant-or-self"
333
+ },
334
+ {
335
+ nodes: limitNodes(descendants, 10),
336
+ axis: "ancestor",
337
+ key: "ancestor"
338
+ },
339
+ {
340
+ nodes: limitNodes(descendants, 10),
341
+ axis: "ancestor-or-self",
342
+ key: "ancestor-or-self"
343
+ }
344
+ ],
345
+ [
346
+ {
347
+ nodes: limitNodes(precedingSeeds),
348
+ axis: "following",
349
+ key: "following"
350
+ },
351
+ { nodes: limitNodes(followingSeeds), axis: "preceding", key: "preceding" }
352
+ ]
353
+ ];
354
+ for (const tier of tiers) {
355
+ for (const strategy of tier) {
356
+ const results = buildAxisXpathsForNodes(strategy.nodes, strategy.axis, element, docmt, isTarget, strategy.key, isIndex, platform);
357
+ if (results.length > 0) {
358
+ return results;
359
+ }
360
+ }
361
+ }
362
+ return [];
363
+ };
364
+ const generateIndexedXpaths = (element, docmt, platform) => {
365
+ const results = [];
366
+ const tag = platform === "web"
367
+ ? element.tagName.toLowerCase()
368
+ : element.tagName;
369
+ const globalList = Array.from(docmt.querySelectorAll(tag));
370
+ const idx = globalList.indexOf(element) + 1;
371
+ if (idx <= 0)
372
+ return [];
373
+ results.push({
374
+ key: "xpath by index",
375
+ value: `(//${tag})[${idx}]`
376
+ });
377
+ let current = element.parentElement;
378
+ while (current && current !== docmt.body) {
379
+ if (current.id || current.className) {
380
+ const cls = current.className
381
+ ?.toString()
382
+ .split(" ")
383
+ .map((name) => name.trim())
384
+ .find(Boolean);
385
+ const tagName = platform === "web"
386
+ ? current.tagName.toLowerCase()
387
+ : current.tagName;
388
+ const scopeXpath = current.id
389
+ ? `//${tagName}[@id='${current.id}']`
390
+ : cls
391
+ ? `//${tagName}[contains(@class,'${cls}')]`
392
+ : "";
393
+ if (!scopeXpath) {
394
+ current = current.parentElement;
395
+ continue;
396
+ }
397
+ const scopedDescendants = Array.from(current.querySelectorAll(tag));
398
+ const scopedIdx = scopedDescendants.indexOf(element) + 1;
399
+ if (scopedIdx > 0) {
400
+ results.push({
401
+ key: "xpath by index",
402
+ value: `(${scopeXpath}//${tag})[${scopedIdx}]`
403
+ });
404
+ break;
405
+ }
406
+ }
407
+ current = current.parentElement;
408
+ }
409
+ return results;
410
+ };
411
+ exports.generateIndexedXpaths = generateIndexedXpaths;
412
+ const buildStrategyXpaths = (element, docmt, isTarget, strategy, platform) => {
413
+ const strategyName = getStrategyName(strategy);
414
+ if (strategyName === "text") {
415
+ return withStrategyKey(strategy, buildTextStrategyXpaths(element, docmt, strategyName, platform));
416
+ }
417
+ if (["contains", "startsWith", "normalizeSpace"].includes(strategyName)) {
418
+ return withStrategyKey(strategy, buildPropertyStrategyXpaths(element, isTarget, strategyName, platform));
419
+ }
420
+ if (["and", "or"].includes(strategyName)) {
421
+ return withStrategyKey(strategy, buildConditionStrategyXpaths(element, docmt, isTarget, strategyName, platform));
422
+ }
423
+ if (strategyName === "axes") {
424
+ return withStrategyKey(strategy, buildAxesStrategyXpaths(element, docmt, isTarget, false, platform));
425
+ }
426
+ if (strategyName === "index") {
427
+ return withStrategyKey(strategy, (0, exports.generateIndexedXpaths)(element, docmt, platform));
428
+ }
429
+ if (strategyName === "tag") {
430
+ return withStrategyKey(strategy, [
431
+ { key: "xpath till tag", value: (0, xpathHelpers_js_1.getTagOnlyXPath)(element, platform, docmt) }
432
+ ]);
433
+ }
434
+ return [];
435
+ };
436
+ const checkRelativeXpathRelation = (nodeXpath1, nodeXpath2, targetElemt, docmt, isIndex, relationType) => {
437
+ if (nodeXpath1 && !referenceElementMode) {
438
+ let xpaths;
439
+ if (relationType === "parent") {
440
+ xpaths = [
441
+ `${nodeXpath1}/descendant-or-self::${nodeXpath2}`,
442
+ `${nodeXpath1}/following::${nodeXpath2}`
443
+ ];
444
+ }
445
+ else {
446
+ xpaths = [
447
+ `${nodeXpath1}/ancestor-or-self::${nodeXpath2}`,
448
+ `${nodeXpath1}/preceding::${nodeXpath2}`
449
+ ];
450
+ }
451
+ // Iterate through XPath patterns
452
+ for (const xpath of xpaths) {
453
+ // Check if result is already cached to avoid recomputation
454
+ if (!xpathCache?.get(xpath)) {
455
+ // Compute and store result in cache
456
+ xpathCache.set(xpath, (0, xpathHelpers_js_1.getCountOfXPath)(xpath, targetElemt, docmt));
457
+ }
458
+ const count = xpathCache?.get(xpath);
459
+ // Short-circuit: Return the first valid XPath result found
460
+ if (count === 1) {
461
+ return xpath;
462
+ }
463
+ if (count > 1) {
464
+ if (xpathDataWithIndex.length) {
465
+ if (count < xpathDataWithIndex[0].count) {
466
+ xpathDataWithIndex.pop();
467
+ xpathDataWithIndex.push({
468
+ key: `relative xpath by unique parent ${isIndex ? "index" : ""}`,
469
+ value: xpath,
470
+ count
471
+ });
472
+ }
473
+ }
474
+ else {
475
+ xpathDataWithIndex.push({
476
+ key: `relative xpath by unique parent ${isIndex ? "index" : ""}`,
477
+ value: xpath,
478
+ count
479
+ });
480
+ }
481
+ }
482
+ if (count > 1 && isIndex && !xpathData.length) {
483
+ // Try finding XPath with index if count is greater than 1
484
+ const indexedXpath = (0, xpathHelpers_js_1.findXpathWithIndex)(xpath, targetElemt, docmt, count);
485
+ // Cache the indexed XPath result
486
+ if (indexedXpath &&
487
+ (0, xpathHelpers_js_1.getCountOfXPath)(indexedXpath, targetElemt, docmt) === 1) {
488
+ xpathData.push({
489
+ key: `relative xpath by unique parent ${isIndex ? "index" : ""}`,
490
+ value: indexedXpath
491
+ });
492
+ }
493
+ }
494
+ }
495
+ }
496
+ return null;
497
+ };
498
+ const getUniqueParentXpath = (domNode, docmt, node, isTarget, nodeXpath, isIndex, platform) => {
499
+ try {
500
+ if (parentXpathCache.has(domNode)) {
501
+ return parentXpathCache.get(domNode);
502
+ }
503
+ // Direct XPath construction without loops
504
+ const xpathParts = [];
505
+ let currentNode = domNode;
506
+ while (currentNode && currentNode.nodeType === 1) {
507
+ const hasUniqueAttr = false;
508
+ for (const attrName of Array.from(currentNode.attributes)) {
509
+ if ((0, xpathHelpers_js_1.checkBlockedAttributes)(attrName, currentNode, isTarget)) {
510
+ const attrValue = (0, xpathHelpers_js_1.sanitizeAttributeValue)(attrName.name, attrName.nodeValue);
511
+ const elementName = attrName.name;
512
+ const xpathe = (0, xpathHelpers_js_1.getXpathString)(currentNode, elementName, attrValue);
513
+ let othersWithAttr;
514
+ // If the XPath does not parse, move to the next unique attribute
515
+ try {
516
+ othersWithAttr = checkRelativeXpathRelation(xpathe, nodeXpath, node, docmt, isIndex, "parent");
517
+ }
518
+ catch (ign) {
519
+ logData_js_1.logger.error("error in getUniqueParentXpath", ign);
520
+ continue;
521
+ }
522
+ // If the attribute isn't actually unique, get it's index too
523
+ if (othersWithAttr) {
524
+ return othersWithAttr;
525
+ }
526
+ }
527
+ }
528
+ if (currentNode.textContent && !currentNode.textContent) {
529
+ if (!isTarget ||
530
+ (isTarget && !(0, xpathHelpers_js_1.isNumberExist)(currentNode.textContent))) {
531
+ let xpathe;
532
+ if (!xpathHelpers_js_1.reWhiteSpace.test(currentNode.textContent)) {
533
+ xpathe = (0, xpathHelpers_js_1.isSvg)(currentNode)
534
+ ? `//*[local-name()='${currentNode.tagName}' and normalize-space(.)=${(0, xpathHelpers_js_1.escapeCharacters)((0, xpathHelpers_js_1.getFilteredText)(currentNode))}]`
535
+ : `//${currentNode.tagName || "*"}[normalize-space(.)=${(0, xpathHelpers_js_1.escapeCharacters)((0, xpathHelpers_js_1.getFilteredText)(currentNode))}]`;
536
+ }
537
+ else {
538
+ xpathe = (0, xpathHelpers_js_1.isSvg)(currentNode)
539
+ ? `//*[local-name()='${currentNode.tagName}' and .=${(0, xpathHelpers_js_1.escapeCharacters)((0, xpathHelpers_js_1.getFilteredText)(currentNode))}]`
540
+ : `//${currentNode.tagName || "*"}[.=${(0, xpathHelpers_js_1.escapeCharacters)((0, xpathHelpers_js_1.getFilteredText)(currentNode))}]`;
541
+ }
542
+ const othersWithAttr = checkRelativeXpathRelation(xpathe, nodeXpath, node, docmt, isIndex, "parent");
543
+ if (othersWithAttr) {
544
+ return othersWithAttr;
545
+ }
546
+ }
547
+ else {
548
+ const combinePattern = [];
549
+ const contentRes = [
550
+ ...new Set((0, xpathHelpers_js_1.getFilteredText)(currentNode).match(/([^0-9]+)/g))
551
+ ];
552
+ const reWhiteSpace = new RegExp(/^[\S]+( [\S]+)*$/gi);
553
+ if (contentRes?.length) {
554
+ for (let i = 0; i < contentRes?.length; i++) {
555
+ if (contentRes[i] && (0, xpathHelpers_js_1.replaceWhiteSpaces)(contentRes[i].trim())) {
556
+ if (!reWhiteSpace.test(contentRes[i])) {
557
+ combinePattern.push(`contains(.,${(0, xpathHelpers_js_1.escapeCharacters)((0, xpathHelpers_js_1.replaceWhiteSpaces)(contentRes[i])).trim()})`);
558
+ }
559
+ else {
560
+ combinePattern.push(`contains(.,${(0, xpathHelpers_js_1.escapeCharacters)(contentRes[i].trim()).trim()})`);
561
+ }
562
+ }
563
+ }
564
+ }
565
+ if (combinePattern?.length) {
566
+ const xpathe = (0, xpathHelpers_js_1.isSvg)(currentNode)
567
+ ? `//*[local-name()='${currentNode.tagName}' and ${combinePattern.join(" and ")}]`
568
+ : `//${currentNode.tagName || "*"}[${combinePattern.join(" and ")}]`;
569
+ const othersWithAttr = checkRelativeXpathRelation(xpathe, nodeXpath, node, docmt, isIndex, "parent");
570
+ if (othersWithAttr) {
571
+ return othersWithAttr;
572
+ }
573
+ }
574
+ }
575
+ }
576
+ // Construct the XPath based on the tag name
577
+ if (!hasUniqueAttr) {
578
+ const fallback = (0, xpathHelpers_js_1.getPlatformFallbackXpath)(currentNode, platform);
579
+ if (fallback) {
580
+ const xpath = checkRelativeXpathRelation(fallback, nodeXpath, node, docmt, isIndex, "parent");
581
+ if (xpath) {
582
+ return xpath;
583
+ }
584
+ }
585
+ const xpathe = (0, xpathHelpers_js_1.isSvg)(currentNode)
586
+ ? `/*[local-name()='${currentNode.tagName}']`
587
+ : `/${currentNode.tagName}`;
588
+ xpathParts.unshift(xpathe);
589
+ }
590
+ else {
591
+ break;
592
+ }
593
+ // Move to the parent node for the next iteration
594
+ currentNode = currentNode.parentElement;
595
+ }
596
+ // Final constructed XPath
597
+ const finalXPath = xpathParts.join("") + nodeXpath;
598
+ const count = (0, xpathHelpers_js_1.getCountOfXPath)(finalXPath, domNode, docmt);
599
+ if (count === 1) {
600
+ parentXpathCache.set(domNode, finalXPath); // Cache final result
601
+ return finalXPath;
602
+ }
603
+ }
604
+ catch (error) {
605
+ console.error(error);
606
+ return null;
607
+ }
608
+ };
609
+ const getParentRelativeXpath = (domNode, docmt, node, isTarget, platform) => {
610
+ const cache = new Map(); // Cache to store computed results
611
+ if (cache.has(domNode)) {
612
+ return cache.get(domNode); // Return cached result if available
613
+ }
614
+ const xpathParts = []; // Initialize an array to hold parts of the XPath
615
+ let currentNode = domNode; // Start with the provided DOM node
616
+ try {
617
+ while (currentNode && currentNode.nodeType === 1) {
618
+ // BASE CASE #1: If this isn't an element, we're above the root, return empty string
619
+ if (!currentNode.tagName) {
620
+ return "";
621
+ }
622
+ // BASE CASE #2: Check for unique attributes
623
+ let uniqueAttrFound = false;
624
+ for (const attr of Array.from(currentNode.attributes)) {
625
+ if ((0, xpathHelpers_js_1.checkBlockedAttributes)(attr, currentNode, isTarget)) {
626
+ const attrValue = (0, xpathHelpers_js_1.sanitizeAttributeValue)(attr.name, attr.nodeValue);
627
+ const elementName = attr.name;
628
+ const xpathe = (0, xpathHelpers_js_1.getXpathString)(currentNode, elementName, attrValue);
629
+ let othersWithAttr;
630
+ // If the XPath does not parse, move to the next unique attribute
631
+ try {
632
+ othersWithAttr = (0, xpathHelpers_js_1.getCountOfXPath)(xpathe, currentNode, docmt);
633
+ }
634
+ catch (ign) {
635
+ logData_js_1.logger.error("error in getParentRelativeXpath", ign);
636
+ continue;
637
+ }
638
+ // If the attribute is unique, return its XPath
639
+ if (othersWithAttr === 1) {
640
+ xpathParts.unshift(xpathe);
641
+ uniqueAttrFound = true; // Mark that we found at least one unique attribute
642
+ break;
643
+ }
644
+ }
645
+ }
646
+ // If no unique attributes, check for text content
647
+ if (!uniqueAttrFound && currentNode.textContent && !node.textContent) {
648
+ const textXPath = (0, xpathHelpers_js_1.getFilteredTextXPath)(currentNode);
649
+ if (textXPath) {
650
+ const othersWithAttr = (0, xpathHelpers_js_1.getCountOfXPath)(textXPath, currentNode, docmt);
651
+ if (othersWithAttr === 1) {
652
+ uniqueAttrFound = true; // Mark that we found at least one unique attribute
653
+ xpathParts.unshift(textXPath);
654
+ break;
655
+ }
656
+ }
657
+ }
658
+ if (!uniqueAttrFound) {
659
+ const fallback = (0, xpathHelpers_js_1.getPlatformFallbackXpath)(currentNode, platform);
660
+ if (fallback) {
661
+ xpathParts.push(fallback);
662
+ uniqueAttrFound = true;
663
+ break;
664
+ }
665
+ // Construct the XPath based on the tag name
666
+ const xpathe = (0, xpathHelpers_js_1.isSvg)(currentNode)
667
+ ? `/*[local-name()='${currentNode.tagName}']`
668
+ : `/${currentNode.tagName}`;
669
+ // Prepend the current XPath part to the array
670
+ xpathParts.unshift(xpathe);
671
+ }
672
+ else {
673
+ break;
674
+ }
675
+ // Move to the parent node for the next iteration
676
+ currentNode = currentNode.parentElement;
677
+ }
678
+ // Combine all parts into the final XPath
679
+ const finalXpath = xpathParts.join("");
680
+ cache.set(domNode, finalXpath); // Store result in cache
681
+ return finalXpath;
682
+ }
683
+ catch (error) {
684
+ logData_js_1.logger.error(error);
685
+ return null;
686
+ }
687
+ };
688
+ const getChildRelativeXpath = (domNode, docmt, node) => {
689
+ const xpathParts = []; // Initialize an array to hold parts of the XPath.
690
+ let currentNode;
691
+ const st = [];
692
+ if (domNode.firstElementChild != null &&
693
+ domNode.firstElementChild.classList.contains("flntooltip")) {
694
+ st.unshift(domNode.firstElementChild);
695
+ }
696
+ else if (domNode.nextElementSibling != null)
697
+ st.unshift(domNode.nextElementSibling);
698
+ for (let m = domNode.parentElement; m != null && m.nodeType === 1; m = m.parentElement) {
699
+ if (m.nextElementSibling)
700
+ st.unshift(m.nextElementSibling);
701
+ }
702
+ try {
703
+ do {
704
+ let uniqueAttrFound = false;
705
+ for (currentNode = st.pop(); currentNode !== null;) {
706
+ for (const attr of Array.from(currentNode.attributes)) {
707
+ if ((0, xpathHelpers_js_1.checkBlockedAttributes)(attr, currentNode, true)) {
708
+ const attrValue = (0, xpathHelpers_js_1.sanitizeAttributeValue)(attr.name, attr.nodeValue);
709
+ const elementName = attr.name;
710
+ const xpathe = (0, xpathHelpers_js_1.getXpathString)(currentNode, elementName, attrValue);
711
+ let othersWithAttr;
712
+ // If the XPath does not parse, move to the next unique attribute
713
+ try {
714
+ othersWithAttr = (0, xpathHelpers_js_1.getCountOfXPath)(xpathe, currentNode, docmt);
715
+ }
716
+ catch (ign) {
717
+ logData_js_1.logger.error("error in getChildRelativeXpath", ign);
718
+ continue;
719
+ }
720
+ // If the attribute is unique, return its XPath
721
+ if (othersWithAttr === 1) {
722
+ uniqueAttrFound = true; // Mark that we found at least one unique attribute
723
+ xpathParts.push(xpathe);
724
+ break;
725
+ }
726
+ }
727
+ }
728
+ // If no unique attributes, check for text content
729
+ if (!uniqueAttrFound && currentNode.textContent && !node.textContent) {
730
+ const textXPath = (0, xpathHelpers_js_1.getFilteredTextXPath)(currentNode);
731
+ if (textXPath) {
732
+ const othersWithAttr = (0, xpathHelpers_js_1.getCountOfXPath)(textXPath, currentNode, docmt);
733
+ if (othersWithAttr === 1) {
734
+ uniqueAttrFound = true; // Mark that we found at least one unique attribute
735
+ xpathParts.push(textXPath);
736
+ break;
737
+ }
738
+ }
739
+ }
740
+ if (!uniqueAttrFound) {
741
+ // Construct the XPath based on the tag name
742
+ const xpathe = (0, xpathHelpers_js_1.isSvg)(currentNode)
743
+ ? `/*[local-name()='${currentNode.tagName}']`
744
+ : `/${currentNode.tagName}`;
745
+ // Prepend the current XPath part to the array
746
+ xpathParts.push(xpathe);
747
+ if (currentNode.firstElementChild != null) {
748
+ st.push(currentNode.nextElementSibling);
749
+ currentNode = currentNode.firstElementChild;
750
+ }
751
+ else {
752
+ currentNode = currentNode.nextElementSibling;
753
+ }
754
+ }
755
+ else {
756
+ break;
757
+ }
758
+ }
759
+ } while (st.length > 0);
760
+ // Combine all parts into the final XPath
761
+ const finalXpath = xpathParts.join("");
762
+ cache.set(domNode, finalXpath); // Store result in cache
763
+ return finalXpath;
764
+ }
765
+ catch (error) {
766
+ logData_js_1.logger.error("error in getChildRelativeXpath", error);
767
+ return null;
768
+ }
769
+ };
770
+ const getSiblingRelativeXPath = (domNode, docmt, isTarget, nodeXpath, platform) => {
771
+ try {
772
+ const markedSpan = document.querySelector(".flntooltip");
773
+ for (let m = domNode.nextElementSibling; m !== null && m !== markedSpan; m = m.nextElementSibling) {
774
+ processSibling(m, domNode, docmt, nodeXpath, "preceding-sibling", isTarget, platform);
775
+ }
776
+ for (let n = domNode.previousElementSibling; n !== null && n !== markedSpan; n = n.previousElementSibling) {
777
+ processSibling(n, domNode, docmt, nodeXpath, "following-sibling", isTarget, platform);
778
+ }
779
+ }
780
+ catch (error) {
781
+ console.error("sibling error", error);
782
+ return null;
783
+ }
784
+ };
785
+ const processSibling = (sibling, domNode, docmt, nodeXpath, axis, isTarget, platform) => {
786
+ try {
787
+ if (sibling.hasAttributes()) {
788
+ for (const attr of Array.from(sibling.attributes)) {
789
+ let xpathe = (0, xpathHelpers_js_1.intermediateXpathStep)(sibling, {
790
+ name: attr.name,
791
+ value: attr.value
792
+ }, isTarget);
793
+ if (!xpathe) {
794
+ xpathe = (0, xpathHelpers_js_1.getPlatformFallbackXpath)(sibling, platform);
795
+ }
796
+ if (xpathe) {
797
+ xpathe += `/${axis}::${nodeXpath}`;
798
+ const count = (0, xpathHelpers_js_1.getCountOfXPath)(xpathe, sibling, docmt);
799
+ if (count === 1) {
800
+ xpathData.push({
801
+ key: `xpath by ${axis}`,
802
+ value: xpathe
803
+ });
804
+ return;
805
+ }
806
+ else if (count > 1) {
807
+ if (xpathDataWithIndex.length) {
808
+ if (count < xpathDataWithIndex[0].count) {
809
+ xpathDataWithIndex.pop();
810
+ xpathDataWithIndex.push({
811
+ key: `relative xpath by ${axis}`,
812
+ value: xpathe,
813
+ count
814
+ });
815
+ }
816
+ }
817
+ else {
818
+ xpathDataWithIndex.push({
819
+ key: `relative xpath by ${axis}`,
820
+ value: xpathe,
821
+ count
822
+ });
823
+ }
824
+ }
825
+ }
826
+ }
827
+ }
828
+ if (!isTarget) {
829
+ const xpathe = (0, xpathHelpers_js_1.intermediateXpathStep)(sibling, {
830
+ name: "text",
831
+ value: sibling.textContent
832
+ }, isTarget);
833
+ if (xpathe) {
834
+ const count = (0, xpathHelpers_js_1.getCountOfXPath)(xpathe, sibling, docmt);
835
+ if (count === 1) {
836
+ xpathData.push({
837
+ key: `xpath by ${axis}`,
838
+ value: xpathe
839
+ });
840
+ return;
841
+ }
842
+ else if (count > 1) {
843
+ if (xpathDataWithIndex.length) {
844
+ if (count < xpathDataWithIndex[0].count) {
845
+ xpathDataWithIndex.pop();
846
+ xpathDataWithIndex.push({
847
+ key: `relative xpath by ${axis}`,
848
+ value: xpathe,
849
+ count
850
+ });
851
+ }
852
+ }
853
+ else {
854
+ xpathDataWithIndex.push({
855
+ key: `relative xpath by ${axis}`,
856
+ value: xpathe,
857
+ count
858
+ });
859
+ }
860
+ }
861
+ }
862
+ }
863
+ }
864
+ catch (error) {
865
+ logData_js_1.logger.error(`${axis} xpath-error`, error);
866
+ }
867
+ };
868
+ function getXPathUsingAttributeAndText(attributes, targetElemt, docmt, isTarget) {
869
+ const { tagName } = targetElemt;
870
+ const textContent = targetElemt.textContent.trim();
871
+ if (!textContent) {
872
+ return;
873
+ }
874
+ for (const attrName of attributes) {
875
+ if ((0, xpathHelpers_js_1.checkBlockedAttributes)(attrName, targetElemt, isTarget)) {
876
+ const attrValue = (0, xpathHelpers_js_1.sanitizeAttributeValue)(attrName.name, attrName.nodeValue);
877
+ const elementName = attrName.name;
878
+ const xpath = `//${tagName}[@${elementName}='${attrValue}' and text()='${textContent}']`;
879
+ if (xpath) {
880
+ const count = (0, xpathHelpers_js_1.getCountOfXPath)(xpath, targetElemt, docmt);
881
+ if (count == 1) {
882
+ return xpath;
883
+ }
884
+ }
885
+ }
886
+ }
887
+ }
888
+ const addRelativeXpaths = (targetElemt, docmt, isIndex, isTarget, attribute, platform) => {
889
+ try {
890
+ const nodeXpath = [];
891
+ let relativeXpath, relativeChildXpath;
892
+ xpathData = [];
893
+ if (attribute) {
894
+ for (const attrName of attribute) {
895
+ const expression = (0, xpathHelpers_js_1.intermediateXpathStep)(targetElemt, {
896
+ name: attrName.name,
897
+ value: attrName.value
898
+ }, isTarget);
899
+ if (expression) {
900
+ nodeXpath.push(expression);
901
+ }
902
+ }
903
+ }
904
+ if (targetElemt.textContent) {
905
+ const expression = (0, xpathHelpers_js_1.intermediateXpathStep)(targetElemt, {
906
+ name: "text",
907
+ value: targetElemt.textContent
908
+ }, isTarget);
909
+ // console.log(expression);
910
+ if (expression) {
911
+ nodeXpath.push(expression);
912
+ }
913
+ }
914
+ nodeXpath.push(targetElemt.tagName);
915
+ if (nodeXpath?.length) {
916
+ for (let i = 0; i < nodeXpath.length; i++) {
917
+ if (!xpathData.length) {
918
+ getSiblingRelativeXPath(targetElemt, docmt, isTarget, nodeXpath[i], platform);
919
+ if (!xpathData.length) {
920
+ if (!relativeXpath) {
921
+ relativeXpath = getParentRelativeXpath(targetElemt.parentElement, docmt, targetElemt, isTarget, platform);
922
+ }
923
+ if (relativeXpath &&
924
+ (relativeXpath.includes("@") ||
925
+ relativeXpath.includes("text()") ||
926
+ relativeXpath.includes(".=")) &&
927
+ relativeXpath.match(/\//g)?.length - 2 < 5) {
928
+ const fullRelativeXpath = relativeXpath + `/${nodeXpath[i]}`;
929
+ const count = (0, xpathHelpers_js_1.getCountOfXPath)(fullRelativeXpath, targetElemt, docmt);
930
+ if (count === 1) {
931
+ xpathData.push({
932
+ key: "relative xpath by relative parent",
933
+ value: fullRelativeXpath
934
+ });
935
+ }
936
+ else if (count > 1 && isIndex) {
937
+ const relativeXpathIndex = (0, xpathHelpers_js_1.findXpathWithIndex)(fullRelativeXpath, targetElemt, docmt, count);
938
+ if (relativeXpathIndex &&
939
+ (0, xpathHelpers_js_1.getCountOfXPath)(relativeXpathIndex, targetElemt, docmt) === 1) {
940
+ xpathData.push({
941
+ key: `relative xpath by relative parent ${isIndex ? "index" : ""}`,
942
+ value: relativeXpathIndex
943
+ });
944
+ }
945
+ }
946
+ }
947
+ }
948
+ if (xpathData.length <= 1) {
949
+ if (!relativeChildXpath) {
950
+ relativeChildXpath = getChildRelativeXpath(targetElemt, docmt, targetElemt);
951
+ }
952
+ if (relativeChildXpath &&
953
+ (relativeChildXpath.includes("@") ||
954
+ relativeChildXpath.includes("text()") ||
955
+ relativeChildXpath.includes(".="))) {
956
+ const fullRelativeXpath = `/${nodeXpath[i] + relativeChildXpath.substring(1)}`;
957
+ const count = (0, xpathHelpers_js_1.getCountOfXPath)(fullRelativeXpath, targetElemt, docmt);
958
+ if (count === 1) {
959
+ xpathData.push({
960
+ key: "relative xpath by relative child",
961
+ value: fullRelativeXpath
962
+ });
963
+ }
964
+ else if (count > 1 && isIndex) {
965
+ const relativeXpathIndex = (0, xpathHelpers_js_1.findXpathWithIndex)(fullRelativeXpath, targetElemt, docmt, count);
966
+ if (relativeXpathIndex &&
967
+ (0, xpathHelpers_js_1.getCountOfXPath)(relativeXpathIndex, targetElemt, docmt) === 1) {
968
+ xpathData.push({
969
+ key: `relative xpath by relative parent ${isIndex ? "index" : ""}`,
970
+ value: relativeXpathIndex
971
+ });
972
+ }
973
+ }
974
+ }
975
+ }
976
+ if (xpathData?.length === 1 &&
977
+ (xpathData?.[0]?.value?.match(/\[([0-9]+)\]/gm)?.length || 0) > 3 &&
978
+ !referenceElementMode) {
979
+ if (targetElemt.textContent) {
980
+ const txtXpath = (0, exports.getTextXPath)(targetElemt, docmt, isIndex, false, platform);
981
+ if (txtXpath) {
982
+ xpathData.unshift({
983
+ key: `xpath by text${isIndex ? "index" : ""}`,
984
+ value: txtXpath
985
+ });
986
+ }
987
+ }
988
+ }
989
+ if (!xpathData.length) {
990
+ const tempRelativeXpath = getUniqueParentXpath(targetElemt.parentElement, docmt, targetElemt, isTarget, nodeXpath[i], isIndex, platform);
991
+ if (tempRelativeXpath) {
992
+ xpathData.push({
993
+ key: "xpath by unique parent",
994
+ value: tempRelativeXpath
995
+ });
996
+ }
997
+ }
998
+ }
999
+ }
1000
+ }
1001
+ return xpathData;
1002
+ }
1003
+ catch (error) {
1004
+ logData_js_1.logger.error("Error in addRelativeXpaths:", error);
1005
+ }
1006
+ };
1007
+ const attributesBasedXPath = (attr, targetElemt, docmt, isIndex, isTarget, platform) => {
1008
+ const attrName = attr.name;
1009
+ const xpath = (0, xpathHelpers_js_1.getPropertyXPath)(targetElemt, docmt, `@${attrName}`, attr.value, isIndex, isTarget, platform);
1010
+ return xpath;
1011
+ };
1012
+ exports.attributesBasedXPath = attributesBasedXPath;
1013
+ const getUniqueClassName = (element, docmt, isIndex, isTarget, platform) => {
1014
+ let value = element.className;
1015
+ if (typeof value !== "string") {
1016
+ value = "";
1017
+ }
1018
+ value = value?.replace("flndisabled", "disabled");
1019
+ value = (0, xpathHelpers_js_1.sanitizeAttributeValue)("class", value);
1020
+ value = value?.trim();
1021
+ if (value) {
1022
+ return (0, xpathHelpers_js_1.getPropertyXPath)(element, docmt, `@class`, value, isIndex, isTarget, platform);
1023
+ }
1024
+ };
1025
+ exports.getUniqueClassName = getUniqueClassName;
1026
+ const getTextXPath = (element, docmt, isIndex, isTarget, platform) => {
1027
+ if ((element.textContent ?? "").trim() != "") {
1028
+ const text = (0, xpathHelpers_js_1.getTextContent)(element);
1029
+ if (text) {
1030
+ return (0, xpathHelpers_js_1.getPropertyXPath)(element, docmt, ".", text, isIndex, isTarget, platform);
1031
+ }
1032
+ }
1033
+ };
1034
+ exports.getTextXPath = getTextXPath;
1035
+ const addAllXPathAttributes = (attributes, targetElemt, docmt, isIndex, isTarget, platform) => {
1036
+ const attributesArray = attributes;
1037
+ try {
1038
+ attributesArray.map((attr) => {
1039
+ if (!(attr.name === "className" || attr.name === "class")) {
1040
+ if ((0, xpathHelpers_js_1.checkBlockedAttributes)(attr, targetElemt, isTarget)) {
1041
+ const xpth = (0, exports.attributesBasedXPath)(attr, targetElemt, docmt, isIndex, isTarget, platform);
1042
+ if (xpth) {
1043
+ xpathData.push({
1044
+ key: `xpath by ${attr.name}${isIndex ? " index" : ""}`,
1045
+ value: xpth
1046
+ });
1047
+ }
1048
+ const containsXpath = (0, xpathHelpers_js_1.getContainsPropertyXPath)(targetElemt, `@${attr.name}`, attr.value, platform);
1049
+ if (containsXpath &&
1050
+ (0, xpathHelpers_js_1.getCountOfXPath)(containsXpath, targetElemt, docmt) === 1) {
1051
+ xpathData.push({
1052
+ key: `xpath by contains ${attr.name}`,
1053
+ value: containsXpath
1054
+ });
1055
+ }
1056
+ const startsWithXpath = (0, xpathHelpers_js_1.getStartsWithPropertyXPath)(targetElemt, `@${attr.name}`, attr.value, platform);
1057
+ if (startsWithXpath &&
1058
+ (0, xpathHelpers_js_1.getCountOfXPath)(startsWithXpath, targetElemt, docmt) === 1) {
1059
+ xpathData.push({
1060
+ key: `xpath by startsWith ${attr.name}`,
1061
+ value: startsWithXpath
1062
+ });
1063
+ }
1064
+ }
1065
+ }
1066
+ });
1067
+ const txtXpath = (0, exports.getTextXPath)(targetElemt, docmt, isIndex, isTarget, platform);
1068
+ if (txtXpath) {
1069
+ xpathData.push({
1070
+ key: `xpath by text${isIndex ? " index" : ""}`,
1071
+ value: txtXpath
1072
+ });
1073
+ }
1074
+ const classNameAttr = attributesArray.find((element) => element.name === "className");
1075
+ if (classNameAttr && (0, xpathHelpers_js_1.checkBlockedAttributes)(classNameAttr, targetElemt, isTarget)) {
1076
+ const xpath = (0, exports.getUniqueClassName)(targetElemt, docmt, isIndex, isTarget, platform);
1077
+ if (xpath) {
1078
+ xpathData.push({
1079
+ key: "xpath by class",
1080
+ value: xpath
1081
+ });
1082
+ }
1083
+ }
1084
+ if (!xpathData.length && attributesArray.length > 1) {
1085
+ const combinationXpath = (0, xpathHelpers_js_1.getAttributeCombinationXpath)(targetElemt, docmt, attributesArray, isTarget, platform);
1086
+ if (combinationXpath)
1087
+ xpathData.push({
1088
+ key: "xpath by combination",
1089
+ value: combinationXpath
1090
+ });
1091
+ }
1092
+ if (!xpathData.length) {
1093
+ const textAttribute = getXPathUsingAttributeAndText(attributes, targetElemt, docmt, isTarget);
1094
+ if (textAttribute)
1095
+ xpathData.push({
1096
+ key: "xpath by textAttribute",
1097
+ value: textAttribute
1098
+ });
1099
+ }
1100
+ }
1101
+ catch (error) {
1102
+ logData_js_1.logger.error("Error in addAllXPathAttributes:", error);
1103
+ }
1104
+ };
1105
+ const parseDOM = (element, doc, isIndex, isTarget, includedAttributes = [], strategies = [], platform) => {
1106
+ xpathData = [];
1107
+ const targetElemt = element;
1108
+ const rootNode = targetElemt?.getRootNode?.();
1109
+ const DOCUMENT_FRAGMENT_NODE = 11;
1110
+ const isShadowScoped = rootNode?.nodeType === DOCUMENT_FRAGMENT_NODE;
1111
+ const docmt = (isShadowScoped ? rootNode : targetElemt?.ownerDocument || doc);
1112
+ const tag = targetElemt.tagName;
1113
+ const { attributes } = targetElemt;
1114
+ const attributesToUse = includedAttributes.length > 0 ? includedAttributes : Array.from(attributes);
1115
+ addAllXPathAttributes(attributesToUse, targetElemt, docmt, isIndex, isTarget, platform);
1116
+ if (platform === "android") {
1117
+ xpathData.push(...(0, androidSelector_js_1.generateAndroidLocators)(targetElemt, docmt, isTarget));
1118
+ }
1119
+ else if (platform === "ios") {
1120
+ xpathData.push(...(0, iosSelector_js_1.generateIOSLocators)(targetElemt, docmt, isTarget));
1121
+ }
1122
+ if (xpathData.length < 2) {
1123
+ const fallback = (0, xpathHelpers_js_1.getPlatformFallbackXpath)(targetElemt, platform);
1124
+ if (fallback) {
1125
+ xpathData.push({
1126
+ key: "platform fallback",
1127
+ value: fallback
1128
+ });
1129
+ }
1130
+ }
1131
+ if (strategies.length) {
1132
+ const strategyXpaths = strategies.flatMap((strategy) => buildStrategyXpaths(targetElemt, docmt, isTarget, strategy, platform));
1133
+ xpathData = getUniqueXpathEntries(strategyXpaths.filter((xpath) => (0, xpathHelpers_js_1.getCountOfXPath)(xpath.value, targetElemt, docmt) === 1));
1134
+ return xpathData;
1135
+ }
1136
+ if (!referenceElementMode) {
1137
+ if (xpathData.length) {
1138
+ const len = xpathData.length;
1139
+ for (let i = 0; i < len; i++) {
1140
+ let xpth = xpathData[i].value;
1141
+ if (xpth.startsWith(`//${tag}`)) {
1142
+ xpth = "//*" + xpth.substring(2 + tag.length);
1143
+ }
1144
+ if ((0, xpathHelpers_js_1.getCountOfXPath)(xpth, element, docmt) === 1 &&
1145
+ !xpathData.some(x => x.value === xpth)) {
1146
+ xpathData.push({
1147
+ key: `${xpathData[i].key} regex`,
1148
+ value: xpth
1149
+ });
1150
+ }
1151
+ // const count = getCountOfXPath(xpth, element, docmt);
1152
+ // if (count === 1) {
1153
+ // xpathData.push({
1154
+ // key: `${xpathData[i].key} regex`,
1155
+ // value: xpth
1156
+ // });
1157
+ // }
1158
+ }
1159
+ }
1160
+ }
1161
+ if (!xpathData.length && !isShadowScoped) {
1162
+ xpathData = buildAxesStrategyXpaths(targetElemt, docmt, isTarget, isIndex, platform);
1163
+ }
1164
+ return xpathData;
1165
+ };
1166
+ exports.parseDOM = parseDOM;
1167
+ const xpath = {
1168
+ parseDOM: exports.parseDOM,
1169
+ getTextXPath: exports.getTextXPath,
1170
+ getUniqueClassName: exports.getUniqueClassName,
1171
+ attributesBasedXPath: exports.attributesBasedXPath,
1172
+ addAllXPathAttributes,
1173
+ addRelativeXpaths,
1174
+ getXPathUsingAttributeAndText,
1175
+ getSiblingRelativeXPath,
1176
+ getChildRelativeXpath,
1177
+ getParentRelativeXpath,
1178
+ getUniqueParentXpath,
1179
+ checkRelativeXpathRelation,
1180
+ buildAxesStrategyXpaths
1181
+ };
1182
+ exports.default = xpath;