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.
- package/README.md +271 -0
- package/RUNTIME_SECURITY_NOTICE.txt +41 -0
- package/SECURITY.md +24 -0
- package/dist/cli/args.js +34 -0
- package/dist/cli/help.js +214 -0
- package/dist/cli/output.js +39 -0
- package/dist/commands/auth.js +283 -0
- package/dist/commands/capabilities.js +118 -0
- package/dist/commands/cloud.js +241 -0
- package/dist/commands/data.js +220 -0
- package/dist/commands/doctor.js +73 -0
- package/dist/commands/env.js +63 -0
- package/dist/commands/local.js +251 -0
- package/dist/commands/run.js +622 -0
- package/dist/commands/runs.js +171 -0
- package/dist/commands/task.js +101 -0
- package/dist/index.js +133 -0
- package/dist/runtime/account-capabilities.js +71 -0
- package/dist/runtime/api-client.js +290 -0
- package/dist/runtime/artifacts.js +33 -0
- package/dist/runtime/auth.js +94 -0
- package/dist/runtime/bridge-hub.js +173 -0
- package/dist/runtime/client-headers.js +23 -0
- package/dist/runtime/cloud-data.js +75 -0
- package/dist/runtime/config.js +48 -0
- package/dist/runtime/data-exporter.js +267 -0
- package/dist/runtime/engine-host.js +449 -0
- package/dist/runtime/local-runs.js +92 -0
- package/dist/runtime/naming.js +13 -0
- package/dist/runtime/run-control.js +363 -0
- package/dist/runtime/run-services.js +380 -0
- package/dist/runtime/security-notice.js +78 -0
- package/dist/runtime/task-definition-provider.js +282 -0
- package/dist/types.js +4 -0
- package/examples/minimal-task.json +6 -0
- package/examples/navigate-example-task.json +6 -0
- package/node_modules/@octopus/bpmn/index.js +3 -0
- package/node_modules/@octopus/bpmn/lib/Context.js +245 -0
- package/node_modules/@octopus/bpmn/lib/Definition.js +258 -0
- package/node_modules/@octopus/bpmn/lib/Engine.js +275 -0
- package/node_modules/@octopus/bpmn/lib/PrematureStopError.js +7 -0
- package/node_modules/@octopus/bpmn/lib/activities/Activity.js +202 -0
- package/node_modules/@octopus/bpmn/lib/activities/BaseProcess.js +308 -0
- package/node_modules/@octopus/bpmn/lib/activities/BaseTask.js +145 -0
- package/node_modules/@octopus/bpmn/lib/activities/BoundaryEvent.js +12 -0
- package/node_modules/@octopus/bpmn/lib/activities/Dummy.js +10 -0
- package/node_modules/@octopus/bpmn/lib/activities/EventDefinition.js +99 -0
- package/node_modules/@octopus/bpmn/lib/activities/Flow.js +52 -0
- package/node_modules/@octopus/bpmn/lib/activities/Form.js +67 -0
- package/node_modules/@octopus/bpmn/lib/activities/InputOutput.js +53 -0
- package/node_modules/@octopus/bpmn/lib/activities/IntermediateCatchEvent.js +12 -0
- package/node_modules/@octopus/bpmn/lib/activities/MessageFlow.js +19 -0
- package/node_modules/@octopus/bpmn/lib/activities/MultiInstanceLoopCharacteristics.js +160 -0
- package/node_modules/@octopus/bpmn/lib/activities/Properties.js +27 -0
- package/node_modules/@octopus/bpmn/lib/activities/SequenceFlow.js +56 -0
- package/node_modules/@octopus/bpmn/lib/activities/ServiceConnector.js +71 -0
- package/node_modules/@octopus/bpmn/lib/context-helper.js +198 -0
- package/node_modules/@octopus/bpmn/lib/events/EndEvent.js +22 -0
- package/node_modules/@octopus/bpmn/lib/events/ErrorEvent.js +41 -0
- package/node_modules/@octopus/bpmn/lib/events/MessageEvent.js +19 -0
- package/node_modules/@octopus/bpmn/lib/events/StartEvent.js +55 -0
- package/node_modules/@octopus/bpmn/lib/events/TimerEvent.js +75 -0
- package/node_modules/@octopus/bpmn/lib/expressions.js +41 -0
- package/node_modules/@octopus/bpmn/lib/gateways/ExclusiveGateway.js +86 -0
- package/node_modules/@octopus/bpmn/lib/gateways/InclusiveGateway.js +56 -0
- package/node_modules/@octopus/bpmn/lib/gateways/ParallelGateway.js +195 -0
- package/node_modules/@octopus/bpmn/lib/getPropertyValue.js +83 -0
- package/node_modules/@octopus/bpmn/lib/index.js +6 -0
- package/node_modules/@octopus/bpmn/lib/mapper.js +55 -0
- package/node_modules/@octopus/bpmn/lib/parameter.js +119 -0
- package/node_modules/@octopus/bpmn/lib/script-helper.js +45 -0
- package/node_modules/@octopus/bpmn/lib/tasks/ManualTask.js +31 -0
- package/node_modules/@octopus/bpmn/lib/tasks/ReceiveTask.js +31 -0
- package/node_modules/@octopus/bpmn/lib/tasks/ScriptTask.js +35 -0
- package/node_modules/@octopus/bpmn/lib/tasks/SendTask.js +16 -0
- package/node_modules/@octopus/bpmn/lib/tasks/ServiceTask.js +68 -0
- package/node_modules/@octopus/bpmn/lib/tasks/SubProcess.js +17 -0
- package/node_modules/@octopus/bpmn/lib/tasks/Task.js +16 -0
- package/node_modules/@octopus/bpmn/lib/tasks/UserTask.js +47 -0
- package/node_modules/@octopus/bpmn/lib/transformer.js +13 -0
- package/node_modules/@octopus/bpmn/lib/validation.js +111 -0
- package/node_modules/@octopus/bpmn/package.json +17 -0
- package/node_modules/@octopus/bpmn/types/bpmn.d.ts +85 -0
- package/node_modules/@octopus/engine/README.md +370 -0
- package/node_modules/@octopus/engine/dist/actions/BackPreWebPageAction.d.ts +4 -0
- package/node_modules/@octopus/engine/dist/actions/BackPreWebPageAction.js +1 -0
- package/node_modules/@octopus/engine/dist/actions/BaseAction.d.ts +339 -0
- package/node_modules/@octopus/engine/dist/actions/BaseAction.js +1559 -0
- package/node_modules/@octopus/engine/dist/actions/BranchAction.d.ts +9 -0
- package/node_modules/@octopus/engine/dist/actions/BranchAction.js +1 -0
- package/node_modules/@octopus/engine/dist/actions/ClickAction.d.ts +22 -0
- package/node_modules/@octopus/engine/dist/actions/ClickAction.js +1 -0
- package/node_modules/@octopus/engine/dist/actions/ConditionAction.d.ts +4 -0
- package/node_modules/@octopus/engine/dist/actions/ConditionAction.js +1 -0
- package/node_modules/@octopus/engine/dist/actions/EmptyAction.d.ts +4 -0
- package/node_modules/@octopus/engine/dist/actions/EmptyAction.js +12 -0
- package/node_modules/@octopus/engine/dist/actions/EnterCaptchaAction.d.ts +28 -0
- package/node_modules/@octopus/engine/dist/actions/EnterCaptchaAction.js +1 -0
- package/node_modules/@octopus/engine/dist/actions/EnterTextAction.d.ts +20 -0
- package/node_modules/@octopus/engine/dist/actions/EnterTextAction.js +1 -0
- package/node_modules/@octopus/engine/dist/actions/ExtractDataAction.d.ts +40 -0
- package/node_modules/@octopus/engine/dist/actions/ExtractDataAction.js +1 -0
- package/node_modules/@octopus/engine/dist/actions/LoopAction.d.ts +41 -0
- package/node_modules/@octopus/engine/dist/actions/LoopAction.js +526 -0
- package/node_modules/@octopus/engine/dist/actions/LoopStartAction.d.ts +47 -0
- package/node_modules/@octopus/engine/dist/actions/LoopStartAction.js +607 -0
- package/node_modules/@octopus/engine/dist/actions/MouseOverAction.d.ts +8 -0
- package/node_modules/@octopus/engine/dist/actions/MouseOverAction.js +34 -0
- package/node_modules/@octopus/engine/dist/actions/NavigateAction.d.ts +38 -0
- package/node_modules/@octopus/engine/dist/actions/NavigateAction.js +535 -0
- package/node_modules/@octopus/engine/dist/actions/SwitchComboAction.d.ts +13 -0
- package/node_modules/@octopus/engine/dist/actions/SwitchComboAction.js +69 -0
- package/node_modules/@octopus/engine/dist/browser.d.ts +17 -0
- package/node_modules/@octopus/engine/dist/browser.js +157 -0
- package/node_modules/@octopus/engine/dist/browserProxy.d.ts +90 -0
- package/node_modules/@octopus/engine/dist/browserProxy.js +1 -0
- package/node_modules/@octopus/engine/dist/configs/BaseConfig.d.ts +20 -0
- package/node_modules/@octopus/engine/dist/configs/BaseConfig.js +88 -0
- package/node_modules/@octopus/engine/dist/configs/BranchConfig.d.ts +7 -0
- package/node_modules/@octopus/engine/dist/configs/BranchConfig.js +1 -0
- package/node_modules/@octopus/engine/dist/configs/ClickConfig.d.ts +36 -0
- package/node_modules/@octopus/engine/dist/configs/ClickConfig.js +65 -0
- package/node_modules/@octopus/engine/dist/configs/EnterCaptchaConfig.d.ts +19 -0
- package/node_modules/@octopus/engine/dist/configs/EnterCaptchaConfig.js +25 -0
- package/node_modules/@octopus/engine/dist/configs/EnterTextConfig.d.ts +24 -0
- package/node_modules/@octopus/engine/dist/configs/EnterTextConfig.js +36 -0
- package/node_modules/@octopus/engine/dist/configs/ExtractDataConfig.d.ts +12 -0
- package/node_modules/@octopus/engine/dist/configs/ExtractDataConfig.js +1 -0
- package/node_modules/@octopus/engine/dist/configs/LoopConfig.d.ts +25 -0
- package/node_modules/@octopus/engine/dist/configs/LoopConfig.js +40 -0
- package/node_modules/@octopus/engine/dist/configs/LoopStartConfig.d.ts +4 -0
- package/node_modules/@octopus/engine/dist/configs/LoopStartConfig.js +12 -0
- package/node_modules/@octopus/engine/dist/configs/MouseOverConfig.d.ts +8 -0
- package/node_modules/@octopus/engine/dist/configs/MouseOverConfig.js +15 -0
- package/node_modules/@octopus/engine/dist/configs/NavigateConfig.d.ts +41 -0
- package/node_modules/@octopus/engine/dist/configs/NavigateConfig.js +121 -0
- package/node_modules/@octopus/engine/dist/configs/SwitchComboConfig.d.ts +8 -0
- package/node_modules/@octopus/engine/dist/configs/SwitchComboConfig.js +15 -0
- package/node_modules/@octopus/engine/dist/enums/index.d.ts +419 -0
- package/node_modules/@octopus/engine/dist/enums/index.js +314 -0
- package/node_modules/@octopus/engine/dist/extension/BrowserWebSocketTransport-D_zAGZMQ.js +1 -0
- package/node_modules/@octopus/engine/dist/extension/LaunchOptions-DxvePrV4.js +6 -0
- package/node_modules/@octopus/engine/dist/extension/NodeWebSocketTransport-BTgRVB7Z.js +6 -0
- package/node_modules/@octopus/engine/dist/extension/background.js +396 -0
- package/node_modules/@octopus/engine/dist/extension/bidi-C_GIZ8Uz.js +131 -0
- package/node_modules/@octopus/engine/dist/extension/manifest.json +27 -0
- package/node_modules/@octopus/engine/dist/extension/src/content/anti-detection.js +1 -0
- package/node_modules/@octopus/engine/dist/extension-bridge/BaseExtensionBridge.d.ts +21 -0
- package/node_modules/@octopus/engine/dist/extension-bridge/BaseExtensionBridge.js +117 -0
- package/node_modules/@octopus/engine/dist/extension-bridge/SessionExtensionBridge.d.ts +17 -0
- package/node_modules/@octopus/engine/dist/extension-bridge/SessionExtensionBridge.js +29 -0
- package/node_modules/@octopus/engine/dist/extension-bridge/index.d.ts +2 -0
- package/node_modules/@octopus/engine/dist/extension-bridge/index.js +5 -0
- package/node_modules/@octopus/engine/dist/extension-bridge/types.d.ts +159 -0
- package/node_modules/@octopus/engine/dist/extension-bridge/types.js +5 -0
- package/node_modules/@octopus/engine/dist/extensions/ublock-origin/uBlock0.chromium.tar.xz +0 -0
- package/node_modules/@octopus/engine/dist/extensions/ublock-origin-lite/uBOLite.chromium.tar.xz +0 -0
- package/node_modules/@octopus/engine/dist/index.d.ts +169 -0
- package/node_modules/@octopus/engine/dist/index.js +1 -0
- package/node_modules/@octopus/engine/dist/models/actionItem.d.ts +16 -0
- package/node_modules/@octopus/engine/dist/models/actionItem.js +15 -0
- package/node_modules/@octopus/engine/dist/models/conditionCheckArgs.d.ts +11 -0
- package/node_modules/@octopus/engine/dist/models/conditionCheckArgs.js +11 -0
- package/node_modules/@octopus/engine/dist/models/customizeCookie.d.ts +14 -0
- package/node_modules/@octopus/engine/dist/models/customizeCookie.js +6 -0
- package/node_modules/@octopus/engine/dist/models/downloadFileConfig.d.ts +17 -0
- package/node_modules/@octopus/engine/dist/models/downloadFileConfig.js +26 -0
- package/node_modules/@octopus/engine/dist/models/elementNotFoundArgs.d.ts +8 -0
- package/node_modules/@octopus/engine/dist/models/elementNotFoundArgs.js +12 -0
- package/node_modules/@octopus/engine/dist/models/elementNotFoundError.d.ts +2 -0
- package/node_modules/@octopus/engine/dist/models/elementNotFoundError.js +6 -0
- package/node_modules/@octopus/engine/dist/models/extractItem.d.ts +37 -0
- package/node_modules/@octopus/engine/dist/models/extractItem.js +35 -0
- package/node_modules/@octopus/engine/dist/models/extractTemplate.d.ts +11 -0
- package/node_modules/@octopus/engine/dist/models/extractTemplate.js +48 -0
- package/node_modules/@octopus/engine/dist/models/extractTextItem.d.ts +10 -0
- package/node_modules/@octopus/engine/dist/models/extractTextItem.js +17 -0
- package/node_modules/@octopus/engine/dist/models/globalConfig.d.ts +5 -0
- package/node_modules/@octopus/engine/dist/models/globalConfig.js +1 -0
- package/node_modules/@octopus/engine/dist/models/httpHeader.d.ts +4 -0
- package/node_modules/@octopus/engine/dist/models/httpHeader.js +10 -0
- package/node_modules/@octopus/engine/dist/models/operation.d.ts +27 -0
- package/node_modules/@octopus/engine/dist/models/operation.js +242 -0
- package/node_modules/@octopus/engine/dist/models/retryCondition.d.ts +7 -0
- package/node_modules/@octopus/engine/dist/models/retryCondition.js +10 -0
- package/node_modules/@octopus/engine/dist/models/task.d.ts +89 -0
- package/node_modules/@octopus/engine/dist/models/task.js +120 -0
- package/node_modules/@octopus/engine/dist/models/trigger.d.ts +66 -0
- package/node_modules/@octopus/engine/dist/models/trigger.js +117 -0
- package/node_modules/@octopus/engine/dist/package.json +26 -0
- package/node_modules/@octopus/engine/dist/public-types.d.ts +13 -0
- package/node_modules/@octopus/engine/dist/public-types.js +2 -0
- package/node_modules/@octopus/engine/dist/settings.d.ts +41 -0
- package/node_modules/@octopus/engine/dist/settings.js +20 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/ClickCaptchaSolver.d.ts +6 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/ClickCaptchaSolver.js +1 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/HCaptchaSolver.d.ts +4 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/HCaptchaSolver.js +73 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/ImageCaptchaSolver.d.ts +2 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/ImageCaptchaSolver.js +74 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/RecaptchaSolver.d.ts +9 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/RecaptchaSolver.js +371 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/SliderCaptchaSolver.d.ts +6 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/SliderCaptchaSolver.js +184 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/SlidingTrajectory.d.ts +50 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/SlidingTrajectory.js +125 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/types.d.ts +68 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/types.js +34 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/utils.d.ts +2 -0
- package/node_modules/@octopus/engine/dist/solvers/captcha/utils.js +15 -0
- package/node_modules/@octopus/engine/dist/translator/actionFactory.d.ts +6 -0
- package/node_modules/@octopus/engine/dist/translator/actionFactory.js +1 -0
- package/node_modules/@octopus/engine/dist/translator/activityTypeEnum.d.ts +22 -0
- package/node_modules/@octopus/engine/dist/translator/activityTypeEnum.js +1 -0
- package/node_modules/@octopus/engine/dist/translator/backPreWebPageAction.d.ts +5 -0
- package/node_modules/@octopus/engine/dist/translator/backPreWebPageAction.js +1 -0
- package/node_modules/@octopus/engine/dist/translator/baseAction.d.ts +31 -0
- package/node_modules/@octopus/engine/dist/translator/baseAction.js +1 -0
- package/node_modules/@octopus/engine/dist/translator/breakActivity.d.ts +5 -0
- package/node_modules/@octopus/engine/dist/translator/breakActivity.js +1 -0
- package/node_modules/@octopus/engine/dist/translator/clickAction.d.ts +5 -0
- package/node_modules/@octopus/engine/dist/translator/clickAction.js +1 -0
- package/node_modules/@octopus/engine/dist/translator/completeWF.d.ts +5 -0
- package/node_modules/@octopus/engine/dist/translator/completeWF.js +1 -0
- package/node_modules/@octopus/engine/dist/translator/conditionAction.d.ts +6 -0
- package/node_modules/@octopus/engine/dist/translator/conditionAction.js +1 -0
- package/node_modules/@octopus/engine/dist/translator/emptyAction.d.ts +5 -0
- package/node_modules/@octopus/engine/dist/translator/emptyAction.js +1 -0
- package/node_modules/@octopus/engine/dist/translator/enterCapachaAction.d.ts +5 -0
- package/node_modules/@octopus/engine/dist/translator/enterCapachaAction.js +1 -0
- package/node_modules/@octopus/engine/dist/translator/enterTextAction.d.ts +5 -0
- package/node_modules/@octopus/engine/dist/translator/enterTextAction.js +1 -0
- package/node_modules/@octopus/engine/dist/translator/extractDataAction.d.ts +13 -0
- package/node_modules/@octopus/engine/dist/translator/extractDataAction.js +1 -0
- package/node_modules/@octopus/engine/dist/translator/loopAction.d.ts +5 -0
- package/node_modules/@octopus/engine/dist/translator/loopAction.js +1 -0
- package/node_modules/@octopus/engine/dist/translator/mouseOverAction.d.ts +5 -0
- package/node_modules/@octopus/engine/dist/translator/mouseOverAction.js +19 -0
- package/node_modules/@octopus/engine/dist/translator/navigateAction.d.ts +5 -0
- package/node_modules/@octopus/engine/dist/translator/navigateAction.js +117 -0
- package/node_modules/@octopus/engine/dist/translator/rootAction.d.ts +6 -0
- package/node_modules/@octopus/engine/dist/translator/rootAction.js +80 -0
- package/node_modules/@octopus/engine/dist/translator/switchCombo2Action.d.ts +5 -0
- package/node_modules/@octopus/engine/dist/translator/switchCombo2Action.js +19 -0
- package/node_modules/@octopus/engine/dist/translator/translator.d.ts +1 -0
- package/node_modules/@octopus/engine/dist/translator/translator.js +36 -0
- package/node_modules/@octopus/engine/dist/type.d.ts +25 -0
- package/node_modules/@octopus/engine/dist/type.js +2 -0
- package/node_modules/@octopus/engine/dist/types/browser.d.ts +191 -0
- package/node_modules/@octopus/engine/dist/types/browser.js +1 -0
- package/node_modules/@octopus/engine/dist/types/browserManager.d.ts +41 -0
- package/node_modules/@octopus/engine/dist/types/browserManager.js +1 -0
- package/node_modules/@octopus/engine/dist/types/index.d.ts +40 -0
- package/node_modules/@octopus/engine/dist/types/index.js +2 -0
- package/node_modules/@octopus/engine/dist/types/plugin.d.ts +29 -0
- package/node_modules/@octopus/engine/dist/types/plugin.js +2 -0
- package/node_modules/@octopus/engine/dist/utils/AsyncEmitter.d.ts +15 -0
- package/node_modules/@octopus/engine/dist/utils/AsyncEmitter.js +1 -0
- package/node_modules/@octopus/engine/dist/utils/DataStore.d.ts +58 -0
- package/node_modules/@octopus/engine/dist/utils/DataStore.js +1 -0
- package/node_modules/@octopus/engine/dist/utils/DateTimeFormatHelper.d.ts +22 -0
- package/node_modules/@octopus/engine/dist/utils/DateTimeFormatHelper.js +173 -0
- package/node_modules/@octopus/engine/dist/utils/FileDownloader.d.ts +108 -0
- package/node_modules/@octopus/engine/dist/utils/FileDownloader.js +1 -0
- package/node_modules/@octopus/engine/dist/utils/HttpRequester.d.ts +43 -0
- package/node_modules/@octopus/engine/dist/utils/HttpRequester.js +174 -0
- package/node_modules/@octopus/engine/dist/utils/JsonParser.d.ts +95 -0
- package/node_modules/@octopus/engine/dist/utils/JsonParser.js +439 -0
- package/node_modules/@octopus/engine/dist/utils/Operations.d.ts +27 -0
- package/node_modules/@octopus/engine/dist/utils/Operations.js +115 -0
- package/node_modules/@octopus/engine/dist/utils/index.d.ts +28 -0
- package/node_modules/@octopus/engine/dist/utils/index.js +356 -0
- package/node_modules/@octopus/engine/package.json +58 -0
- package/package.json +79 -0
- package/schemas/capabilities-v1.schema.json +234 -0
- package/schemas/detached-bootstrap-v1.schema.json +42 -0
- package/schemas/json-envelope-v1.schema.json +39 -0
- package/schemas/run-event-v1.schema.json +47 -0
|
@@ -0,0 +1,526 @@
|
|
|
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 LoopConfig_1 = __importDefault(require("../configs/LoopConfig"));
|
|
7
|
+
const enums_1 = require("../enums");
|
|
8
|
+
const Operations_1 = require("../utils/Operations");
|
|
9
|
+
const BaseAction_1 = __importDefault(require("./BaseAction"));
|
|
10
|
+
const actionItem_1 = require("../models/actionItem");
|
|
11
|
+
class LoopAction extends BaseAction_1.default {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
this.isDoneFirst = false;
|
|
15
|
+
this.targets = [];
|
|
16
|
+
this.onTargetCreated = (target) => {
|
|
17
|
+
if (target.type() == 'page') {
|
|
18
|
+
this.targets = [...(this.targets || []), target];
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
this.onTargetChanged = (target) => {
|
|
22
|
+
if (target.type() == 'page') {
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
parseConfig(config) {
|
|
27
|
+
return new LoopConfig_1.default(config);
|
|
28
|
+
}
|
|
29
|
+
resetTarget() {
|
|
30
|
+
this.actionTarget && this.browserProxy.switchTarget(this.actionTarget);
|
|
31
|
+
this.browserProxy.removeTargetCreated(this.onTargetCreated);
|
|
32
|
+
this.browserProxy.removeTargetChanged(this.onTargetChanged);
|
|
33
|
+
}
|
|
34
|
+
async loopElementExists(actionItem, timeout = 0) {
|
|
35
|
+
if (this.useExtensionBridge) {
|
|
36
|
+
const bridgeExists = await this.bridgeElementExists(this.page, actionItem, timeout || 1500);
|
|
37
|
+
if (bridgeExists !== undefined) {
|
|
38
|
+
return bridgeExists;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return Boolean(await (0, Operations_1.queryElement)(actionItem, this.page, timeout));
|
|
42
|
+
}
|
|
43
|
+
async wait() {
|
|
44
|
+
var _a;
|
|
45
|
+
if (this.isDoneFirst || this.getIsSkipCurrentLoop()) {
|
|
46
|
+
const page = await ((_a = this.actionTarget) === null || _a === void 0 ? void 0 : _a.page());
|
|
47
|
+
if (page) {
|
|
48
|
+
if (!this.useExtensionBridge) {
|
|
49
|
+
await page.bringToFront();
|
|
50
|
+
}
|
|
51
|
+
this.browserProxy.switchTarget(this.actionTarget);
|
|
52
|
+
for (const target of this.targets) {
|
|
53
|
+
const page = await target.page();
|
|
54
|
+
if (!page.isClosed()) {
|
|
55
|
+
await page.close();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
this.targets = [];
|
|
59
|
+
}
|
|
60
|
+
this.finish();
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
this.isDoneFirst = true;
|
|
64
|
+
this.page = await this.getCurrentPage();
|
|
65
|
+
this.actionTarget = this.browserProxy.currentTarget;
|
|
66
|
+
this.browserProxy.onTargetCreated(this.onTargetCreated);
|
|
67
|
+
// JSON 任务跳过页面等待逻辑
|
|
68
|
+
if (this.browserProxy.navigateType !== "OpenJson" /* NavigateType.OpenJson */) {
|
|
69
|
+
await super.wait();
|
|
70
|
+
}
|
|
71
|
+
// 设置本次循环的次数_设置数量
|
|
72
|
+
this.initLoopCount(this.id);
|
|
73
|
+
const list = [];
|
|
74
|
+
switch (this.config.loopType) {
|
|
75
|
+
case "FixedItem" /* LoopType.FixedItem */:
|
|
76
|
+
{
|
|
77
|
+
this.log(enums_1.LogKey.Loop.Begin.FixedItem, this.name);
|
|
78
|
+
if (this.config.fixedItem) {
|
|
79
|
+
list.unshift(this.config.fixedItem);
|
|
80
|
+
}
|
|
81
|
+
// 设置无效点击为 0 次
|
|
82
|
+
this.initContinuousInvalidPageCount(this.id);
|
|
83
|
+
}
|
|
84
|
+
break;
|
|
85
|
+
case "FixedItemList" /* LoopType.FixedItemList */:
|
|
86
|
+
{
|
|
87
|
+
this.log(enums_1.LogKey.Loop.Begin.FixedList, this.name);
|
|
88
|
+
// JSON 模式不支持 FixedItemList(固定元素列表需要 DOM 查询)
|
|
89
|
+
if (this.browserProxy.navigateType === "OpenJson" /* NavigateType.OpenJson */) {
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
try {
|
|
93
|
+
const extensionElementsValues = this.activity.activity.extensionElements.values;
|
|
94
|
+
for (const key in extensionElementsValues) {
|
|
95
|
+
const fixedList = extensionElementsValues[key];
|
|
96
|
+
if (fixedList.$type == "xml:LoopAction.FixedList" /* ActionTags.FixedList */ &&
|
|
97
|
+
fixedList.$children) {
|
|
98
|
+
for (const c of fixedList.$children) {
|
|
99
|
+
const actionItem = this.config.getElementXPath(c.value);
|
|
100
|
+
const exists = await this.loopElementExists(actionItem, this.shouldWait ? 1500 : 0);
|
|
101
|
+
if (exists)
|
|
102
|
+
list.unshift(actionItem);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
await this.checkPause();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
break;
|
|
112
|
+
case "TextList" /* LoopType.TextList */:
|
|
113
|
+
{
|
|
114
|
+
this.log(enums_1.LogKey.Loop.Begin.TextList, this.name);
|
|
115
|
+
const extensionElementsValues = this.activity.activity.extensionElements.values;
|
|
116
|
+
for (const key in extensionElementsValues) {
|
|
117
|
+
const textList = extensionElementsValues[key];
|
|
118
|
+
if (textList.$type == "xml:LoopAction.TextList" /* ActionTags.TextList */ && textList.$children) {
|
|
119
|
+
for (const c of textList.$children) {
|
|
120
|
+
list.unshift(c.value);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
break;
|
|
126
|
+
case "URLList" /* LoopType.URLList */:
|
|
127
|
+
{
|
|
128
|
+
this.log(enums_1.LogKey.Loop.Begin.URLList, this.name);
|
|
129
|
+
const extensionElementsValues = this.activity.activity.extensionElements.values;
|
|
130
|
+
for (const key in extensionElementsValues) {
|
|
131
|
+
const textList = extensionElementsValues[key];
|
|
132
|
+
if (textList.$type == "xml:LoopAction.URLList" /* ActionTags.URLList */ && textList.$children) {
|
|
133
|
+
for (const c of textList.$children) {
|
|
134
|
+
list.unshift(c.value);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
break;
|
|
140
|
+
case "VarilableItemList" /* LoopType.VarilableItemList */:
|
|
141
|
+
{
|
|
142
|
+
this.log(enums_1.LogKey.Loop.Begin.VarilableList, this.name);
|
|
143
|
+
if (this.config.variableList) {
|
|
144
|
+
// JSON 模式和网页模式分别处理
|
|
145
|
+
if (this.browserProxy.navigateType === "OpenJson" /* NavigateType.OpenJson */) {
|
|
146
|
+
try {
|
|
147
|
+
const originalPath = this.config.variableList.AbsXpath;
|
|
148
|
+
// 检查 jsonParser 是否有数据
|
|
149
|
+
const root = this.browserProxy.jsonParser.getRoot();
|
|
150
|
+
if (!root || Object.keys(root).length === 0) {
|
|
151
|
+
console.log('❌ jsonParser 没有数据!');
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
const startIndex = originalPath.lastIndexOf('[*]');
|
|
155
|
+
//当前循环项的xpath
|
|
156
|
+
const thisXpath = originalPath.substring(0, startIndex) + '[0]';
|
|
157
|
+
const thisnode = this.browserProxy.jsonParser.getNode(thisXpath);
|
|
158
|
+
if (thisnode) {
|
|
159
|
+
list.unshift(this.config.variableList);
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
// 尝试直接用原始路径查询看看
|
|
163
|
+
const testNode = this.browserProxy.jsonParser.getNode(originalPath.replace('[*]', '[0]'));
|
|
164
|
+
console.log('🔍 尝试替换 [*] 为 [0]:', testNode);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
console.log('🔴 LoopAction JSON 模式错误:', error);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
try {
|
|
174
|
+
const { AbsXpath } = this.config.variableList;
|
|
175
|
+
// 这里必须等待 Promise 结果;否则 Promise 对象本身恒为 truthy,
|
|
176
|
+
// 会把“不存在的列表”也当成存在,导致循环队列永远压回去。
|
|
177
|
+
const isExist = await this.loopElementExists(this.config.variableList, this.shouldWait ? 1500 : 0);
|
|
178
|
+
if (isExist) {
|
|
179
|
+
list.unshift(this.config.variableList);
|
|
180
|
+
}
|
|
181
|
+
let diff = false;
|
|
182
|
+
if (this.getCurrentLoopUrl(this.id)) {
|
|
183
|
+
const url = this.page.url();
|
|
184
|
+
if (this.getCurrentLoopUrl(this.id) != url) {
|
|
185
|
+
diff = true;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
diff = true;
|
|
190
|
+
}
|
|
191
|
+
const sample = this.getSamplingElementsMap(this.id);
|
|
192
|
+
if (sample.size > 0) {
|
|
193
|
+
for (const [key, value] of sample) {
|
|
194
|
+
const thisElement = {
|
|
195
|
+
...this.config.variableList,
|
|
196
|
+
AbsXpath: '(' + AbsXpath + ')[' + key + ']'
|
|
197
|
+
};
|
|
198
|
+
const isExist = await this.loopElementExists(thisElement, this.shouldWait ? 1500 : 0);
|
|
199
|
+
if (!isExist) {
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
// const text = await this.page.$eval(`::-p-xpath(${thisXpath})`, (ele: HTMLElement) => ele?.innerText || ele.textContent)
|
|
203
|
+
const text = await (0, Operations_1.processElement)(thisElement, this.page, '$eval', (ele) => (ele === null || ele === void 0 ? void 0 : ele.innerText) || ele.textContent);
|
|
204
|
+
if (this.similar(value.replace(/[\r\n\s]/g, ''), text.replace(/[\r\n\s]/g, ''), 2) < 0.95) {
|
|
205
|
+
diff = true; //说明前面的列表数据有变化
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
const parentLoopAction = this.recursionGetParentLoopAction(this);
|
|
211
|
+
const parentLoopCount = this.getLoopCount(parentLoopAction === null || parentLoopAction === void 0 ? void 0 : parentLoopAction.id);
|
|
212
|
+
let isScrollWeb = false;
|
|
213
|
+
// 滚动时循环列表不自动去重,重置index
|
|
214
|
+
let notDirectSkip = true;
|
|
215
|
+
if (parentLoopAction) {
|
|
216
|
+
const parentConfig = this.parent.config;
|
|
217
|
+
// 必须是在其父类的时候是FixedItem,单击的时候才做次判断
|
|
218
|
+
if (parentConfig.loopType == "ScrollWeb" /* LoopType.ScrollWeb */) {
|
|
219
|
+
isScrollWeb = true;
|
|
220
|
+
notDirectSkip =
|
|
221
|
+
parentConfig.disabledScrollAutoRemoveDuplication;
|
|
222
|
+
}
|
|
223
|
+
else if (parentConfig.loopType == "FixedItem" /* LoopType.FixedItem */ &&
|
|
224
|
+
parentConfig.checkedJumpLoopClick) {
|
|
225
|
+
// // 需要在任务配置勾选了【自动跳过无效的循环点击】选项才启用后面的【采样判断】
|
|
226
|
+
notDirectSkip = false;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
if (parentLoopCount === 1 ||
|
|
230
|
+
notDirectSkip ||
|
|
231
|
+
(diff && !isScrollWeb)) {
|
|
232
|
+
this.initSomeLoopExtractDataCount(this.id);
|
|
233
|
+
this.initIdentifiedEachLoopExtractDataCount(this.id);
|
|
234
|
+
// 当列表基准发生变化时,同时清空上次为瞬时失败留下的 offset,
|
|
235
|
+
// 保证下一轮重新从自然索引开始。
|
|
236
|
+
this.resetNextLoopOffset(this.id);
|
|
237
|
+
this.initSamplingElementsMap(this.id);
|
|
238
|
+
this.initSampedLoopRecord();
|
|
239
|
+
this.initContinuousClickLoadNoNewDataCount(parentLoopAction === null || parentLoopAction === void 0 ? void 0 : parentLoopAction.id);
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
this.setIdentifiedEachLoopExtractDataCount(this.id);
|
|
243
|
+
// 停止无效点击
|
|
244
|
+
if (parentLoopAction && this.browserProxy.workflowSetting) {
|
|
245
|
+
const parentLoopActionConfig = parentLoopAction.config;
|
|
246
|
+
// 只有循环采集的父级循环循环类型是循环单个元素时,才进行停止无效点击加载更多判断
|
|
247
|
+
if (parentLoopActionConfig &&
|
|
248
|
+
parentLoopActionConfig.loopType === "FixedItem" /* LoopType.FixedItem */ &&
|
|
249
|
+
parentLoopActionConfig.checkedJumpLoopClick &&
|
|
250
|
+
parentLoopCount >
|
|
251
|
+
this.browserProxy.workflowSetting.repeatPageLoopCount) {
|
|
252
|
+
const configOptions = {
|
|
253
|
+
AbsXpath: this.config.variableList.AbsXpath,
|
|
254
|
+
IsIFrame: this.config.variableList.IsIFrame,
|
|
255
|
+
IFrameAbsXPath: this.config.variableList.IFrameAbsXPath,
|
|
256
|
+
newXpathStartIndex: this.getSomeLoopExtractDataCount(this.id)
|
|
257
|
+
};
|
|
258
|
+
// 判断是否有新数据
|
|
259
|
+
if (await this.ifNextElement(configOptions, this.page)) {
|
|
260
|
+
this.initContinuousClickLoadNoNewDataCount(parentLoopAction.id);
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
this.addContinuousClickLoadNoNewDataCount(parentLoopAction.id);
|
|
264
|
+
}
|
|
265
|
+
const noNewDataCount = this.getContinuousClickLoadNoNewDataCount(parentLoopAction.id);
|
|
266
|
+
if (noNewDataCount >=
|
|
267
|
+
this.browserProxy.workflowSetting.continuousJudgeCount) {
|
|
268
|
+
// 跳过本轮采集
|
|
269
|
+
this.setIsSkipCurrentLoop(parentLoopAction.id, true);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
catch (error) {
|
|
276
|
+
await this.checkPause();
|
|
277
|
+
/* empty */
|
|
278
|
+
}
|
|
279
|
+
// if (this.workflow.navigateType == NavigateType.OpenJson) {
|
|
280
|
+
// const startIndex = this.config.variableList.AbsXpath.lastIndexOf('[*]')
|
|
281
|
+
// //当前循环项的xpath
|
|
282
|
+
// const thisXpath = this.config.variableList.AbsXpath.substring(0, startIndex) + '[0]'
|
|
283
|
+
// const thisnode = this.workflow.jsonParser.getNode(thisXpath)
|
|
284
|
+
// if (thisnode) {
|
|
285
|
+
// list.unshift(this.config.variableList)
|
|
286
|
+
// }
|
|
287
|
+
// } else {
|
|
288
|
+
// //当前循环项的xpath
|
|
289
|
+
// this.popIsLoadedState()
|
|
290
|
+
// let checkRes = false
|
|
291
|
+
// const actionItem = new ActionItem(this.config.variableList.AbsXpath, this.config.variableList.IsIFrame, this.config.variableList.IFrameAbsXPath)
|
|
292
|
+
// // 检测是否加载,如果加载后,那么会执行一次时长120的检测页面加载(成功后提前退出)
|
|
293
|
+
// // if ([FuncRetryType.IsLoaded, FuncRetryType.IsClick].indexOf(nowType) > -1) {
|
|
294
|
+
// // checkRes = await this.retryCheckActionItem(this.id + '_IsLoaded_IsClick', actionItem, 120 * 1000)
|
|
295
|
+
// // } else {
|
|
296
|
+
// // 健壮性
|
|
297
|
+
// checkRes = await this.workflow.browser.existElement(actionItem)
|
|
298
|
+
// //如果存在
|
|
299
|
+
// if (!checkRes) {
|
|
300
|
+
// checkRes = await this.awaitElement(actionItem)
|
|
301
|
+
// }
|
|
302
|
+
// // 记录结果
|
|
303
|
+
// var msg = '页面找不到循环的'
|
|
304
|
+
// if (checkRes) {
|
|
305
|
+
// list.unshift(this.config.variableList)
|
|
306
|
+
// msg = '准备循环的'
|
|
307
|
+
// }
|
|
308
|
+
// await this.varilableItemListCount()
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
break;
|
|
313
|
+
case "ScrollWeb" /* LoopType.ScrollWeb */:
|
|
314
|
+
{
|
|
315
|
+
this.log(enums_1.LogKey.Loop.Begin.Scroll, this.name);
|
|
316
|
+
list.unshift(['ScrollWeb']);
|
|
317
|
+
}
|
|
318
|
+
break;
|
|
319
|
+
}
|
|
320
|
+
this.setLoopValues(this.id, list);
|
|
321
|
+
this.finish();
|
|
322
|
+
}
|
|
323
|
+
leave() {
|
|
324
|
+
super.leave();
|
|
325
|
+
// 删除除去跳过本次循环
|
|
326
|
+
this.deleteIsSkipCurrentLoop(this.id);
|
|
327
|
+
this.isDoneFirst = false;
|
|
328
|
+
// this.workflow.emit('loop-completed')
|
|
329
|
+
}
|
|
330
|
+
/** 不固定元素循环列表的采集偏移量计算 */
|
|
331
|
+
async varilableItemListCount() {
|
|
332
|
+
this.setIdentifiedEachLoopExtractDataCount(this.id);
|
|
333
|
+
// let parentLoopCount = 0
|
|
334
|
+
// // (父级/爷爷级)循环是第几次循环
|
|
335
|
+
// const parentLoopAction = this.recursionGetParentLoopAction(this)
|
|
336
|
+
// let notDirectSkip = true
|
|
337
|
+
// let isScrollWeb = false
|
|
338
|
+
// if (parentLoopAction) {
|
|
339
|
+
// parentLoopCount = this.getLoopCount(parentLoopAction.id)
|
|
340
|
+
// const parentConfig = this.parent.config as LoopConfig
|
|
341
|
+
// // 必须是在其父类的时候是FixedItem,单击的时候才做次判断
|
|
342
|
+
// if (parentConfig.loopType == LoopType.ScrollWeb) {
|
|
343
|
+
// isScrollWeb = true
|
|
344
|
+
// notDirectSkip = parentConfig.disabledScrollAutoRemoveDuplication
|
|
345
|
+
// } else if (parentConfig.loopType == LoopType.FixedItem && parentConfig.checkedJumpLoopClick) {
|
|
346
|
+
// // 需要在任务配置勾选了【自动跳过无效的循环点击】选项才启用后面的【采样判断】
|
|
347
|
+
// notDirectSkip = false
|
|
348
|
+
// }
|
|
349
|
+
// }
|
|
350
|
+
// const configOptions = {
|
|
351
|
+
// AbsXpath: this.config.variableList.AbsXpath,
|
|
352
|
+
// IsIFrame: this.config.variableList.IsIFrame,
|
|
353
|
+
// IFrameAbsXPath: this.config.variableList.IFrameAbsXPath,
|
|
354
|
+
// newXpathStartIndex: this.getSomeLoopExtractDataCount(this.id),
|
|
355
|
+
// }
|
|
356
|
+
// // parentLoopCount 不固定元素循环列表,父循环的循环次数为1时,置零
|
|
357
|
+
// if (parentLoopCount === 1 || notDirectSkip || (!isScrollWeb && (await this.diffSamplingElements(this.id, configOptions)))) {
|
|
358
|
+
// this.initSomeLoopExtractDataCount(this.id)
|
|
359
|
+
// this.initIdentifiedEachLoopExtractDataCount(this.id)
|
|
360
|
+
// this.initSamplingElementsMap(this.id)
|
|
361
|
+
// this.initSampedLoopRecord()
|
|
362
|
+
// this.initContinuousClickLoadNoNewDataCount(parentLoopAction?.id)
|
|
363
|
+
// } else {
|
|
364
|
+
// // 根据上一次
|
|
365
|
+
// this.setIdentifiedEachLoopExtractDataCount(this.id)
|
|
366
|
+
// // 停止无效点击
|
|
367
|
+
// // if (parentLoopAction && this.workflow.task.workflowSetting) {
|
|
368
|
+
// // const parentLoopActionConfig = parentLoopAction.config as LoopConfig
|
|
369
|
+
// // // 只有循环采集的父级循环循环类型是循环单个元素时,才进行停止无效点击加载更多判断
|
|
370
|
+
// // if (
|
|
371
|
+
// // parentLoopActionConfig &&
|
|
372
|
+
// // parentLoopActionConfig.loopType === LoopType.FixedItem &&
|
|
373
|
+
// // parentLoopActionConfig.checkedJumpLoopClick &&
|
|
374
|
+
// // parentLoopCount > this.workflow.task.workflowSetting.repeatPageLoopCount
|
|
375
|
+
// // ) {
|
|
376
|
+
// // // 判断是否有新数据
|
|
377
|
+
// // if (await this.ifNextElement(configOptions)) {
|
|
378
|
+
// // this.initContinuousClickLoadNoNewDataCount(parentLoopAction.id)
|
|
379
|
+
// // } else {
|
|
380
|
+
// // this.addContinuousClickLoadNoNewDataCount(parentLoopAction.id)
|
|
381
|
+
// // }
|
|
382
|
+
// // const noNewDataCount = this.getContinuousClickLoadNoNewDataCount(parentLoopAction.id)
|
|
383
|
+
// // if (noNewDataCount >= this.workflow.task.workflowSetting.continuousJudgeCount) {
|
|
384
|
+
// // // 跳过本轮采集
|
|
385
|
+
// // this.setIsSkipCurrentLoop(parentLoopAction.id, true)
|
|
386
|
+
// // }
|
|
387
|
+
// // }
|
|
388
|
+
// // }
|
|
389
|
+
// }
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* 递归获取第一个(父级/爷爷级)循环节点
|
|
393
|
+
* @param action 当前节点
|
|
394
|
+
*/
|
|
395
|
+
recursionGetParentLoopAction(action) {
|
|
396
|
+
if (action && action.parent && action.parent.type === 'LoopAction') {
|
|
397
|
+
return action.parent;
|
|
398
|
+
}
|
|
399
|
+
if (!action) {
|
|
400
|
+
return undefined;
|
|
401
|
+
}
|
|
402
|
+
return this.recursionGetParentLoopAction(action.parent);
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* 对比指定的不固定循环列表元素是否变化
|
|
406
|
+
* @param nodeId
|
|
407
|
+
* @param loopConfig
|
|
408
|
+
*/
|
|
409
|
+
async diffSamplingElements(nodeId, loopConfig) {
|
|
410
|
+
if (this.getCurrentLoopUrl(nodeId)) {
|
|
411
|
+
// const url = this.workflow.browser.getURL()
|
|
412
|
+
// if (this.getCurrentLoopUrl(nodeId) != url) {
|
|
413
|
+
// return true
|
|
414
|
+
// }
|
|
415
|
+
}
|
|
416
|
+
else {
|
|
417
|
+
return true;
|
|
418
|
+
}
|
|
419
|
+
const AbsXpath = loopConfig.AbsXpath;
|
|
420
|
+
const IsIFrame = loopConfig.IsIFrame;
|
|
421
|
+
const IFrameAbsXPath = loopConfig.IFrameAbsXPath;
|
|
422
|
+
const flag = false;
|
|
423
|
+
const samplingElementsMap = this.getSamplingElementsMap(nodeId);
|
|
424
|
+
// 这个时候可能请求没有结束
|
|
425
|
+
// if (this.workflow.browser.isWaitRequest()) {
|
|
426
|
+
// //4秒等待
|
|
427
|
+
// for (let i = 0; i < 20; i++) {
|
|
428
|
+
// if (this.workflow.browser.isWaitRequest()) {
|
|
429
|
+
// await this.sleep(200)
|
|
430
|
+
// await this.checkPause()
|
|
431
|
+
// } else {
|
|
432
|
+
// break
|
|
433
|
+
// }
|
|
434
|
+
// }
|
|
435
|
+
// }
|
|
436
|
+
// if (samplingElementsMap.size > 0) {
|
|
437
|
+
// for (const [key, value] of samplingElementsMap) {
|
|
438
|
+
// const thisXpath = '(' + AbsXpath + ')[' + key + ']'
|
|
439
|
+
// let curVal = await this.workflow.browser.getInnerText(new ActionItem(thisXpath, IsIFrame, IFrameAbsXPath))
|
|
440
|
+
// /** 相似度比对 */
|
|
441
|
+
// if (this.similar(value.replace(/[\r\n\s]/g, ''), curVal.replace(/[\r\n\s]/g, ''), 2) < 0.95) {
|
|
442
|
+
// // 说明前面遍历过的元素有变动,将该轮循环的偏移量置零
|
|
443
|
+
// // console.log(value.replace(/[\r\n]/g,'') +'--------不相同-------'+ curVal.replace(/[\r\n]/g,''))
|
|
444
|
+
// flag = true //说明前面的列表数据有变化
|
|
445
|
+
// break
|
|
446
|
+
// }
|
|
447
|
+
// /** 全比对 */
|
|
448
|
+
// // if(value.replace(/[\r\n]/g,'') != curVal.replace(/[\r\n]/g,'')){
|
|
449
|
+
// // // 说明前面遍历过的元素有变动,将该轮循环的偏移量置零
|
|
450
|
+
// // console.log(value.replace(/[\r\n]/g,'') +'--------不相同-------'+ curVal.replace(/[\r\n]/g,''))
|
|
451
|
+
// // falg = true //说明前面的列表数据有变化
|
|
452
|
+
// // break;
|
|
453
|
+
// // }
|
|
454
|
+
// }
|
|
455
|
+
// }
|
|
456
|
+
return flag;
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* 辅助判断当前循环列表所依赖的列表元素是否有增加
|
|
460
|
+
* @param loopConfig
|
|
461
|
+
*/
|
|
462
|
+
async ifNextElement(loopConfig, page) {
|
|
463
|
+
const { AbsXpath, IsIFrame, IFrameAbsXPath } = loopConfig;
|
|
464
|
+
const newXpathStartIndex = loopConfig.newXpathStartIndex;
|
|
465
|
+
//判断下一个循环的xpath对应元素是否存在,存在则把line重新压入队列中以使循环能够继续执行
|
|
466
|
+
const nextXpath = '(' + AbsXpath + ')[' + (newXpathStartIndex + 1) + ']';
|
|
467
|
+
const nextActionItem = new actionItem_1.ActionItem(nextXpath, IsIFrame, IFrameAbsXPath);
|
|
468
|
+
if (this.useExtensionBridge && page === this.page) {
|
|
469
|
+
const bridgeExists = await this.bridgeElementExists(page, nextActionItem, 500);
|
|
470
|
+
if (bridgeExists !== undefined) {
|
|
471
|
+
return bridgeExists;
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
return Boolean(await (0, Operations_1.queryElement)(nextActionItem, page));
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* 辅助判断字符串相似度
|
|
478
|
+
* @param s 字符串1
|
|
479
|
+
* @param t 字符串1
|
|
480
|
+
* @param f 精确度:保留几位小数
|
|
481
|
+
*/
|
|
482
|
+
similar(s, t, f) {
|
|
483
|
+
if (s == '' && t == '') {
|
|
484
|
+
return 1;
|
|
485
|
+
}
|
|
486
|
+
if (!s || !t) {
|
|
487
|
+
return 0;
|
|
488
|
+
}
|
|
489
|
+
const l = s.length > t.length ? s.length : t.length;
|
|
490
|
+
const n = s.length;
|
|
491
|
+
const m = t.length;
|
|
492
|
+
const d = [];
|
|
493
|
+
f = f || 3;
|
|
494
|
+
const min = function (a, b, c) {
|
|
495
|
+
return a < b ? (a < c ? a : c) : b < c ? b : c;
|
|
496
|
+
};
|
|
497
|
+
let i, j, si, tj, cost;
|
|
498
|
+
if (n === 0)
|
|
499
|
+
return m;
|
|
500
|
+
if (m === 0)
|
|
501
|
+
return n;
|
|
502
|
+
for (i = 0; i <= n; i++) {
|
|
503
|
+
d[i] = [];
|
|
504
|
+
d[i][0] = i;
|
|
505
|
+
}
|
|
506
|
+
for (j = 0; j <= m; j++) {
|
|
507
|
+
d[0][j] = j;
|
|
508
|
+
}
|
|
509
|
+
for (i = 1; i <= n; i++) {
|
|
510
|
+
si = s.charAt(i - 1);
|
|
511
|
+
for (j = 1; j <= m; j++) {
|
|
512
|
+
tj = t.charAt(j - 1);
|
|
513
|
+
if (si === tj) {
|
|
514
|
+
cost = 0;
|
|
515
|
+
}
|
|
516
|
+
else {
|
|
517
|
+
cost = 1;
|
|
518
|
+
}
|
|
519
|
+
d[i][j] = min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + cost);
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
const res = 1 - d[n][m] / l;
|
|
523
|
+
return res.toFixed(f);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
exports.default = LoopAction;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import LoopStartConfig from '../configs/LoopStartConfig';
|
|
2
|
+
import BaseAction from './BaseAction';
|
|
3
|
+
export default class LoopStartAction extends BaseAction {
|
|
4
|
+
config: LoopStartConfig;
|
|
5
|
+
private page;
|
|
6
|
+
private readLoopItemText;
|
|
7
|
+
private loopElementExists;
|
|
8
|
+
protected parseConfig(): LoopStartConfig;
|
|
9
|
+
wait(): Promise<void>;
|
|
10
|
+
loopXpathNextWait: Map<string, number>;
|
|
11
|
+
isWaitPathByMaxIndex(key: string, currentIndex: number): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* 停止无效点击翻页判断
|
|
14
|
+
* @param parentid
|
|
15
|
+
* @param loopConfig
|
|
16
|
+
*/
|
|
17
|
+
private stopInvalidClickPage;
|
|
18
|
+
/**
|
|
19
|
+
* 生成随机采样数据需要的数据坐标
|
|
20
|
+
* @param currentIndex 抽样前多少条数据条目(数据模板)
|
|
21
|
+
* @param m 抽样的数据条目
|
|
22
|
+
*/
|
|
23
|
+
private getRandomArrayElements;
|
|
24
|
+
/**
|
|
25
|
+
* 指定循环采集数据步骤完成后进行数据采样并存储
|
|
26
|
+
* @param params
|
|
27
|
+
*/
|
|
28
|
+
private cacheCurLoopSampleElenemts;
|
|
29
|
+
/**
|
|
30
|
+
* 对比指定的不固定循环列表元素是否变化
|
|
31
|
+
* @param nodeId
|
|
32
|
+
* @param loopConfig
|
|
33
|
+
*/
|
|
34
|
+
private diffSamplingElements;
|
|
35
|
+
/**
|
|
36
|
+
* 辅助判断当前循环列表所依赖的列表元素是否有增加
|
|
37
|
+
* @param loopConfig
|
|
38
|
+
*/
|
|
39
|
+
private ifNextElement;
|
|
40
|
+
/**
|
|
41
|
+
* 辅助判断字符串相似度
|
|
42
|
+
* @param s 字符串1
|
|
43
|
+
* @param t 字符串1
|
|
44
|
+
* @param f 精确度:保留几位小数
|
|
45
|
+
*/
|
|
46
|
+
private similar;
|
|
47
|
+
}
|