Table of Contents

Class GetShadowRootWithJavaScript

Namespace
CSF.Screenplay.Selenium.Questions
Assembly
CSF.Screenplay.Selenium.dll

A Screenplay Question which gets the Shadow Root element from the specified Selenium Element, using the simple JavaScript technique.

public class GetShadowRootWithJavaScript : ISingleElementPerformableWithResult<ShadowRoot>, ICanReportForElement, IHasCustomTypeName
Inheritance
GetShadowRootWithJavaScript
Implements
Inherited Members

Remarks

This is used when working with web pages which use The Shadow DOM technique. This question allows Screenplay to 'pierce' the Shadow DOM and get the Shadow Root element, so that the Performance may continue and interact with elements which are inside the Shadow DOM.

Note that the SeleniumElement which is returned from this question is not a fully-fledged Selenium Element. It may be used only to get/find elements from inside the Shadow DOM. Use with any other performables will raise NotSupportedException.

The SeleniumElement passed to this performable as a parameter must be the Shadow Host element.

This technique is known to work on older Chromium versions (before 96) and Safari.

Methods

GetHumanReadableTypeName()

Gets a human-readable name of the type of the current instance.

public string GetHumanReadableTypeName()

Returns

string

A human-readable name of the .NET type of the current instance, which could (for example) be qualified with additional context, such as a wrapped implementation.

Remarks

See the remarks on IHasCustomTypeName; this does not need to be the same as GetType().

GetReportFragment(Actor, Lazy<SeleniumElement>, IFormatsReportFragment)

Counterpart to GetReportFragment(Actor, IFormatsReportFragment) except that this method also offers a Selenium element.

public ReportFragment GetReportFragment(Actor actor, Lazy<SeleniumElement> element, IFormatsReportFragment formatter)

Parameters

actor Actor

An actor for whom to write the report fragment

element Lazy<SeleniumElement>

The Selenium element for which the report is being written

formatter IFormatsReportFragment

A report-formatting service

Returns

ReportFragment

A human-readable report fragment.

Remarks

Please see the documentation for GetReportFragment(Actor, IFormatsReportFragment) for more information.

PerformAsAsync(ICanPerform, IWebDriver, Lazy<SeleniumElement>, CancellationToken)

Counterpart to PerformAsAsync(ICanPerform, CancellationToken) except that this method also offers a Selenium WebDriver and element.

public ValueTask<ShadowRoot> PerformAsAsync(ICanPerform actor, IWebDriver webDriver, Lazy<SeleniumElement> element, CancellationToken cancellationToken = default)

Parameters

actor ICanPerform

The actor that is performing.

webDriver IWebDriver

The Selenium WebDriver provided from the actor's abilities.

element Lazy<SeleniumElement>

The single Selenium Element upon which this method should operate.

cancellationToken CancellationToken

An optional cancellation token by which to abort the performable.

Returns

ValueTask<ShadowRoot>

A task which exposes a strongly-typed 'result' value when the performable represented by the current instance is complete.