ISelectorStrategy Interface#
Defines a custom element-targeting strategy beyond the built-in CSS, XPath, and text selectors.
public interface ISelectorStrategy
Properties#
Priority Property#
Gets the precedence when multiple strategies can resolve the same selector. Higher priority wins. Used by the recorder's selector inference to rank candidates.
int Priority { get; }
Property Value#
StrategyName Property#
Gets the prefix used in selector strings (e.g. "data-test" for data-test=login-btn).
string StrategyName { get; }
Property Value#
Methods#
GenerateSelector(IElementHandle, CancellationToken) Method#
Given an element handle, generates the best selector for it using this strategy. Returns null if this strategy cannot produce a selector for the element.
System.Threading.Tasks.Task<string?> GenerateSelector(Motus.Abstractions.IElementHandle element, System.Threading.CancellationToken ct=default(System.Threading.CancellationToken));
Parameters#
element IElementHandle
The element to generate a selector for.
ct System.Threading.CancellationToken
Cancellation token.
Returns#
System.Threading.Tasks.Task<System.String>
The generated selector, or null.
ResolveAsync(string, IFrame, bool, CancellationToken) Method#
Resolves the selector expression to a list of matching elements within the given frame.
System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<Motus.Abstractions.IElementHandle>> ResolveAsync(string selector, Motus.Abstractions.IFrame frame, bool pierceShadow=true, System.Threading.CancellationToken ct=default(System.Threading.CancellationToken));
Parameters#
selector System.String
The selector expression to resolve.
frame IFrame
The frame to search within.
pierceShadow System.Boolean
Whether to descend into open shadow roots when resolving.
ct System.Threading.CancellationToken
Cancellation token.
Returns#
System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<IElementHandle>>
A list of matching elements.