IFrame Interface#
Represents a frame within a page (including the main frame).
public interface IFrame
Remarks#
Locators created from a frame resolve inside that frame. A selector that matches in one frame and in another matches only the frame it was created from.
Properties#
ChildFrames Property#
Gets the child frames, in the order they attached, which is the order they appear in the document unless the page inserted one later.
System.Collections.Generic.IReadOnlyList<Motus.Abstractions.IFrame> ChildFrames { get; }
Property Value#
System.Collections.Generic.IReadOnlyList<IFrame>
IsDetached Property#
Gets whether the frame has been removed from its page.
bool IsDetached { get; }
Property Value#
Remarks#
A detached frame is a handle to something that no longer exists. Operations on it fail, and this is how to tell that apart from a selector that simply did not match.
Name Property#
Gets the frame name as specified in the tag.
string Name { get; }
Property Value#
Page Property#
Gets the page that owns this frame.
Motus.Abstractions.IPage Page { get; }
Property Value#
ParentFrame Property#
Gets the parent frame, or null if this is the main frame.
Motus.Abstractions.IFrame? ParentFrame { get; }
Property Value#
Url Property#
Gets the current URL of the frame.
string Url { get; }
Property Value#
Methods#
AccessibilitySnapshotAsync(CancellationToken) Method#
Returns the accessibility tree of this frame's document.
System.Threading.Tasks.Task<Motus.Abstractions.AccessibilitySnapshot> AccessibilitySnapshotAsync(System.Threading.CancellationToken ct=default(System.Threading.CancellationToken));
Parameters#
ct System.Threading.CancellationToken
Cancellation token.
Returns#
System.Threading.Tasks.Task<AccessibilitySnapshot>
The frame's accessibility tree, with each node carrying the backend DOM node
identifier that LocatorByBackendNodeId(long) can target.
Remarks#
The tree stops at this frame's document. A child frame appears as the element that hosts it and nothing more, so reading inside a child means asking that frame in turn. This is the only way to see into a frame the browser renders in its own process, whose contents the page's own tree does not contain at all.
AddScriptTagAsync(string, string) Method#
Adds a script tag to the frame.
System.Threading.Tasks.Task<Motus.Abstractions.IElementHandle> AddScriptTagAsync(string? url=null, string? content=null);
Parameters#
url System.String
URL of the script to add.
content System.String
Inline script content.
Returns#
System.Threading.Tasks.Task<IElementHandle>
An element handle to the script element.
AddStyleTagAsync(string, string) Method#
Adds a style tag to the frame.
System.Threading.Tasks.Task<Motus.Abstractions.IElementHandle> AddStyleTagAsync(string? url=null, string? content=null);
Parameters#
url System.String
URL of the stylesheet to add.
content System.String
Inline CSS content.
Returns#
System.Threading.Tasks.Task<IElementHandle>
An element handle to the style element.
ContentAsync() Method#
Returns the full HTML content of the frame.
System.Threading.Tasks.Task<string> ContentAsync();
Returns#
System.Threading.Tasks.Task<System.String>
The HTML content.
EvaluateAsync<T>(string, object) Method#
Evaluates a JavaScript expression in the frame context.
System.Threading.Tasks.Task<T> EvaluateAsync<T>(string expression, object? arg=null);
Type parameters#
T
The expected return type.
Parameters#
expression System.String
The JavaScript expression to evaluate.
arg System.Object
Optional argument to pass to the expression.
Returns#
System.Threading.Tasks.Task<T>
The result of the evaluation.
EvaluateAsync<T>(string, object, EvaluateOptions) Method#
Evaluates a JavaScript expression in the frame, in the specified world.
System.Threading.Tasks.Task<T> EvaluateAsync<T>(string expression, object? arg, Motus.Abstractions.EvaluateOptions options);
Type parameters#
T
The expected return type.
Parameters#
expression System.String
The JavaScript expression to evaluate.
arg System.Object
Optional argument to pass to the expression.
options EvaluateOptions
Evaluation options, including which world to run in.
Returns#
System.Threading.Tasks.Task<T>
The result of the evaluation.
Remarks#
An isolated world shares the frame's document but not its globals, so the DOM is fully
present while anything the application defined on window is not. Reading application
state needs Main, which is what the overload without options
uses.
GetByAltText(string, Nullable<bool>) Method#
Creates a locator for the element matching the specified alt text.
Motus.Abstractions.ILocator GetByAltText(string text, System.Nullable<bool> exact=null);
Parameters#
text System.String
The alt text to match.
exact System.Nullable<System.Boolean>
Whether to match the text exactly.
Returns#
ILocator
A locator for the matching elements.
GetByLabel(string, Nullable<bool>) Method#
Creates a locator for the element matching the specified label.
Motus.Abstractions.ILocator GetByLabel(string text, System.Nullable<bool> exact=null);
Parameters#
text System.String
The label text to match.
exact System.Nullable<System.Boolean>
Whether to match the text exactly.
Returns#
ILocator
A locator for the matching elements.
GetByPlaceholder(string, Nullable<bool>) Method#
Creates a locator for the element matching the specified placeholder.
Motus.Abstractions.ILocator GetByPlaceholder(string text, System.Nullable<bool> exact=null);
Parameters#
text System.String
The placeholder text to match.
exact System.Nullable<System.Boolean>
Whether to match the text exactly.
Returns#
ILocator
A locator for the matching elements.
GetByRole(string, string) Method#
Creates a locator for the element matching the specified role.
Motus.Abstractions.ILocator GetByRole(string role, string? name=null);
Parameters#
role System.String
The ARIA role to match.
name System.String
Optional accessible name to filter by.
Returns#
ILocator
A locator for the matching elements.
GetByTestId(string) Method#
Creates a locator for the element matching the specified test ID.
Motus.Abstractions.ILocator GetByTestId(string testId);
Parameters#
testId System.String
The test ID to match.
Returns#
ILocator
A locator for the matching elements.
GetByText(string, Nullable<bool>) Method#
Creates a locator for the element matching the specified text.
Motus.Abstractions.ILocator GetByText(string text, System.Nullable<bool> exact=null);
Parameters#
text System.String
The text to match.
exact System.Nullable<System.Boolean>
Whether to match the text exactly.
Returns#
ILocator
A locator for the matching elements.
GetByTitle(string, Nullable<bool>) Method#
Creates a locator for the element matching the specified title.
Motus.Abstractions.ILocator GetByTitle(string text, System.Nullable<bool> exact=null);
Parameters#
text System.String
The title text to match.
exact System.Nullable<System.Boolean>
Whether to match the text exactly.
Returns#
ILocator
A locator for the matching elements.
GotoAsync(string, NavigationOptions) Method#
Navigates the frame to the specified URL, leaving the rest of the page where it is.
System.Threading.Tasks.Task<Motus.Abstractions.IResponse?> GotoAsync(string url, Motus.Abstractions.NavigationOptions? options=null);
Parameters#
url System.String
The URL to navigate to.
options NavigationOptions
Navigation options.
Returns#
System.Threading.Tasks.Task<IResponse>
The response of the navigation, or null.
Remarks#
A frame other than the main frame reports only that it has finished loading, with no separate signal for its DOM being ready, so DOMContentLoaded and Load both wait for the same point. NetworkIdle is measured across the whole page rather than for this frame alone. Navigating the main frame navigates the page.
Locator(string, LocatorOptions) Method#
Creates a locator for the specified selector.
Motus.Abstractions.ILocator Locator(string selector, Motus.Abstractions.LocatorOptions? options=null);
Parameters#
selector System.String
The selector to locate elements.
options LocatorOptions
Locator options.
Returns#
ILocator
A locator for the matching elements.
LocatorByBackendNodeId(long) Method#
Creates a locator for the element with the given backend DOM node identifier, as reported by AccessibilitySnapshotAsync(CancellationToken).
Motus.Abstractions.ILocator LocatorByBackendNodeId(long backendNodeId);
Parameters#
backendNodeId System.Int64
The backend DOM node identifier.
Returns#
ILocator
A locator for that element, resolved through this frame.
Remarks#
Backend node identifiers last only as long as the snapshot that reported them, and are resolved against the session that owns this frame, so a node read from one frame's tree must be addressed through that same frame.
SetContentAsync(string, NavigationOptions) Method#
Sets the HTML content of the frame.
System.Threading.Tasks.Task SetContentAsync(string html, Motus.Abstractions.NavigationOptions? options=null);
Parameters#
html System.String
The HTML content to set.
options NavigationOptions
Navigation options.
Returns#
TitleAsync() Method#
Returns the title of the frame.
System.Threading.Tasks.Task<string> TitleAsync();
Returns#
System.Threading.Tasks.Task<System.String>
The frame title.
WaitForFunctionAsync<T>(string, object, Nullable<double>) Method#
Waits for a function to return a truthy value.
System.Threading.Tasks.Task<T> WaitForFunctionAsync<T>(string expression, object? arg=null, System.Nullable<double> timeout=null);
Type parameters#
T
The expected return type.
Parameters#
expression System.String
The JavaScript expression to evaluate.
arg System.Object
Optional argument to pass to the expression.
timeout System.Nullable<System.Double>
Maximum time in milliseconds to wait.
Returns#
System.Threading.Tasks.Task<T>
The return value of the function.
WaitForLoadStateAsync(Nullable<LoadState>, Nullable<double>) Method#
Waits for the specified load state.
System.Threading.Tasks.Task WaitForLoadStateAsync(System.Nullable<Motus.Abstractions.LoadState> state=null, System.Nullable<double> timeout=null);
Parameters#
state System.Nullable<LoadState>
The load state to wait for.
timeout System.Nullable<System.Double>
Maximum time in milliseconds to wait.
Returns#
WaitForURLAsync(string, NavigationOptions) Method#
Waits for a matching URL navigation.
System.Threading.Tasks.Task WaitForURLAsync(string urlPattern, Motus.Abstractions.NavigationOptions? options=null);
Parameters#
urlPattern System.String
The URL pattern to match.
options NavigationOptions
Navigation options.