feat: click, hover, dnd actions

This commit is contained in:
karishmas6
2024-06-06 05:42:23 +05:30
parent 88b2fe4c2e
commit 343c34ca3b

View 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;
}
}