Table of Contents

Class FindElement

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

Represents a question that finds a single element within a specified target.

public class FindElement : ISingleElementPerformableWithResult<SeleniumElement>, ICanReportForElement
Inheritance
FindElement
Implements
Inherited Members

Remarks

This question is used to find a single element within a target. If more than one element would have been matched by the specified locator then the first matching element (only) will be returned.

Consumers are encouraged to specify a human-readable name for the collection of elements which are found, this will be kept with the returned collection of elements and will be visible in reports.

Note that if no element is found, which is a descendent of the target and which is matched by the locator, then the PerformAsAsync(ICanPerform, IWebDriver, Lazy<SeleniumElement>, CancellationToken) method of this question will return a value task of a null reference.

Constructors

FindElement(string, Locator)

Initializes a new instance of the FindElement class.

public FindElement(string elementsName = null, Locator locatorBasedMatcher = null)

Parameters

elementsName string

An optional short, descriptive, human-readable name to give to the collection of elements which are found.

locatorBasedMatcher Locator

An optional Locator which should be used to filter the elements which are returned.

Methods

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<SeleniumElement> 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<SeleniumElement>

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