RenderedComponent<TComponent> Class
A component rendered by a ComponentTestHost, and the DOM nodes it renders. Its locators search the elements rendered by the component.
public sealed class RenderedComponent<TComponent> : LocatorScope where TComponent : IComponentType parameters
TComponent- The type of the component.
- Inheritance
LocatorScopeRenderedComponent<TComponent>
Properties
| Name | Description |
|---|---|
| ComponentId | Gets the identifier of the component in the renderer. |
| Host | Gets the test host that renders the component. |
| Instance | Gets the instance of the component. |
| Markup | Gets the HTML rendered by the component, formatted for snapshots. |
| Nodes | Gets the DOM nodes rendered by the component and its descendants, at the top level of its output. |
| RenderCount | Gets the number of times the component was rendered. |
ComponentId
RenderedComponent.csInstance
RenderedComponent.csGets the instance of the component.
public TComponent Instance { get; }Property value
TComponent
Markup
RenderedComponent.csNodes
RenderedComponent.csGets the DOM nodes rendered by the component and its descendants, at the top level of its output.
public IReadOnlyList<Node> Nodes { get; }Property value
RenderCount
RenderedComponent.csMethods
| Name | Description |
|---|---|
| Find(string) | Gets the first element rendered by the component that matches a CSS selector, now (see LocatorScope.Locator for a locator that waits). |
| Find<TElement>(string) | Gets the first element rendered by the component of a type that matches a CSS selector, now. |
| FindAll(string) | Gets the elements rendered by the component that match a CSS selector now, in document order. |
| FindComponent<TChild>() | Gets the first descendant component of a type, in render order. |
| FindComponents<TChild>() | Gets the descendant components of a type, in render order. |
| FindOrDefault(string) | Gets the first element rendered by the component that matches a CSS selector now, or null. |
| GetAccessibilitySnapshot() | Gets the accessibility tree of the elements rendered by the component, as a YAML snapshot (the format of the ARIA snapshots of Playwright). |
| GetMarkup(MarkupOptions?) | Gets the HTML rendered by the component, formatted for snapshots. |
| SetParametersAsync(Action<ComponentParameterCollectionBuilder<TComponent>>, CancellationToken) | Sets parameters of the component (the other parameters keep their values), and waits until the components are idle. |
| TakeScreenshotAsPng() | Takes a screenshot of the elements rendered by the component, encoded as PNG. |
Find overloads
Find(string)
RenderedComponent.csGets the first element rendered by the component that matches a CSS selector, now (see LocatorScope.Locator for a locator that waits).
Parameters
selectorstring- The CSS selector.
Returns
Element The element.
Exceptions
ElementNotFoundException- No element matches the selector.
Find<TElement>(string)
RenderedComponent.csGets the first element rendered by the component of a type that matches a CSS selector, now.
Type parameters
TElement- The type of the element.
Parameters
selectorstring- The CSS selector.
Returns
TElement The element.
Exceptions
ElementNotFoundException- No element of type
TElementmatches the selector.
FindAll(string)
RenderedComponent.csGets the elements rendered by the component that match a CSS selector now, in document order.
public IReadOnlyList<Element> FindAll(string selector)FindComponent<TChild>()
RenderedComponent.csGets the first descendant component of a type, in render order.
public RenderedComponent<TChild> FindComponent<TChild>() where TChild : IComponentType parameters
TChild- The type of the component.
Returns
RenderedComponent<TChild> The component.
Exceptions
ComponentNotFoundException- The component has no descendant of type
TChild.
FindComponents<TChild>()
RenderedComponent.csGets the descendant components of a type, in render order.
public IReadOnlyList<RenderedComponent<TChild>> FindComponents<TChild>() where TChild : IComponentType parameters
TChild- The type of the components.
Returns
IReadOnlyList<RenderedComponent<TChild>> The components.
FindOrDefault(string)
RenderedComponent.csGetAccessibilitySnapshot()
RenderedComponent.csGetMarkup(MarkupOptions?)
RenderedComponent.csGets the HTML rendered by the component, formatted for snapshots.
public string GetMarkup(MarkupOptions? options = null)Parameters
optionsMarkupOptions?- The options, or null for the default options.
Returns
string The HTML.
SetParametersAsync(Action<ComponentParameterCollectionBuilder<TComponent>>, CancellationToken)
RenderedComponent.csSets parameters of the component (the other parameters keep their values), and waits until the components are idle.
public Task SetParametersAsync(Action<ComponentParameterCollectionBuilder<TComponent>> parameters, CancellationToken cancellationToken = default)Parameters
parametersAction<ComponentParameterCollectionBuilder<TComponent>>- Sets the parameters.
cancellationTokenCancellationToken- A token to cancel the wait.
Returns
Task A task completed once the components are idle.
Exceptions
InvalidOperationException- The component is not a root component.
TakeScreenshotAsPng()
RenderedComponent.csTakes a screenshot of the elements rendered by the component, encoded as PNG.
public byte[] TakeScreenshotAsPng()