From 3600a6b4d71b19bcf7005974d43671f711dac8b5 Mon Sep 17 00:00:00 2001 From: frankpagan Date: Fri, 8 Mar 2024 22:16:15 -0500 Subject: [PATCH] fix: add flag status to trigger next action --- src/index.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index ef1ba2a..65ab425 100644 --- a/src/index.js +++ b/src/index.js @@ -102,16 +102,19 @@ function runAction(stagedActions, index, element) { function runSpecialAction(actions, index, element, actionName, params) { if (!params) return "next"; - let elements + let elements, status = "next" switch (actionName) { case 'event': console.log("Waiting Event...."); + status = "" document.addEventListener(params, () => { console.log('Event Action (Received event from other section) ====== ' + params); runNextAction(actions, index, element); }, { once: true }) break; case 'timeout': + status = "" + let delayTime = parseInt(params); if (delayTime > 0) { setTimeout(function () { @@ -141,8 +144,14 @@ function runSpecialAction(actions, index, element, actionName, params) { form.click(); break; default: - return "next"; + elements = queryElements({ element, selector: params, type: 'selector' }); + for (let i = 0; i < elements.length; i++) { + if (elements[i][actionName]) + elements[i][actionName](); + } } + + return status } function runNextAction(actions, index, element) {