feat: click, hover, dnd actions
This commit is contained in:
24
server/src/workflow-management/utils.ts
Normal file
24
server/src/workflow-management/utils.ts
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import { Action, ActionType, TagName } from "../types";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A helper function to get the best selector for the specific user action.
|
||||||
|
* @param action The user action.
|
||||||
|
* @returns {string|null}
|
||||||
|
* @category WorkflowManagement-Selectors
|
||||||
|
*/
|
||||||
|
export const getBestSelectorForAction = (action: Action) => {
|
||||||
|
switch (action.type) {
|
||||||
|
case ActionType.Click:
|
||||||
|
case ActionType.Hover:
|
||||||
|
case ActionType.DragAndDrop: {
|
||||||
|
const selectors = action.selectors;
|
||||||
|
// less than 25 characters, and element only has text inside
|
||||||
|
const textSelector =
|
||||||
|
selectors?.text?.length != null &&
|
||||||
|
selectors?.text?.length < 25 &&
|
||||||
|
action.hasOnlyText
|
||||||
|
? `text=${selectors.text}`
|
||||||
|
: null;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user