feat: add selectors in bottom up order
This commit is contained in:
@@ -121,24 +121,30 @@ export default class Interpreter extends EventEmitter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// private getPreviousSelectors(workflow: Workflow, actionId: number): string[] {
|
// private getSelectors(workflow: Workflow, actionId: number): string[] {
|
||||||
// const selectors: string[] = [];
|
// const selectors: string[] = [];
|
||||||
// let index = actionId - 1;
|
|
||||||
|
|
||||||
// while (index >= 0) {
|
// // Validate actionId
|
||||||
// const previousSelectors = workflow[index]?.where?.selectors;
|
// if (actionId <= 0) {
|
||||||
// console.log("Previous Selectors:", previousSelectors);
|
// console.log("No previous selectors to collect.");
|
||||||
// if (previousSelectors && previousSelectors.length > 0) {
|
// return selectors; // Empty array as there are no previous steps
|
||||||
// previousSelectors.forEach((selector) => {
|
// }
|
||||||
|
|
||||||
|
// // Iterate from the start up to (but not including) actionId
|
||||||
|
// for (let index = 0; index < actionId; index++) {
|
||||||
|
// const currentSelectors = workflow[index]?.where?.selectors;
|
||||||
|
// console.log(`Selectors at step ${index}:`, currentSelectors);
|
||||||
|
|
||||||
|
// if (currentSelectors && currentSelectors.length > 0) {
|
||||||
|
// currentSelectors.forEach((selector) => {
|
||||||
// if (!selectors.includes(selector)) {
|
// if (!selectors.includes(selector)) {
|
||||||
// selectors.push(selector); // Avoid duplicates
|
// selectors.push(selector); // Avoid duplicates
|
||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
// break; // Exit the loop once valid selectors are found
|
|
||||||
// }
|
// }
|
||||||
// index--; // Move further back in the workflow
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
// console.log("Collected Selectors:", selectors);
|
||||||
// return selectors;
|
// return selectors;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@@ -208,12 +214,14 @@ export default class Interpreter extends EventEmitter {
|
|||||||
// return [];
|
// return [];
|
||||||
// }),
|
// }),
|
||||||
// ).then((x) => x.flat());
|
// ).then((x) => x.flat());
|
||||||
|
|
||||||
const action = workflowCopy[workflowCopy.length - 1];
|
const action = workflowCopy[workflowCopy.length - 1];
|
||||||
|
|
||||||
|
// console.log("Next action:", action)
|
||||||
|
|
||||||
let url: any = page.url();
|
let url: any = page.url();
|
||||||
|
|
||||||
if (action && action.where.url !== url) {
|
if (action && action.where.url !== url && action.where.url !== "about:blank") {
|
||||||
url = action.where.url;
|
url = action.where.url;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -700,7 +708,7 @@ export default class Interpreter extends EventEmitter {
|
|||||||
usedActions.push(action.id ?? 'undefined');
|
usedActions.push(action.id ?? 'undefined');
|
||||||
|
|
||||||
workflowCopy.splice(actionId, 1);
|
workflowCopy.splice(actionId, 1);
|
||||||
console.log(`Action with ID ${actionId} removed from the workflow copy.`);
|
console.log(`Action with ID ${action.id} removed from the workflow copy.`);
|
||||||
|
|
||||||
// const newSelectors = this.getPreviousSelectors(workflow, actionId);
|
// const newSelectors = this.getPreviousSelectors(workflow, actionId);
|
||||||
const newSelectors = this.getSelectors(workflowCopy);
|
const newSelectors = this.getSelectors(workflowCopy);
|
||||||
|
|||||||
Reference in New Issue
Block a user