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,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;
|