(params: {
session: SessionState | undefined;
selectorExpression: string;
})
| 7 | export type DirectIosSelectorTarget = ElementSelectorTapOptions & { raw: string }; |
| 8 | |
| 9 | export function readSimpleIosSelectorTarget(params: { |
| 10 | session: SessionState | undefined; |
| 11 | selectorExpression: string; |
| 12 | }): DirectIosSelectorTarget | null { |
| 13 | const { session, selectorExpression } = params; |
| 14 | if (!session) return null; |
| 15 | if (!isIosFamily(session.device)) return null; |
| 16 | if (session.postGestureStabilization) return null; |
| 17 | const chain = tryParseSelectorChain(selectorExpression); |
| 18 | if (!chain) return null; |
| 19 | if (chain.selectors.length !== 1) return null; |
| 20 | const selector = chain.selectors[0]; |
| 21 | if (!selector || selector.terms.length !== 1) return null; |
| 22 | const term = selector.terms[0]; |
| 23 | if (!term || typeof term.value !== 'string') return null; |
| 24 | if (!isRunnerNativeSelectorKey(term.key)) return null; |
| 25 | return { key: term.key, value: term.value, raw: selector.raw }; |
| 26 | } |
| 27 | |
| 28 | function isRunnerNativeSelectorKey(key: string): key is DirectIosSelectorTarget['key'] { |
| 29 | return key === 'id' || key === 'label' || key === 'text' || key === 'value'; |
no test coverage detected