Table of Contents

Class FilterElementsBuilder

Namespace
CSF.Screenplay.Selenium.Builders
Assembly
CSF.Screenplay.Selenium.dll

A builder class for filtering Selenium elements based on a specification.

public class FilterElementsBuilder
Inheritance
FilterElementsBuilder
Inherited Members

Examples

Here is a sample usage which combines both the QueryPredicatePrototypeBuilder and FilterElementsBuilder classes:

using static CSF.Screenplay.Selenium.PerformableBuilder;

var buyNowButtons = await actor.PerformAsync(Filter(someElements).ForThoseWhich(have => have.Clickability(true).And(have.Text("Buy now")), cancellationToken);

The code sample above assumes that actor is an instance of ICanPerform, that someElements is a collection of SeleniumElement instances, and that cancellationToken is a CancellationToken instance. It would filter the elements in someElements to only those which are clickable and have the text "Buy now".

Constructors

FilterElementsBuilder(SeleniumElementCollection)

Initializes a new instance of the FilterElementsBuilder class.

public FilterElementsBuilder(SeleniumElementCollection elements)

Parameters

elements SeleniumElementCollection

The collection of Selenium elements to be filtered.

Methods

ForThoseWhich(ISpecificationFunction<SeleniumElement>)

Specifies the specification which will be used to filter the collection of elements.

public NamedFilterElementsBuilder ForThoseWhich(ISpecificationFunction<SeleniumElement> specification)

Parameters

specification ISpecificationFunction<SeleniumElement>

The specification function to filter elements.

Returns

NamedFilterElementsBuilder

A builder which permits naming the filtered elements.

Remarks

Consider using the QueryPredicatePrototypeBuilder class to create the specification function which is passed to this method. Do this via the other overload to this method..

ForThoseWhich(Func<QueryPredicatePrototypeBuilder, IBuildsElementPredicates>)

Specifies the specification which will be used to filter the collection of elements.

public NamedFilterElementsBuilder ForThoseWhich(Func<QueryPredicatePrototypeBuilder, IBuildsElementPredicates> predicatePrototype)

Parameters

predicatePrototype Func<QueryPredicatePrototypeBuilder, IBuildsElementPredicates>

A lambda function which builds a predicate prototype from a fluent interface.

Returns

NamedFilterElementsBuilder

A builder which permits naming the filtered elements.

Examples

Here is a sample usage which combines both the QueryPredicatePrototypeBuilder and FilterElementsBuilder classes:

using static CSF.Screenplay.Selenium.PerformableBuilder;

var buyNowButtons = await actor.PerformAsync(Filter(someElements).ForThoseWhich(have => have.Clickability(true).And(have.Text("Buy now")), cancellationToken);

The code sample above assumes that actor is an instance of ICanPerform, that someElements is a collection of SeleniumElement instances, and that cancellationToken is a CancellationToken instance. It would filter the elements in someElements to only those which are clickable and have the text "Buy now".

Remarks

This overload uses the QueryPredicatePrototypeBuilder class to create the specification function which is passed to this method.

See Also