From d222ba22034e2404d17adcb1939310ba3a32d6f7 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Mon, 23 Sep 2024 15:43:26 +0530 Subject: [PATCH 01/20] feat: display less technical message to user --- src/components/molecules/InterpretationButtons.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/molecules/InterpretationButtons.tsx b/src/components/molecules/InterpretationButtons.tsx index 848c7e05..41196504 100644 --- a/src/components/molecules/InterpretationButtons.tsx +++ b/src/components/molecules/InterpretationButtons.tsx @@ -73,8 +73,7 @@ export const InterpretationButtons = ({ enableStepping }: InterpretationButtonsP return ( - Do you want to use the previously recorded selector - as a where condition for matching the action? + Do you want to use your previous selection as a condition for performing this action? [previous action: {decisionModal.action}] From c7414eddca8d96d7d88ce0426db9031d9038dca1 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Mon, 23 Sep 2024 17:24:36 +0530 Subject: [PATCH 02/20] feat: get info of lastUsedSelector --- server/src/workflow-management/classes/Generator.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/server/src/workflow-management/classes/Generator.ts b/server/src/workflow-management/classes/Generator.ts index f9ae1410..c1fa16e0 100644 --- a/server/src/workflow-management/classes/Generator.ts +++ b/server/src/workflow-management/classes/Generator.ts @@ -299,6 +299,17 @@ export class WorkflowGenerator { await this.addPairToWorkflowAndNotifyClient(pair, page); }; + private async getLastUsedSelectorInfo(page: Page, selector: string) { + const elementHandle = await page.$(selector); + if (elementHandle) { + const tagName = await elementHandle.evaluate(el => (el as HTMLElement).tagName); + const innerText = await elementHandle.evaluate(el => (el as HTMLElement).innerText); + + return { tagName, innerText }; + } + return { tagName: '', innerText: '' }; + } + /** * Generates a pair for the custom action event. * @param action The type of the custom action. From 22ceb5b39b2086c480980d353eed650197f86c1f Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Mon, 23 Sep 2024 17:25:24 +0530 Subject: [PATCH 03/20] feat: tag name & inner text in PersesistedGeneratedData interafce --- server/src/workflow-management/classes/Generator.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/src/workflow-management/classes/Generator.ts b/server/src/workflow-management/classes/Generator.ts index c1fa16e0..c1f4e1ab 100644 --- a/server/src/workflow-management/classes/Generator.ts +++ b/server/src/workflow-management/classes/Generator.ts @@ -23,6 +23,8 @@ interface PersistedGeneratedData { lastUsedSelector: string; lastIndex: number | null; lastAction: string; + lastUsedSelectorTagName: string; + lastUsedSelectorInnerText: string; } interface MetaData { From 83da2b265f0b296201508a35154b1d710a2f5def Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Mon, 23 Sep 2024 17:25:39 +0530 Subject: [PATCH 04/20] feat: define default values --- server/src/workflow-management/classes/Generator.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/src/workflow-management/classes/Generator.ts b/server/src/workflow-management/classes/Generator.ts index c1f4e1ab..f6de7272 100644 --- a/server/src/workflow-management/classes/Generator.ts +++ b/server/src/workflow-management/classes/Generator.ts @@ -99,6 +99,8 @@ export class WorkflowGenerator { lastUsedSelector: '', lastIndex: null, lastAction: '', + lastUsedSelectorTagName: '', + lastUsedSelectorInnerText: '', } /** From 911ac288b3e96a78e03a014d442ceca5724fd831 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Mon, 23 Sep 2024 17:26:11 +0530 Subject: [PATCH 05/20] feat: use getLastUsedSelectorInfo for lastUsedSelector --- server/src/workflow-management/classes/Generator.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/src/workflow-management/classes/Generator.ts b/server/src/workflow-management/classes/Generator.ts index f6de7272..cdcf01ee 100644 --- a/server/src/workflow-management/classes/Generator.ts +++ b/server/src/workflow-management/classes/Generator.ts @@ -330,6 +330,8 @@ export class WorkflowGenerator { } if (this.generatedData.lastUsedSelector) { + const elementInfo = await this.getLastUsedSelectorInfo(page, this.generatedData.lastUsedSelector); + this.socket.emit('decision', { pair, actionType: 'customAction', lastData: { From 05f83d3926d6e97259bae7430e76d49559125456 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Mon, 23 Sep 2024 17:26:32 +0530 Subject: [PATCH 06/20] feat: return tag name & innerText --- server/src/workflow-management/classes/Generator.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/src/workflow-management/classes/Generator.ts b/server/src/workflow-management/classes/Generator.ts index cdcf01ee..d4ef5003 100644 --- a/server/src/workflow-management/classes/Generator.ts +++ b/server/src/workflow-management/classes/Generator.ts @@ -337,6 +337,8 @@ export class WorkflowGenerator { lastData: { selector: this.generatedData.lastUsedSelector, action: this.generatedData.lastAction, + tagName: elementInfo.tagName, + innerText: elementInfo.innerText, } }); } else { From cda7115e552fdcb01c045c8a1e74b4933a45c78a Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Mon, 23 Sep 2024 17:26:45 +0530 Subject: [PATCH 07/20] chore: lint --- server/src/workflow-management/classes/Generator.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/src/workflow-management/classes/Generator.ts b/server/src/workflow-management/classes/Generator.ts index d4ef5003..d3084f92 100644 --- a/server/src/workflow-management/classes/Generator.ts +++ b/server/src/workflow-management/classes/Generator.ts @@ -308,10 +308,10 @@ export class WorkflowGenerator { if (elementHandle) { const tagName = await elementHandle.evaluate(el => (el as HTMLElement).tagName); const innerText = await elementHandle.evaluate(el => (el as HTMLElement).innerText); - + return { tagName, innerText }; } - return { tagName: '', innerText: '' }; + return { tagName: '', innerText: '' }; } /** @@ -338,7 +338,7 @@ export class WorkflowGenerator { selector: this.generatedData.lastUsedSelector, action: this.generatedData.lastAction, tagName: elementInfo.tagName, - innerText: elementInfo.innerText, + innerText: elementInfo.innerText, } }); } else { @@ -505,7 +505,7 @@ export class WorkflowGenerator { const selectorBasedOnCustomAction = (this.getList === true) ? await getNonUniqueSelectors(page, coordinates) : await getSelectors(page, coordinates); - + const bestSelector = getBestSelectorForAction( { type: action, From 7f63f29f43c65b9479da70eb35161e00fdeb3918 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Mon, 23 Sep 2024 17:28:00 +0530 Subject: [PATCH 08/20] feat: define tagName & innerText in decision modal --- src/components/molecules/InterpretationButtons.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/molecules/InterpretationButtons.tsx b/src/components/molecules/InterpretationButtons.tsx index 41196504..467f5cf9 100644 --- a/src/components/molecules/InterpretationButtons.tsx +++ b/src/components/molecules/InterpretationButtons.tsx @@ -28,9 +28,11 @@ export const InterpretationButtons = ({ enableStepping }: InterpretationButtonsP pair: WhereWhatPair | null, actionType: string, selector: string, + tagName: string, + innerText: string, action: string, open: boolean - }>({ pair: null, actionType: '', selector: '', action: '', open: false }); + }>({ pair: null, actionType: '', selector: '', action: '', tagName: '', innerText: '', open: false }); const { socket } = useSocketStore(); const { notify } = useGlobalInfoStore(); From 2a308f11a0effe7a094b413ae3758be54e683f7d Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Mon, 23 Sep 2024 17:28:32 +0530 Subject: [PATCH 09/20] feat: handle tagName & innerText in decision handler --- src/components/molecules/InterpretationButtons.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/molecules/InterpretationButtons.tsx b/src/components/molecules/InterpretationButtons.tsx index 467f5cf9..0e6a9e2a 100644 --- a/src/components/molecules/InterpretationButtons.tsx +++ b/src/components/molecules/InterpretationButtons.tsx @@ -50,7 +50,7 @@ export const InterpretationButtons = ({ enableStepping }: InterpretationButtonsP const decisionHandler = useCallback( ({ pair, actionType, lastData } - : { pair: WhereWhatPair | null, actionType: string, lastData: { selector: string, action: string } }) => { + : { pair: WhereWhatPair | null, actionType: string, lastData: { selector: string, action: string, tagName: string, innerText: string } }) => { const { selector, action } = lastData; setDecisionModal((prevState) => { return { From fd99b6453772f33b09f93dcb242dad716f9b6d11 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Mon, 23 Sep 2024 17:29:23 +0530 Subject: [PATCH 10/20] feat: display in ui --- src/components/molecules/InterpretationButtons.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/molecules/InterpretationButtons.tsx b/src/components/molecules/InterpretationButtons.tsx index 0e6a9e2a..99c575cb 100644 --- a/src/components/molecules/InterpretationButtons.tsx +++ b/src/components/molecules/InterpretationButtons.tsx @@ -51,13 +51,15 @@ export const InterpretationButtons = ({ enableStepping }: InterpretationButtonsP const decisionHandler = useCallback( ({ pair, actionType, lastData } : { pair: WhereWhatPair | null, actionType: string, lastData: { selector: string, action: string, tagName: string, innerText: string } }) => { - const { selector, action } = lastData; + const { selector, action, tagName, innerText } = lastData; setDecisionModal((prevState) => { return { pair, actionType, selector, action, + tagName, + innerText, open: true, } }) @@ -66,7 +68,7 @@ export const InterpretationButtons = ({ enableStepping }: InterpretationButtonsP const handleDecision = (decision: boolean) => { const { pair, actionType } = decisionModal; socket?.emit('decision', { pair, actionType, decision }); - setDecisionModal({ pair: null, actionType: '', selector: '', action: '', open: false }); + setDecisionModal({ pair: null, actionType: '', selector: '', action: '', tagName: '', innerText: '', open: false }); } const handleDescription = () => { @@ -80,6 +82,8 @@ export const InterpretationButtons = ({ enableStepping }: InterpretationButtonsP [previous action: {decisionModal.action}]
{decisionModal.selector}
+
{decisionModal.tagName}
+
{decisionModal.innerText}
); default: return null; From daeeb6e1fdd0ec2bb5e0a258c4155f1d4193fc1c Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Mon, 23 Sep 2024 17:35:34 +0530 Subject: [PATCH 11/20] feat: better message? --- src/components/molecules/InterpretationButtons.tsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/components/molecules/InterpretationButtons.tsx b/src/components/molecules/InterpretationButtons.tsx index 99c575cb..cd06a9b2 100644 --- a/src/components/molecules/InterpretationButtons.tsx +++ b/src/components/molecules/InterpretationButtons.tsx @@ -80,10 +80,7 @@ export const InterpretationButtons = ({ enableStepping }: InterpretationButtonsP Do you want to use your previous selection as a condition for performing this action? - [previous action: {decisionModal.action}] -
{decisionModal.selector}
-
{decisionModal.tagName}
-
{decisionModal.innerText}
+ [Your previous action was: {decisionModal.action}, on {decisionModal.innerText} {decisionModal.tagName}]
); default: return null; From c984ffd94ef3a52fe78cdb44f9f8e4dbcc750813 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Mon, 23 Sep 2024 17:35:48 +0530 Subject: [PATCH 12/20] chore: lint --- src/components/molecules/InterpretationButtons.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/molecules/InterpretationButtons.tsx b/src/components/molecules/InterpretationButtons.tsx index cd06a9b2..84ece594 100644 --- a/src/components/molecules/InterpretationButtons.tsx +++ b/src/components/molecules/InterpretationButtons.tsx @@ -77,7 +77,7 @@ export const InterpretationButtons = ({ enableStepping }: InterpretationButtonsP return ( - Do you want to use your previous selection as a condition for performing this action? + Do you want to use your previous selection as a condition for performing this action? [Your previous action was: {decisionModal.action}, on {decisionModal.innerText} {decisionModal.tagName}] From 6149e9e619cb6480594ad439a02f7dd49df231ae Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Mon, 23 Sep 2024 17:41:13 +0530 Subject: [PATCH 13/20] feat: use Typography --- src/components/molecules/InterpretationButtons.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/molecules/InterpretationButtons.tsx b/src/components/molecules/InterpretationButtons.tsx index 84ece594..0a146810 100644 --- a/src/components/molecules/InterpretationButtons.tsx +++ b/src/components/molecules/InterpretationButtons.tsx @@ -80,7 +80,9 @@ export const InterpretationButtons = ({ enableStepping }: InterpretationButtonsP Do you want to use your previous selection as a condition for performing this action? - [Your previous action was: {decisionModal.action}, on {decisionModal.innerText} {decisionModal.tagName}] + Your previous action was: + {decisionModal.action}, on an element with text {decisionModal.innerText} + ); default: return null; From d4becc90aac6110777d82909fb987338472d21a0 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Mon, 23 Sep 2024 17:47:04 +0530 Subject: [PATCH 14/20] feat: capitalize first letter --- src/components/molecules/InterpretationButtons.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/molecules/InterpretationButtons.tsx b/src/components/molecules/InterpretationButtons.tsx index 0a146810..b61866e3 100644 --- a/src/components/molecules/InterpretationButtons.tsx +++ b/src/components/molecules/InterpretationButtons.tsx @@ -81,7 +81,7 @@ export const InterpretationButtons = ({ enableStepping }: InterpretationButtonsP Your previous action was: - {decisionModal.action}, on an element with text {decisionModal.innerText} + {decisionModal.action.charAt(0).toUpperCase() }, on an element with text {decisionModal.innerText} ); From 0919e5319dde7861f35b45e1865703736510bcf0 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Mon, 23 Sep 2024 17:50:51 +0530 Subject: [PATCH 15/20] fix: sliceeeeeeee --- src/components/molecules/InterpretationButtons.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/molecules/InterpretationButtons.tsx b/src/components/molecules/InterpretationButtons.tsx index b61866e3..4b97354a 100644 --- a/src/components/molecules/InterpretationButtons.tsx +++ b/src/components/molecules/InterpretationButtons.tsx @@ -81,7 +81,7 @@ export const InterpretationButtons = ({ enableStepping }: InterpretationButtonsP Your previous action was: - {decisionModal.action.charAt(0).toUpperCase() }, on an element with text {decisionModal.innerText} + {decisionModal.action.charAt(0).toUpperCase() + decisionModal.action.slice(1)}, on an element with text {decisionModal.innerText} ); From 0450e75bf7e8c4fc2e5a058cb5cc20278c9b7d58 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Mon, 23 Sep 2024 17:51:08 +0530 Subject: [PATCH 16/20] chore: lint --- src/components/molecules/InterpretationButtons.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/molecules/InterpretationButtons.tsx b/src/components/molecules/InterpretationButtons.tsx index 4b97354a..bf43270c 100644 --- a/src/components/molecules/InterpretationButtons.tsx +++ b/src/components/molecules/InterpretationButtons.tsx @@ -80,9 +80,9 @@ export const InterpretationButtons = ({ enableStepping }: InterpretationButtonsP Do you want to use your previous selection as a condition for performing this action? - Your previous action was: + Your previous action was: {decisionModal.action.charAt(0).toUpperCase() + decisionModal.action.slice(1)}, on an element with text {decisionModal.innerText} - + ); default: return null; From 2552fa6aa4b81eebc73ba6a7f2ce7e230c82f715 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Mon, 23 Sep 2024 17:51:53 +0530 Subject: [PATCH 17/20] feat: bold only action & text --- src/components/molecules/InterpretationButtons.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/molecules/InterpretationButtons.tsx b/src/components/molecules/InterpretationButtons.tsx index bf43270c..7adeeb91 100644 --- a/src/components/molecules/InterpretationButtons.tsx +++ b/src/components/molecules/InterpretationButtons.tsx @@ -81,7 +81,7 @@ export const InterpretationButtons = ({ enableStepping }: InterpretationButtonsP Your previous action was: - {decisionModal.action.charAt(0).toUpperCase() + decisionModal.action.slice(1)}, on an element with text {decisionModal.innerText} + {decisionModal.action.charAt(0).toUpperCase() + decisionModal.action.slice(1)} , on an element with text {decisionModal.innerText} ); From a4a98c67d894a1ee8cb6b746b9aa8774ffff7ca2 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Mon, 23 Sep 2024 17:52:17 +0530 Subject: [PATCH 18/20] fix: prettier --- src/components/molecules/InterpretationButtons.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/molecules/InterpretationButtons.tsx b/src/components/molecules/InterpretationButtons.tsx index 7adeeb91..c9f45be2 100644 --- a/src/components/molecules/InterpretationButtons.tsx +++ b/src/components/molecules/InterpretationButtons.tsx @@ -81,7 +81,9 @@ export const InterpretationButtons = ({ enableStepping }: InterpretationButtonsP Your previous action was: - {decisionModal.action.charAt(0).toUpperCase() + decisionModal.action.slice(1)} , on an element with text {decisionModal.innerText} + {decisionModal.action.charAt(0).toUpperCase() + decisionModal.action.slice(1)} , + on an element with text + {decisionModal.innerText} ); From 960c254b89c0f65801d4d12bb81c7938ef8c7018 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Mon, 23 Sep 2024 17:57:50 +0530 Subject: [PATCH 19/20] docs: fxn docs --- server/src/workflow-management/classes/Generator.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server/src/workflow-management/classes/Generator.ts b/server/src/workflow-management/classes/Generator.ts index d3084f92..7594a8f3 100644 --- a/server/src/workflow-management/classes/Generator.ts +++ b/server/src/workflow-management/classes/Generator.ts @@ -303,6 +303,10 @@ export class WorkflowGenerator { await this.addPairToWorkflowAndNotifyClient(pair, page); }; + /** + * Returns tag name and text content for the specified selector + * used in customAction for decision modal + */ private async getLastUsedSelectorInfo(page: Page, selector: string) { const elementHandle = await page.$(selector); if (elementHandle) { From 3807876a81d8d9879d8238d3bbdda2641a3a19b5 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Mon, 23 Sep 2024 17:58:45 +0530 Subject: [PATCH 20/20] chore: add todo --- server/src/workflow-management/classes/Generator.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/server/src/workflow-management/classes/Generator.ts b/server/src/workflow-management/classes/Generator.ts index 7594a8f3..0b303478 100644 --- a/server/src/workflow-management/classes/Generator.ts +++ b/server/src/workflow-management/classes/Generator.ts @@ -311,6 +311,7 @@ export class WorkflowGenerator { const elementHandle = await page.$(selector); if (elementHandle) { const tagName = await elementHandle.evaluate(el => (el as HTMLElement).tagName); + // TODO: based on tagName, send data. Always innerText won't hold true. For now, can roll. const innerText = await elementHandle.evaluate(el => (el as HTMLElement).innerText); return { tagName, innerText };