app-walkthrough
Version:
An intuitive guided walkthrough library with UI highlighting and voice narration for web apps.
25 lines (24 loc) • 713 B
JavaScript
export function convertToCss(selector) {
if (!selector.selector)
return undefined;
const s = selector.selector;
switch (selector.selectorType) {
case "testId":
return `[data-testid="${s}"]`;
case "input":
return `input[name="${s}"]`;
case "css":
case undefined:
return s;
default:
console.warn("Unsupported selectorType, skipping:", selector.selectorType);
return undefined;
}
}
// 选择器生成函数
export function createTestidSelector(testId) {
return `[data-testid="${testId}"]`;
}
export function getRadioSelector(value) {
return `input[type="radio"][value="${value}"]`;
}