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
actorActorAn actor for whom to write the report fragment
elementLazy<SeleniumElement>The Selenium element for which the report is being written
formatterIFormatsReportFragmentA 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
actorICanPerformThe actor that is performing.
webDriverIWebDriverThe Selenium WebDriver provided from the actor's abilities.
elementLazy<SeleniumElement>The single Selenium Element upon which this method should operate.
cancellationTokenCancellationTokenAn 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.