octoparse-cli 0.1.14

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 (278) hide show
  1. package/README.md +271 -0
  2. package/RUNTIME_SECURITY_NOTICE.txt +41 -0
  3. package/SECURITY.md +24 -0
  4. package/dist/cli/args.js +34 -0
  5. package/dist/cli/help.js +214 -0
  6. package/dist/cli/output.js +39 -0
  7. package/dist/commands/auth.js +283 -0
  8. package/dist/commands/capabilities.js +118 -0
  9. package/dist/commands/cloud.js +241 -0
  10. package/dist/commands/data.js +220 -0
  11. package/dist/commands/doctor.js +73 -0
  12. package/dist/commands/env.js +63 -0
  13. package/dist/commands/local.js +251 -0
  14. package/dist/commands/run.js +622 -0
  15. package/dist/commands/runs.js +171 -0
  16. package/dist/commands/task.js +101 -0
  17. package/dist/index.js +133 -0
  18. package/dist/runtime/account-capabilities.js +71 -0
  19. package/dist/runtime/api-client.js +290 -0
  20. package/dist/runtime/artifacts.js +33 -0
  21. package/dist/runtime/auth.js +94 -0
  22. package/dist/runtime/bridge-hub.js +173 -0
  23. package/dist/runtime/client-headers.js +23 -0
  24. package/dist/runtime/cloud-data.js +75 -0
  25. package/dist/runtime/config.js +48 -0
  26. package/dist/runtime/data-exporter.js +267 -0
  27. package/dist/runtime/engine-host.js +449 -0
  28. package/dist/runtime/local-runs.js +92 -0
  29. package/dist/runtime/naming.js +13 -0
  30. package/dist/runtime/run-control.js +363 -0
  31. package/dist/runtime/run-services.js +380 -0
  32. package/dist/runtime/security-notice.js +78 -0
  33. package/dist/runtime/task-definition-provider.js +282 -0
  34. package/dist/types.js +4 -0
  35. package/examples/minimal-task.json +6 -0
  36. package/examples/navigate-example-task.json +6 -0
  37. package/node_modules/@octopus/bpmn/index.js +3 -0
  38. package/node_modules/@octopus/bpmn/lib/Context.js +245 -0
  39. package/node_modules/@octopus/bpmn/lib/Definition.js +258 -0
  40. package/node_modules/@octopus/bpmn/lib/Engine.js +275 -0
  41. package/node_modules/@octopus/bpmn/lib/PrematureStopError.js +7 -0
  42. package/node_modules/@octopus/bpmn/lib/activities/Activity.js +202 -0
  43. package/node_modules/@octopus/bpmn/lib/activities/BaseProcess.js +308 -0
  44. package/node_modules/@octopus/bpmn/lib/activities/BaseTask.js +145 -0
  45. package/node_modules/@octopus/bpmn/lib/activities/BoundaryEvent.js +12 -0
  46. package/node_modules/@octopus/bpmn/lib/activities/Dummy.js +10 -0
  47. package/node_modules/@octopus/bpmn/lib/activities/EventDefinition.js +99 -0
  48. package/node_modules/@octopus/bpmn/lib/activities/Flow.js +52 -0
  49. package/node_modules/@octopus/bpmn/lib/activities/Form.js +67 -0
  50. package/node_modules/@octopus/bpmn/lib/activities/InputOutput.js +53 -0
  51. package/node_modules/@octopus/bpmn/lib/activities/IntermediateCatchEvent.js +12 -0
  52. package/node_modules/@octopus/bpmn/lib/activities/MessageFlow.js +19 -0
  53. package/node_modules/@octopus/bpmn/lib/activities/MultiInstanceLoopCharacteristics.js +160 -0
  54. package/node_modules/@octopus/bpmn/lib/activities/Properties.js +27 -0
  55. package/node_modules/@octopus/bpmn/lib/activities/SequenceFlow.js +56 -0
  56. package/node_modules/@octopus/bpmn/lib/activities/ServiceConnector.js +71 -0
  57. package/node_modules/@octopus/bpmn/lib/context-helper.js +198 -0
  58. package/node_modules/@octopus/bpmn/lib/events/EndEvent.js +22 -0
  59. package/node_modules/@octopus/bpmn/lib/events/ErrorEvent.js +41 -0
  60. package/node_modules/@octopus/bpmn/lib/events/MessageEvent.js +19 -0
  61. package/node_modules/@octopus/bpmn/lib/events/StartEvent.js +55 -0
  62. package/node_modules/@octopus/bpmn/lib/events/TimerEvent.js +75 -0
  63. package/node_modules/@octopus/bpmn/lib/expressions.js +41 -0
  64. package/node_modules/@octopus/bpmn/lib/gateways/ExclusiveGateway.js +86 -0
  65. package/node_modules/@octopus/bpmn/lib/gateways/InclusiveGateway.js +56 -0
  66. package/node_modules/@octopus/bpmn/lib/gateways/ParallelGateway.js +195 -0
  67. package/node_modules/@octopus/bpmn/lib/getPropertyValue.js +83 -0
  68. package/node_modules/@octopus/bpmn/lib/index.js +6 -0
  69. package/node_modules/@octopus/bpmn/lib/mapper.js +55 -0
  70. package/node_modules/@octopus/bpmn/lib/parameter.js +119 -0
  71. package/node_modules/@octopus/bpmn/lib/script-helper.js +45 -0
  72. package/node_modules/@octopus/bpmn/lib/tasks/ManualTask.js +31 -0
  73. package/node_modules/@octopus/bpmn/lib/tasks/ReceiveTask.js +31 -0
  74. package/node_modules/@octopus/bpmn/lib/tasks/ScriptTask.js +35 -0
  75. package/node_modules/@octopus/bpmn/lib/tasks/SendTask.js +16 -0
  76. package/node_modules/@octopus/bpmn/lib/tasks/ServiceTask.js +68 -0
  77. package/node_modules/@octopus/bpmn/lib/tasks/SubProcess.js +17 -0
  78. package/node_modules/@octopus/bpmn/lib/tasks/Task.js +16 -0
  79. package/node_modules/@octopus/bpmn/lib/tasks/UserTask.js +47 -0
  80. package/node_modules/@octopus/bpmn/lib/transformer.js +13 -0
  81. package/node_modules/@octopus/bpmn/lib/validation.js +111 -0
  82. package/node_modules/@octopus/bpmn/package.json +17 -0
  83. package/node_modules/@octopus/bpmn/types/bpmn.d.ts +85 -0
  84. package/node_modules/@octopus/engine/README.md +370 -0
  85. package/node_modules/@octopus/engine/dist/actions/BackPreWebPageAction.d.ts +4 -0
  86. package/node_modules/@octopus/engine/dist/actions/BackPreWebPageAction.js +1 -0
  87. package/node_modules/@octopus/engine/dist/actions/BaseAction.d.ts +339 -0
  88. package/node_modules/@octopus/engine/dist/actions/BaseAction.js +1559 -0
  89. package/node_modules/@octopus/engine/dist/actions/BranchAction.d.ts +9 -0
  90. package/node_modules/@octopus/engine/dist/actions/BranchAction.js +1 -0
  91. package/node_modules/@octopus/engine/dist/actions/ClickAction.d.ts +22 -0
  92. package/node_modules/@octopus/engine/dist/actions/ClickAction.js +1 -0
  93. package/node_modules/@octopus/engine/dist/actions/ConditionAction.d.ts +4 -0
  94. package/node_modules/@octopus/engine/dist/actions/ConditionAction.js +1 -0
  95. package/node_modules/@octopus/engine/dist/actions/EmptyAction.d.ts +4 -0
  96. package/node_modules/@octopus/engine/dist/actions/EmptyAction.js +12 -0
  97. package/node_modules/@octopus/engine/dist/actions/EnterCaptchaAction.d.ts +28 -0
  98. package/node_modules/@octopus/engine/dist/actions/EnterCaptchaAction.js +1 -0
  99. package/node_modules/@octopus/engine/dist/actions/EnterTextAction.d.ts +20 -0
  100. package/node_modules/@octopus/engine/dist/actions/EnterTextAction.js +1 -0
  101. package/node_modules/@octopus/engine/dist/actions/ExtractDataAction.d.ts +40 -0
  102. package/node_modules/@octopus/engine/dist/actions/ExtractDataAction.js +1 -0
  103. package/node_modules/@octopus/engine/dist/actions/LoopAction.d.ts +41 -0
  104. package/node_modules/@octopus/engine/dist/actions/LoopAction.js +526 -0
  105. package/node_modules/@octopus/engine/dist/actions/LoopStartAction.d.ts +47 -0
  106. package/node_modules/@octopus/engine/dist/actions/LoopStartAction.js +607 -0
  107. package/node_modules/@octopus/engine/dist/actions/MouseOverAction.d.ts +8 -0
  108. package/node_modules/@octopus/engine/dist/actions/MouseOverAction.js +34 -0
  109. package/node_modules/@octopus/engine/dist/actions/NavigateAction.d.ts +38 -0
  110. package/node_modules/@octopus/engine/dist/actions/NavigateAction.js +535 -0
  111. package/node_modules/@octopus/engine/dist/actions/SwitchComboAction.d.ts +13 -0
  112. package/node_modules/@octopus/engine/dist/actions/SwitchComboAction.js +69 -0
  113. package/node_modules/@octopus/engine/dist/browser.d.ts +17 -0
  114. package/node_modules/@octopus/engine/dist/browser.js +157 -0
  115. package/node_modules/@octopus/engine/dist/browserProxy.d.ts +90 -0
  116. package/node_modules/@octopus/engine/dist/browserProxy.js +1 -0
  117. package/node_modules/@octopus/engine/dist/configs/BaseConfig.d.ts +20 -0
  118. package/node_modules/@octopus/engine/dist/configs/BaseConfig.js +88 -0
  119. package/node_modules/@octopus/engine/dist/configs/BranchConfig.d.ts +7 -0
  120. package/node_modules/@octopus/engine/dist/configs/BranchConfig.js +1 -0
  121. package/node_modules/@octopus/engine/dist/configs/ClickConfig.d.ts +36 -0
  122. package/node_modules/@octopus/engine/dist/configs/ClickConfig.js +65 -0
  123. package/node_modules/@octopus/engine/dist/configs/EnterCaptchaConfig.d.ts +19 -0
  124. package/node_modules/@octopus/engine/dist/configs/EnterCaptchaConfig.js +25 -0
  125. package/node_modules/@octopus/engine/dist/configs/EnterTextConfig.d.ts +24 -0
  126. package/node_modules/@octopus/engine/dist/configs/EnterTextConfig.js +36 -0
  127. package/node_modules/@octopus/engine/dist/configs/ExtractDataConfig.d.ts +12 -0
  128. package/node_modules/@octopus/engine/dist/configs/ExtractDataConfig.js +1 -0
  129. package/node_modules/@octopus/engine/dist/configs/LoopConfig.d.ts +25 -0
  130. package/node_modules/@octopus/engine/dist/configs/LoopConfig.js +40 -0
  131. package/node_modules/@octopus/engine/dist/configs/LoopStartConfig.d.ts +4 -0
  132. package/node_modules/@octopus/engine/dist/configs/LoopStartConfig.js +12 -0
  133. package/node_modules/@octopus/engine/dist/configs/MouseOverConfig.d.ts +8 -0
  134. package/node_modules/@octopus/engine/dist/configs/MouseOverConfig.js +15 -0
  135. package/node_modules/@octopus/engine/dist/configs/NavigateConfig.d.ts +41 -0
  136. package/node_modules/@octopus/engine/dist/configs/NavigateConfig.js +121 -0
  137. package/node_modules/@octopus/engine/dist/configs/SwitchComboConfig.d.ts +8 -0
  138. package/node_modules/@octopus/engine/dist/configs/SwitchComboConfig.js +15 -0
  139. package/node_modules/@octopus/engine/dist/enums/index.d.ts +419 -0
  140. package/node_modules/@octopus/engine/dist/enums/index.js +314 -0
  141. package/node_modules/@octopus/engine/dist/extension/BrowserWebSocketTransport-D_zAGZMQ.js +1 -0
  142. package/node_modules/@octopus/engine/dist/extension/LaunchOptions-DxvePrV4.js +6 -0
  143. package/node_modules/@octopus/engine/dist/extension/NodeWebSocketTransport-BTgRVB7Z.js +6 -0
  144. package/node_modules/@octopus/engine/dist/extension/background.js +396 -0
  145. package/node_modules/@octopus/engine/dist/extension/bidi-C_GIZ8Uz.js +131 -0
  146. package/node_modules/@octopus/engine/dist/extension/manifest.json +27 -0
  147. package/node_modules/@octopus/engine/dist/extension/src/content/anti-detection.js +1 -0
  148. package/node_modules/@octopus/engine/dist/extension-bridge/BaseExtensionBridge.d.ts +21 -0
  149. package/node_modules/@octopus/engine/dist/extension-bridge/BaseExtensionBridge.js +117 -0
  150. package/node_modules/@octopus/engine/dist/extension-bridge/SessionExtensionBridge.d.ts +17 -0
  151. package/node_modules/@octopus/engine/dist/extension-bridge/SessionExtensionBridge.js +29 -0
  152. package/node_modules/@octopus/engine/dist/extension-bridge/index.d.ts +2 -0
  153. package/node_modules/@octopus/engine/dist/extension-bridge/index.js +5 -0
  154. package/node_modules/@octopus/engine/dist/extension-bridge/types.d.ts +159 -0
  155. package/node_modules/@octopus/engine/dist/extension-bridge/types.js +5 -0
  156. package/node_modules/@octopus/engine/dist/extensions/ublock-origin/uBlock0.chromium.tar.xz +0 -0
  157. package/node_modules/@octopus/engine/dist/extensions/ublock-origin-lite/uBOLite.chromium.tar.xz +0 -0
  158. package/node_modules/@octopus/engine/dist/index.d.ts +169 -0
  159. package/node_modules/@octopus/engine/dist/index.js +1 -0
  160. package/node_modules/@octopus/engine/dist/models/actionItem.d.ts +16 -0
  161. package/node_modules/@octopus/engine/dist/models/actionItem.js +15 -0
  162. package/node_modules/@octopus/engine/dist/models/conditionCheckArgs.d.ts +11 -0
  163. package/node_modules/@octopus/engine/dist/models/conditionCheckArgs.js +11 -0
  164. package/node_modules/@octopus/engine/dist/models/customizeCookie.d.ts +14 -0
  165. package/node_modules/@octopus/engine/dist/models/customizeCookie.js +6 -0
  166. package/node_modules/@octopus/engine/dist/models/downloadFileConfig.d.ts +17 -0
  167. package/node_modules/@octopus/engine/dist/models/downloadFileConfig.js +26 -0
  168. package/node_modules/@octopus/engine/dist/models/elementNotFoundArgs.d.ts +8 -0
  169. package/node_modules/@octopus/engine/dist/models/elementNotFoundArgs.js +12 -0
  170. package/node_modules/@octopus/engine/dist/models/elementNotFoundError.d.ts +2 -0
  171. package/node_modules/@octopus/engine/dist/models/elementNotFoundError.js +6 -0
  172. package/node_modules/@octopus/engine/dist/models/extractItem.d.ts +37 -0
  173. package/node_modules/@octopus/engine/dist/models/extractItem.js +35 -0
  174. package/node_modules/@octopus/engine/dist/models/extractTemplate.d.ts +11 -0
  175. package/node_modules/@octopus/engine/dist/models/extractTemplate.js +48 -0
  176. package/node_modules/@octopus/engine/dist/models/extractTextItem.d.ts +10 -0
  177. package/node_modules/@octopus/engine/dist/models/extractTextItem.js +17 -0
  178. package/node_modules/@octopus/engine/dist/models/globalConfig.d.ts +5 -0
  179. package/node_modules/@octopus/engine/dist/models/globalConfig.js +1 -0
  180. package/node_modules/@octopus/engine/dist/models/httpHeader.d.ts +4 -0
  181. package/node_modules/@octopus/engine/dist/models/httpHeader.js +10 -0
  182. package/node_modules/@octopus/engine/dist/models/operation.d.ts +27 -0
  183. package/node_modules/@octopus/engine/dist/models/operation.js +242 -0
  184. package/node_modules/@octopus/engine/dist/models/retryCondition.d.ts +7 -0
  185. package/node_modules/@octopus/engine/dist/models/retryCondition.js +10 -0
  186. package/node_modules/@octopus/engine/dist/models/task.d.ts +89 -0
  187. package/node_modules/@octopus/engine/dist/models/task.js +120 -0
  188. package/node_modules/@octopus/engine/dist/models/trigger.d.ts +66 -0
  189. package/node_modules/@octopus/engine/dist/models/trigger.js +117 -0
  190. package/node_modules/@octopus/engine/dist/package.json +26 -0
  191. package/node_modules/@octopus/engine/dist/public-types.d.ts +13 -0
  192. package/node_modules/@octopus/engine/dist/public-types.js +2 -0
  193. package/node_modules/@octopus/engine/dist/settings.d.ts +41 -0
  194. package/node_modules/@octopus/engine/dist/settings.js +20 -0
  195. package/node_modules/@octopus/engine/dist/solvers/captcha/ClickCaptchaSolver.d.ts +6 -0
  196. package/node_modules/@octopus/engine/dist/solvers/captcha/ClickCaptchaSolver.js +1 -0
  197. package/node_modules/@octopus/engine/dist/solvers/captcha/HCaptchaSolver.d.ts +4 -0
  198. package/node_modules/@octopus/engine/dist/solvers/captcha/HCaptchaSolver.js +73 -0
  199. package/node_modules/@octopus/engine/dist/solvers/captcha/ImageCaptchaSolver.d.ts +2 -0
  200. package/node_modules/@octopus/engine/dist/solvers/captcha/ImageCaptchaSolver.js +74 -0
  201. package/node_modules/@octopus/engine/dist/solvers/captcha/RecaptchaSolver.d.ts +9 -0
  202. package/node_modules/@octopus/engine/dist/solvers/captcha/RecaptchaSolver.js +371 -0
  203. package/node_modules/@octopus/engine/dist/solvers/captcha/SliderCaptchaSolver.d.ts +6 -0
  204. package/node_modules/@octopus/engine/dist/solvers/captcha/SliderCaptchaSolver.js +184 -0
  205. package/node_modules/@octopus/engine/dist/solvers/captcha/SlidingTrajectory.d.ts +50 -0
  206. package/node_modules/@octopus/engine/dist/solvers/captcha/SlidingTrajectory.js +125 -0
  207. package/node_modules/@octopus/engine/dist/solvers/captcha/types.d.ts +68 -0
  208. package/node_modules/@octopus/engine/dist/solvers/captcha/types.js +34 -0
  209. package/node_modules/@octopus/engine/dist/solvers/captcha/utils.d.ts +2 -0
  210. package/node_modules/@octopus/engine/dist/solvers/captcha/utils.js +15 -0
  211. package/node_modules/@octopus/engine/dist/translator/actionFactory.d.ts +6 -0
  212. package/node_modules/@octopus/engine/dist/translator/actionFactory.js +1 -0
  213. package/node_modules/@octopus/engine/dist/translator/activityTypeEnum.d.ts +22 -0
  214. package/node_modules/@octopus/engine/dist/translator/activityTypeEnum.js +1 -0
  215. package/node_modules/@octopus/engine/dist/translator/backPreWebPageAction.d.ts +5 -0
  216. package/node_modules/@octopus/engine/dist/translator/backPreWebPageAction.js +1 -0
  217. package/node_modules/@octopus/engine/dist/translator/baseAction.d.ts +31 -0
  218. package/node_modules/@octopus/engine/dist/translator/baseAction.js +1 -0
  219. package/node_modules/@octopus/engine/dist/translator/breakActivity.d.ts +5 -0
  220. package/node_modules/@octopus/engine/dist/translator/breakActivity.js +1 -0
  221. package/node_modules/@octopus/engine/dist/translator/clickAction.d.ts +5 -0
  222. package/node_modules/@octopus/engine/dist/translator/clickAction.js +1 -0
  223. package/node_modules/@octopus/engine/dist/translator/completeWF.d.ts +5 -0
  224. package/node_modules/@octopus/engine/dist/translator/completeWF.js +1 -0
  225. package/node_modules/@octopus/engine/dist/translator/conditionAction.d.ts +6 -0
  226. package/node_modules/@octopus/engine/dist/translator/conditionAction.js +1 -0
  227. package/node_modules/@octopus/engine/dist/translator/emptyAction.d.ts +5 -0
  228. package/node_modules/@octopus/engine/dist/translator/emptyAction.js +1 -0
  229. package/node_modules/@octopus/engine/dist/translator/enterCapachaAction.d.ts +5 -0
  230. package/node_modules/@octopus/engine/dist/translator/enterCapachaAction.js +1 -0
  231. package/node_modules/@octopus/engine/dist/translator/enterTextAction.d.ts +5 -0
  232. package/node_modules/@octopus/engine/dist/translator/enterTextAction.js +1 -0
  233. package/node_modules/@octopus/engine/dist/translator/extractDataAction.d.ts +13 -0
  234. package/node_modules/@octopus/engine/dist/translator/extractDataAction.js +1 -0
  235. package/node_modules/@octopus/engine/dist/translator/loopAction.d.ts +5 -0
  236. package/node_modules/@octopus/engine/dist/translator/loopAction.js +1 -0
  237. package/node_modules/@octopus/engine/dist/translator/mouseOverAction.d.ts +5 -0
  238. package/node_modules/@octopus/engine/dist/translator/mouseOverAction.js +19 -0
  239. package/node_modules/@octopus/engine/dist/translator/navigateAction.d.ts +5 -0
  240. package/node_modules/@octopus/engine/dist/translator/navigateAction.js +117 -0
  241. package/node_modules/@octopus/engine/dist/translator/rootAction.d.ts +6 -0
  242. package/node_modules/@octopus/engine/dist/translator/rootAction.js +80 -0
  243. package/node_modules/@octopus/engine/dist/translator/switchCombo2Action.d.ts +5 -0
  244. package/node_modules/@octopus/engine/dist/translator/switchCombo2Action.js +19 -0
  245. package/node_modules/@octopus/engine/dist/translator/translator.d.ts +1 -0
  246. package/node_modules/@octopus/engine/dist/translator/translator.js +36 -0
  247. package/node_modules/@octopus/engine/dist/type.d.ts +25 -0
  248. package/node_modules/@octopus/engine/dist/type.js +2 -0
  249. package/node_modules/@octopus/engine/dist/types/browser.d.ts +191 -0
  250. package/node_modules/@octopus/engine/dist/types/browser.js +1 -0
  251. package/node_modules/@octopus/engine/dist/types/browserManager.d.ts +41 -0
  252. package/node_modules/@octopus/engine/dist/types/browserManager.js +1 -0
  253. package/node_modules/@octopus/engine/dist/types/index.d.ts +40 -0
  254. package/node_modules/@octopus/engine/dist/types/index.js +2 -0
  255. package/node_modules/@octopus/engine/dist/types/plugin.d.ts +29 -0
  256. package/node_modules/@octopus/engine/dist/types/plugin.js +2 -0
  257. package/node_modules/@octopus/engine/dist/utils/AsyncEmitter.d.ts +15 -0
  258. package/node_modules/@octopus/engine/dist/utils/AsyncEmitter.js +1 -0
  259. package/node_modules/@octopus/engine/dist/utils/DataStore.d.ts +58 -0
  260. package/node_modules/@octopus/engine/dist/utils/DataStore.js +1 -0
  261. package/node_modules/@octopus/engine/dist/utils/DateTimeFormatHelper.d.ts +22 -0
  262. package/node_modules/@octopus/engine/dist/utils/DateTimeFormatHelper.js +173 -0
  263. package/node_modules/@octopus/engine/dist/utils/FileDownloader.d.ts +108 -0
  264. package/node_modules/@octopus/engine/dist/utils/FileDownloader.js +1 -0
  265. package/node_modules/@octopus/engine/dist/utils/HttpRequester.d.ts +43 -0
  266. package/node_modules/@octopus/engine/dist/utils/HttpRequester.js +174 -0
  267. package/node_modules/@octopus/engine/dist/utils/JsonParser.d.ts +95 -0
  268. package/node_modules/@octopus/engine/dist/utils/JsonParser.js +439 -0
  269. package/node_modules/@octopus/engine/dist/utils/Operations.d.ts +27 -0
  270. package/node_modules/@octopus/engine/dist/utils/Operations.js +115 -0
  271. package/node_modules/@octopus/engine/dist/utils/index.d.ts +28 -0
  272. package/node_modules/@octopus/engine/dist/utils/index.js +356 -0
  273. package/node_modules/@octopus/engine/package.json +58 -0
  274. package/package.json +79 -0
  275. package/schemas/capabilities-v1.schema.json +234 -0
  276. package/schemas/detached-bootstrap-v1.schema.json +42 -0
  277. package/schemas/json-envelope-v1.schema.json +39 -0
  278. package/schemas/run-event-v1.schema.json +47 -0
@@ -0,0 +1,607 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const LoopStartConfig_1 = __importDefault(require("../configs/LoopStartConfig"));
7
+ const enums_1 = require("../enums");
8
+ const actionItem_1 = require("../models/actionItem");
9
+ const Operations_1 = require("../utils/Operations");
10
+ const BaseAction_1 = __importDefault(require("./BaseAction"));
11
+ class LoopStartAction extends BaseAction_1.default {
12
+ constructor() {
13
+ super(...arguments);
14
+ this.loopXpathNextWait = new Map();
15
+ }
16
+ async readLoopItemText(actionItem, timeout = 0) {
17
+ // 保持旧语义:优先走 page / Puppeteer 提取。
18
+ // bridge 只作为 fallback,用来兜住 rebrowser context 短暂不可用的窗口。
19
+ if (timeout > 0) {
20
+ await (0, Operations_1.queryElement)(actionItem, this.page, timeout);
21
+ }
22
+ try {
23
+ return await (0, Operations_1.processElement)(actionItem, this.page, '$eval', (ele) => ele.innerText);
24
+ }
25
+ catch (error) {
26
+ if (!(0, Operations_1.isTransientContextError)(error) || !this.useExtensionBridge) {
27
+ throw error;
28
+ }
29
+ const tabId = await this.getTabIdForPage(this.page);
30
+ if (tabId !== undefined) {
31
+ const result = await this.browserProxy.extensionBridge.sendActionCommand({
32
+ action: 'extract',
33
+ tabId,
34
+ frame: actionItem.IsIFrame
35
+ ? {
36
+ isIframe: true,
37
+ iframeXpath: actionItem.IFrameAbsXPath
38
+ }
39
+ : { isIframe: false },
40
+ target: {
41
+ type: 'xpath',
42
+ xpath: actionItem.AbsXpath
43
+ },
44
+ payload: {
45
+ mode: 'text'
46
+ }
47
+ });
48
+ if (!result.success) {
49
+ throw new Error('error' in result ? result.error : 'bridge extract failed');
50
+ }
51
+ const data = result.data;
52
+ const value = typeof (data === null || data === void 0 ? void 0 : data.value) === 'string' ? data.value : '';
53
+ return value;
54
+ }
55
+ throw error;
56
+ }
57
+ }
58
+ async loopElementExists(actionItem, timeout = 0) {
59
+ // 先按原来 page / Puppeteer 的方式判断存在性;
60
+ // 只有 queryElement 因 execution context 抖动失败时,才退到 bridge 探针。
61
+ try {
62
+ const element = await (0, Operations_1.queryElement)(actionItem, this.page, timeout);
63
+ return !!element;
64
+ }
65
+ catch (error) {
66
+ if (!(0, Operations_1.isTransientContextError)(error) || !this.useExtensionBridge) {
67
+ throw error;
68
+ }
69
+ if (timeout > 0) {
70
+ const bridgeExists = await this.bridgeElementExists(this.page, actionItem, timeout);
71
+ if (bridgeExists !== undefined) {
72
+ return bridgeExists;
73
+ }
74
+ }
75
+ const tabId = await this.getTabIdForPage(this.page);
76
+ if (tabId !== undefined) {
77
+ const result = await this.browserProxy.extensionBridge.sendActionCommand({
78
+ action: 'extract',
79
+ tabId,
80
+ frame: actionItem.IsIFrame
81
+ ? {
82
+ isIframe: true,
83
+ iframeXpath: actionItem.IFrameAbsXPath
84
+ }
85
+ : { isIframe: false },
86
+ target: {
87
+ type: 'xpath',
88
+ xpath: actionItem.AbsXpath
89
+ },
90
+ payload: {
91
+ mode: 'text'
92
+ }
93
+ });
94
+ if (result.success) {
95
+ return true;
96
+ }
97
+ const errorMessage = 'error' in result ? result.error : 'bridge exists failed';
98
+ const bridgeExists = errorMessage.includes('Element not found')
99
+ ? false
100
+ : undefined;
101
+ if (bridgeExists !== undefined) {
102
+ return bridgeExists;
103
+ }
104
+ }
105
+ throw error;
106
+ }
107
+ }
108
+ parseConfig() {
109
+ return new LoopStartConfig_1.default(this.execution.activity.$attrs);
110
+ }
111
+ async wait() {
112
+ if (!this.getIsOnlySkipOneLoop() && this.getIsSkipCurrentLoop()) {
113
+ this.finish();
114
+ return;
115
+ }
116
+ // 设置子循环是否跳过
117
+ this.setIsSkipActionUtilNextLoop(this.getNodeId(), false);
118
+ // 仅跳过一次,需要清除本次不跳过
119
+ this.resetIsOnlySkipOneLoop();
120
+ // this.task = task
121
+ // let loopConfig = this.basicConfig as LoopStartConfig
122
+ // 获取任务parentid,本次循环的id
123
+ const parentid = this.activity.parentContext.id;
124
+ // 从中获取一条循环元素
125
+ const line = this.popLoopValue(parentid);
126
+ // 循环增加一次
127
+ this.addLoopCount(parentid);
128
+ if (!line) {
129
+ this.setIsSkipCurrentLoop(parentid, true);
130
+ this.error(enums_1.LogKey.Loop.Error, this.name);
131
+ this.finish();
132
+ return;
133
+ }
134
+ if (this.config.loopType !== "FixedItem" /* LoopType.FixedItem */ &&
135
+ this.config.loopType !== "ScrollWeb" /* LoopType.ScrollWeb */) {
136
+ this.log(enums_1.LogKey.Loop.Action, this.name, this.getLoopCount(parentid));
137
+ }
138
+ // 设置为不跳过
139
+ this.setIsSkipCurrentLoop(parentid, false);
140
+ this.page = await this.getCurrentPage();
141
+ switch (this.config.loopType) {
142
+ case "FixedItem" /* LoopType.FixedItem */:
143
+ {
144
+ this.setCurrentLoopValue(parentid, line);
145
+ if (this.browserProxy.navigateType == "OpenJson" /* NavigateType.OpenJson */) {
146
+ // JSON 模式:使用 jsonParser 检查节点是否存在
147
+ const nextnode = this.browserProxy.jsonParser.getNode(line.AbsXpath);
148
+ if (nextnode) {
149
+ this.pushLoopValue(parentid, line);
150
+ }
151
+ }
152
+ else {
153
+ try {
154
+ const ele = await (0, Operations_1.queryElement)(line, this.page, this.shouldWait ? 1500 : 0);
155
+ if (ele)
156
+ this.pushLoopValue(parentid, line);
157
+ }
158
+ catch (error) {
159
+ await this.checkPause();
160
+ console.log('固定元素当前循环', error === null || error === void 0 ? void 0 : error.message);
161
+ }
162
+ // 停止无效点击翻页判断
163
+ await this.stopInvalidClickPage(parentid, this.config, this.page);
164
+ }
165
+ }
166
+ break;
167
+ case "FixedItemList" /* LoopType.FixedItemList */:
168
+ case "URLList" /* LoopType.URLList */:
169
+ case "TextList" /* LoopType.TextList */:
170
+ {
171
+ this.setCurrentLoopValue(parentid, line);
172
+ }
173
+ break;
174
+ case "VarilableItemList" /* LoopType.VarilableItemList */:
175
+ {
176
+ if (this.browserProxy.navigateType == "OpenJson" /* NavigateType.OpenJson */) {
177
+ // JSON 模式处理
178
+ let startIndex = line.AbsXpath.lastIndexOf('[*]');
179
+ if (startIndex < 0) {
180
+ startIndex = line.AbsXpath.length;
181
+ }
182
+ // 当前循环项的 JSONPath
183
+ const thisXpath = line.AbsXpath.substring(0, startIndex) +
184
+ '[' +
185
+ this.variables.index +
186
+ ']';
187
+ this.setCurrentLoopValue(parentid, new actionItem_1.ActionItem(thisXpath, line.IsIFrame, line.IFrameAbsXPath));
188
+ // 判断下一个循环的 JSONPath 对应节点是否存在
189
+ const nextXpath = line.AbsXpath.substring(0, startIndex) +
190
+ '[' +
191
+ (this.variables.index + 1) +
192
+ ']';
193
+ const nextnode = this.browserProxy.jsonParser.getNode(nextXpath);
194
+ if (nextnode) {
195
+ this.pushLoopValue(parentid, line);
196
+ }
197
+ }
198
+ else {
199
+ // 网页模式处理
200
+ const loopOffset = this.getNextLoopOffset(parentid) || 0;
201
+ const eleIndex = this.variables.index +
202
+ this.getIdentifiedEachLoopExtractDataCount(parentid) +
203
+ 1 +
204
+ loopOffset;
205
+ const currentItem = `(${line.AbsXpath})[${eleIndex}]`;
206
+ try {
207
+ const sampleCurrentItem = new actionItem_1.ActionItem(currentItem, line.IsIFrame, line.IFrameAbsXPath);
208
+ // 当前项读取成功之后,说明本轮索引已经稳定,
209
+ // 要清掉之前因为瞬时上下文异常留下的偏移量,避免一直向负方向漂移。
210
+ const sample = await this.readLoopItemText(sampleCurrentItem, this.shouldWait ? 1500 : 0);
211
+ if (loopOffset !== 0) {
212
+ this.resetNextLoopOffset(parentid);
213
+ }
214
+ this.setCurrentLoopValue(parentid, new actionItem_1.ActionItem(currentItem, line.IsIFrame, line.IFrameAbsXPath));
215
+ if (sample) {
216
+ this.countSomeLoopExtractDataNum(parentid);
217
+ this.setSamplingElementsMap(parentid, new Map([[eleIndex, sample]])); // 将抽样数据记录下来
218
+ }
219
+ }
220
+ catch (er) {
221
+ await this.checkPause();
222
+ if ((0, Operations_1.isTransientContextError)(er)) {
223
+ this.setIsSkipActionUtilNextLoop(parentid, true);
224
+ this.pushLoopValue(parentid, line);
225
+ }
226
+ else {
227
+ this.setIsSkipCurrentLoop(parentid, true);
228
+ }
229
+ break;
230
+ }
231
+ try {
232
+ const nextElement = eleIndex + 1;
233
+ const lineActionItem = new actionItem_1.ActionItem(`(${line.AbsXpath})[${nextElement}]`, line.IsIFrame, line.IFrameAbsXPath);
234
+ const existNextElement = await this.loopElementExists(lineActionItem, this.shouldWait ? 1500 : 0);
235
+ if (existNextElement) {
236
+ this.pushLoopValue(parentid, line);
237
+ }
238
+ else {
239
+ this.saveSampedLoopRecord({
240
+ parentid,
241
+ AbsXpath: line.AbsXpath,
242
+ IsIFrame: line.IsIFrame,
243
+ IFrameAbsXPath: line.IFrameAbsXPath
244
+ });
245
+ await this.cacheCurLoopSampleElenemts({
246
+ AbsXpath: line.AbsXpath,
247
+ IsIFrame: line.IsIFrame,
248
+ IFrameAbsXPath: line.IFrameAbsXPath,
249
+ nodeId: parentid,
250
+ newXpathStartIndex: nextElement
251
+ }, this.page);
252
+ }
253
+ }
254
+ catch (er) {
255
+ await this.checkPause();
256
+ if ((0, Operations_1.isTransientContextError)(er)) {
257
+ // 当前项已经成功解析,这里只是不确定“下一项是否存在”。
258
+ // 保留当前项给后续提取步骤使用,并把基列表项压回去,
259
+ // 让下一轮从自然递增的索引继续,不再写负 offset。
260
+ this.pushLoopValue(parentid, line);
261
+ }
262
+ }
263
+ }
264
+ }
265
+ break;
266
+ case "ScrollWeb" /* LoopType.ScrollWeb */:
267
+ {
268
+ try {
269
+ const { scrollType, scrollTime, scrollInterval, scrollXPath, IfStopScroll } = this.config;
270
+ const loopCount = this.getLoopCount(parentid);
271
+ if (loopCount === 1) {
272
+ this.initContinuousScrollTopFixedWebCount(parentid);
273
+ this.setWebScrollTopTemp(parentid, 0);
274
+ }
275
+ if (scrollXPath) {
276
+ await (0, Operations_1.queryElement)(scrollXPath, this.page, this.shouldWait ? 1500 : 0);
277
+ await (0, Operations_1.processElement)(scrollXPath, this.page, '$eval', (ele, scrollScreen) => {
278
+ scrollScreen
279
+ ? ele.scrollBy(0, ele.offsetHeight)
280
+ : ele.scrollTo({ top: ele.scrollHeight });
281
+ }, scrollType == 1 /* ScrollType.ScrollOneScreen */);
282
+ // await this.page.$eval(
283
+ // `::-p-xpath(${scrollXPath.AbsXpath})`,
284
+ // (ele, scrollScreen) => {
285
+ // scrollScreen ? (ele as HTMLElement).scrollBy(0, (ele as HTMLElement).offsetHeight) : ele.scrollTo({ top: ele.scrollHeight })
286
+ // },
287
+ // scrollType == ScrollType.ScrollOneScreen
288
+ // )
289
+ scrollType == 1 /* ScrollType.ScrollOneScreen */
290
+ ? this.log(enums_1.LogKey.Common.Scroll.Local.Screen, this.name, loopCount)
291
+ : this.log(enums_1.LogKey.Common.Scroll.Local.Bottom, this.name, loopCount);
292
+ }
293
+ else {
294
+ await this.page.evaluate((scrollScreen) => {
295
+ scrollScreen
296
+ ? document.scrollingElement.scrollBy(0, globalThis.window.innerHeight)
297
+ : document.scrollingElement.scrollTo({
298
+ top: globalThis.document.body.scrollHeight,
299
+ behavior: 'auto'
300
+ });
301
+ }, scrollType == 1 /* ScrollType.ScrollOneScreen */);
302
+ scrollType == 1 /* ScrollType.ScrollOneScreen */
303
+ ? this.log(enums_1.LogKey.Common.Scroll.Global.Screen, this.name, loopCount)
304
+ : this.log(enums_1.LogKey.Common.Scroll.Global.Bottom, this.name, loopCount);
305
+ }
306
+ /** 下一次滚动间隔时间,如果只滚动一次就不需要多余等待了 */
307
+ if (scrollInterval > 0 && scrollTime > 1) {
308
+ await this.sleep(scrollInterval);
309
+ await this.checkPause();
310
+ }
311
+ /** 判定无内容更新时结束滚动,通过判断滑动高度无变化 3 次,则认为无内容更新 */
312
+ if (IfStopScroll) {
313
+ const scrollHeight = this.getWebScrollTopTemp(parentid);
314
+ let scrollTop = await this.page.evaluate(() => {
315
+ return Math.max(document.documentElement.scrollTop, (document.body && document.body.scrollTop) || 0);
316
+ });
317
+ if (scrollXPath === null || scrollXPath === void 0 ? void 0 : scrollXPath.AbsXpath) {
318
+ // scrollTop = await this.page.$eval(`::-p-xpath(${scrollXPath.AbsXpath})`, (ele) => ele.scrollTop)
319
+ scrollTop = await (0, Operations_1.processElement)(scrollXPath, this.page, '$eval', (ele) => ele.scrollTop);
320
+ }
321
+ if (scrollHeight === scrollTop) {
322
+ this.addContinuousScrollTopFixedWebCount(parentid);
323
+ if (this.getContinuousScrollTopFixedWebCount(parentid) > 3)
324
+ break;
325
+ }
326
+ this.setWebScrollTopTemp(parentid, scrollTop);
327
+ }
328
+ if (loopCount < scrollTime)
329
+ this.pushLoopValue(parentid, ['ScrollWeb']);
330
+ }
331
+ catch (error) {
332
+ await this.checkPause();
333
+ console.log('未找到元素');
334
+ }
335
+ }
336
+ break;
337
+ }
338
+ this.finish();
339
+ }
340
+ isWaitPathByMaxIndex(key, currentIndex) {
341
+ let currentMax = this.loopXpathNextWait.get(key);
342
+ if (currentMax === undefined) {
343
+ currentMax = -1;
344
+ }
345
+ if (currentMax === -1) {
346
+ this.loopXpathNextWait.set(key, currentIndex);
347
+ return true;
348
+ }
349
+ if (currentMax > currentIndex) {
350
+ return true;
351
+ }
352
+ else if (currentMax < currentIndex) {
353
+ this.loopXpathNextWait.set(key, currentIndex);
354
+ }
355
+ return false;
356
+ }
357
+ /**
358
+ * 停止无效点击翻页判断
359
+ * @param parentid
360
+ * @param loopConfig
361
+ */
362
+ async stopInvalidClickPage(parentid, loopConfig, page) {
363
+ // 每次点击一个循环大概是69毫秒,如果是多个的话是倍速关系s
364
+ if (this.parent && this.browserProxy.workflowSetting) {
365
+ const parentLoopActionConfig = this.parent.config;
366
+ const parentLoopCount = this.getLoopCount(this.parent.id);
367
+ if (parentLoopActionConfig.checkedJumpLoopClick &&
368
+ parentLoopCount > this.browserProxy.workflowSetting.repeatPageLoopCount) {
369
+ const location = await page.evaluate(() => {
370
+ return globalThis.location;
371
+ });
372
+ const referrer = await page.evaluate(() => {
373
+ return globalThis.document.referrer;
374
+ });
375
+ const currentUrl = location.href;
376
+ let isCurrentAndReferrer = false;
377
+ //两个页面的链接相同
378
+ if (referrer !== '' &&
379
+ referrer === currentUrl &&
380
+ location.hash === '') {
381
+ isCurrentAndReferrer = true;
382
+ this.setLoopValues(parentid, []);
383
+ }
384
+ // 如果是一页的情况,那么会出现不能终止的问题
385
+ // else{
386
+ // this.initContinuousInvalidPageCount(parentid);
387
+ // }
388
+ const sampedLoopRecord = this.getSampedLoopRecord();
389
+ if (sampedLoopRecord &&
390
+ Object.keys(sampedLoopRecord) &&
391
+ Object.keys(sampedLoopRecord).length !== 0) {
392
+ let stopLoop = true;
393
+ for (const key in sampedLoopRecord) {
394
+ const configOptions = {
395
+ AbsXpath: sampedLoopRecord[key].AbsXpath,
396
+ IsIFrame: sampedLoopRecord[key].IsIFrame,
397
+ IFrameAbsXPath: sampedLoopRecord[key].IFrameAbsXPath,
398
+ newXpathStartIndex: this.getSomeLoopExtractDataCount(key)
399
+ };
400
+ const nextElement = await this.ifNextElement(configOptions, page);
401
+ let diff = false;
402
+ if (this.getCurrentLoopUrl(key)) {
403
+ const url = page.url();
404
+ if (this.getCurrentLoopUrl(key) != url) {
405
+ diff = true;
406
+ }
407
+ }
408
+ const loopConfig = sampedLoopRecord[key];
409
+ if (loopConfig && loopConfig.AbsXpath) {
410
+ const sample = this.getSamplingElementsMap(key);
411
+ if (sample.size > 0) {
412
+ for (const [key, value] of sample) {
413
+ const thisElement = {
414
+ ...this.config.variableList,
415
+ AbsXpath: '(' + loopConfig.AbsXpath + ')[' + key + ']'
416
+ };
417
+ const isExist = await (0, Operations_1.queryElement)(thisElement, this.page, this.shouldWait ? 1500 : 0);
418
+ if (!isExist) {
419
+ continue;
420
+ }
421
+ const text = await (0, Operations_1.processElement)(thisElement, this.page, '$eval', (ele) => (ele === null || ele === void 0 ? void 0 : ele.innerText) || ele.textContent);
422
+ if (this.similar(value.replace(/[\r\n\s]/g, ''), text.replace(/[\r\n\s]/g, ''), 2) < 0.95) {
423
+ diff = true; //说明前面的列表数据有变化
424
+ break;
425
+ }
426
+ }
427
+ }
428
+ }
429
+ if (nextElement || diff) {
430
+ stopLoop = false;
431
+ break;
432
+ }
433
+ }
434
+ if (stopLoop) {
435
+ this.addContinuousInvalidPageCount(parentid);
436
+ }
437
+ else {
438
+ //初始化之后不做判断
439
+ this.initContinuousInvalidPageCount(parentid);
440
+ return;
441
+ }
442
+ const invalidPageCount = this.getContinuousInvalidPageCount(parentid);
443
+ if ((stopLoop &&
444
+ invalidPageCount >=
445
+ this.browserProxy.workflowSetting.continuousJudgeCount) ||
446
+ (isCurrentAndReferrer && stopLoop)) {
447
+ this.setIsSkipCurrentLoop(parentid, true);
448
+ }
449
+ }
450
+ }
451
+ const element = await (0, Operations_1.queryElement)(loopConfig.fixedItem, page);
452
+ const isVisible = await (element === null || element === void 0 ? void 0 : element.isVisible());
453
+ if (!isVisible) {
454
+ this.setLoopValues(parentid, []);
455
+ }
456
+ }
457
+ }
458
+ /**
459
+ * 生成随机采样数据需要的数据坐标
460
+ * @param currentIndex 抽样前多少条数据条目(数据模板)
461
+ * @param m 抽样的数据条目
462
+ */
463
+ getRandomArrayElements(currentIndex, m = 5) {
464
+ if (currentIndex <= 0) {
465
+ return [];
466
+ }
467
+ if (currentIndex === 1) {
468
+ return [currentIndex];
469
+ }
470
+ const array = [...new Array(currentIndex).keys()];
471
+ array.shift();
472
+ const result = [];
473
+ const ranNum = Math.min(currentIndex, m);
474
+ for (let i = 0; i < ranNum; i++) {
475
+ const ran = Math.floor(Math.random() * (array.length - i));
476
+ result.push(array[ran]);
477
+ array[ran] = array[array.length - i - 1];
478
+ }
479
+ return result;
480
+ }
481
+ /**
482
+ * 指定循环采集数据步骤完成后进行数据采样并存储
483
+ * @param params
484
+ */
485
+ async cacheCurLoopSampleElenemts(params, page) {
486
+ const AbsXpath = params.AbsXpath;
487
+ const IsIFrame = params.IsIFrame;
488
+ const IFrameAbsXPath = params.IFrameAbsXPath;
489
+ const newmap = new Map();
490
+ const needle = this.getRandomArrayElements(params.newXpathStartIndex, 4);
491
+ if (needle.length > 0) {
492
+ for (const index of needle) {
493
+ const thisXpath = '(' + AbsXpath + ')[' + index + ']';
494
+ const text = await this.readLoopItemText(new actionItem_1.ActionItem(thisXpath, IsIFrame, IFrameAbsXPath));
495
+ newmap.set(index, text);
496
+ }
497
+ this.setSamplingElementsMap(params.nodeId, newmap); // 将抽样数据记录下来
498
+ try {
499
+ this.setCurrentLoopUrl(params.nodeId, page.url());
500
+ }
501
+ catch {
502
+ // processEventCenter.publish(PROCESS_EVENT.Action.Loop, this.id, this.actionType, '获取当前的url失败')
503
+ }
504
+ }
505
+ }
506
+ /**
507
+ * 对比指定的不固定循环列表元素是否变化
508
+ * @param nodeId
509
+ * @param loopConfig
510
+ */
511
+ async diffSamplingElements(nodeId, loopConfig) {
512
+ if (this.getCurrentLoopUrl(nodeId)) {
513
+ // var url = this.workflow.browser.getURL()
514
+ // if (this.getCurrentLoopUrl(nodeId) != url) {
515
+ // return true
516
+ // }
517
+ }
518
+ const AbsXpath = loopConfig.AbsXpath;
519
+ const IsIFrame = loopConfig.IsIFrame;
520
+ const IFrameAbsXPath = loopConfig.IFrameAbsXPath;
521
+ const flag = false;
522
+ const samplingElementsMap = this.getSamplingElementsMap(nodeId);
523
+ // if (samplingElementsMap.size > 0) {
524
+ // for (const [key, value] of samplingElementsMap) {
525
+ // const xpath = `(${AbsXpath})[${key}]`
526
+ // const actionItem = new ActionItem(xpath, IsIFrame, IFrameAbsXPath)
527
+ // const currentText = await this.workflow.browser.getInnerText(actionItem)
528
+ // /** 相似度比对 */
529
+ // if (this.similar(value.replace(/[\r\n\s]/g, ''), currentText.replace(/[\r\n\s]/g, ''), 2) < 0.95) {
530
+ // // 说明前面遍历过的元素有变动,将该轮循环的偏移量置零
531
+ // // console.log(value.replace(/[\r\n]/g,'') +'--------不相同-------'+ curVal.replace(/[\r\n]/g,''))
532
+ // falg = true //说明前面的列表数据有变化
533
+ // break
534
+ // }
535
+ // /** 全比对 */
536
+ // // if(value.replace(/[\r\n]/g,'') != curVal.replace(/[\r\n]/g,'')){
537
+ // // // 说明前面遍历过的元素有变动,将该轮循环的偏移量置零
538
+ // // console.log(value.replace(/[\r\n]/g,'') +'--------不相同-------'+ curVal.replace(/[\r\n]/g,''))
539
+ // // falg = true //说明前面的列表数据有变化
540
+ // // break;
541
+ // // }
542
+ // }
543
+ // }
544
+ return flag;
545
+ }
546
+ /**
547
+ * 辅助判断当前循环列表所依赖的列表元素是否有增加
548
+ * @param loopConfig
549
+ */
550
+ async ifNextElement(loopConfig, page) {
551
+ const AbsXpath = loopConfig.AbsXpath;
552
+ const IsIFrame = loopConfig.IsIFrame;
553
+ const IFrameAbsXPath = loopConfig.IFrameAbsXPath;
554
+ const newXpathStartIndex = loopConfig.newXpathStartIndex;
555
+ //判断下一个循环的xpath对应元素是否存在,存在则把line重新压入队列中以使循环能够继续执行
556
+ const nextXpath = '(' + AbsXpath + ')[' + (newXpathStartIndex + 1) + ']';
557
+ const isExist = await this.loopElementExists(new actionItem_1.ActionItem(nextXpath, IsIFrame, IFrameAbsXPath));
558
+ return isExist;
559
+ }
560
+ /**
561
+ * 辅助判断字符串相似度
562
+ * @param s 字符串1
563
+ * @param t 字符串1
564
+ * @param f 精确度:保留几位小数
565
+ */
566
+ similar(s, t, f) {
567
+ if (!s || !t) {
568
+ return 0;
569
+ }
570
+ const l = s.length > t.length ? s.length : t.length;
571
+ const n = s.length;
572
+ const m = t.length;
573
+ const d = [];
574
+ f = f || 3;
575
+ const min = function (a, b, c) {
576
+ return a < b ? (a < c ? a : c) : b < c ? b : c;
577
+ };
578
+ let i, j, si, tj, cost;
579
+ if (n === 0)
580
+ return m;
581
+ if (m === 0)
582
+ return n;
583
+ for (i = 0; i <= n; i++) {
584
+ d[i] = [];
585
+ d[i][0] = i;
586
+ }
587
+ for (j = 0; j <= m; j++) {
588
+ d[0][j] = j;
589
+ }
590
+ for (i = 1; i <= n; i++) {
591
+ si = s.charAt(i - 1);
592
+ for (j = 1; j <= m; j++) {
593
+ tj = t.charAt(j - 1);
594
+ if (si === tj) {
595
+ cost = 0;
596
+ }
597
+ else {
598
+ cost = 1;
599
+ }
600
+ d[i][j] = min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + cost);
601
+ }
602
+ }
603
+ const res = 1 - d[n][m] / l;
604
+ return res.toFixed(f);
605
+ }
606
+ }
607
+ exports.default = LoopStartAction;
@@ -0,0 +1,8 @@
1
+ import MouseOverConfig from '../configs/MouseOverConfig';
2
+ import BaseAction from './BaseAction';
3
+ export default class MouseOverAction extends BaseAction {
4
+ config: MouseOverConfig;
5
+ private page;
6
+ protected parseConfig(config: any): MouseOverConfig;
7
+ wait(): Promise<void>;
8
+ }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const MouseOverConfig_1 = __importDefault(require("../configs/MouseOverConfig"));
7
+ const enums_1 = require("../enums");
8
+ const actionItem_1 = require("../models/actionItem");
9
+ const BaseAction_1 = __importDefault(require("./BaseAction"));
10
+ class MouseOverAction extends BaseAction_1.default {
11
+ parseConfig(config) {
12
+ return new MouseOverConfig_1.default(config);
13
+ }
14
+ async wait() {
15
+ if (this.getIsSkipCurrentLoop() || this.getIsSkipActionUtilNextLoop(this.getNodeId())) {
16
+ this.finish();
17
+ return;
18
+ }
19
+ await super.wait();
20
+ let actionItem = this.config.elementXPath;
21
+ if (this.config.useLoopItem) {
22
+ const { AbsXpath, IsIFrame, IFrameAbsXPath } = this.getCurrentLoopValue();
23
+ actionItem = new actionItem_1.ActionItem(AbsXpath + actionItem.AbsXpath, IsIFrame, IFrameAbsXPath);
24
+ }
25
+ this.page = await this.getCurrentPage();
26
+ (await this.locator(this.page, actionItem)).hover();
27
+ this.log(enums_1.LogKey.MouseOver.Begin, this.name, actionItem.AbsXpath);
28
+ // await this.workflow.browser.scrollIntoView(actionItem)
29
+ // await this.workflow.browser.mouseOver(actionItem)
30
+ await this.ajax();
31
+ this.finish();
32
+ }
33
+ }
34
+ exports.default = MouseOverAction;