Table of Contents

Class UnnamedWaitBuilder

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

Provides a builder for configuring wait actions in Selenium.

public class UnnamedWaitBuilder : NamedWaitBuilder, IGetsPerformable
Inheritance
UnnamedWaitBuilder
Implements
Inherited Members

Remarks

This class provides methods for configuring various aspects of a wait action, such as timeout, polling interval, and ignored exception types. It also provides a way to set a human-readable name for the wait condition.

Constructors

UnnamedWaitBuilder(Func<IWebDriver, bool>)

Initializes a new instance of the UnnamedWaitBuilder class with a specified timeout.

public UnnamedWaitBuilder(Func<IWebDriver, bool> predicate)

Parameters

predicate Func<IWebDriver, bool>

The predicate which ends the wait when it returns a successful result.

Methods

ForAtMost(TimeSpan)

Configures the wait action to use a specified maximum timeout.

public UnnamedWaitBuilder ForAtMost(TimeSpan timeout)

Parameters

timeout TimeSpan

The maximum amount of time to wait.

Returns

UnnamedWaitBuilder

The same wait builder, so that calls may be chained.

Remarks

If the timeout is reached before the predicate function returns a true result then the wait will end, and an exception will be raised.

This method is optional. If it is not called then the default behaviour of the Wait question will be used. See the documentation for that class for more details.

GetWaitUntilPredicate()

Gets the wait-until predicate, which wraps both the predicate logic and a human-readable name.

protected override WaitUntilPredicate<bool> GetWaitUntilPredicate()

Returns

WaitUntilPredicate<bool>

The wait-until predicate instance.

IgnoringTheseExceptionTypes(params Type[])

Configures the wait action which will be created to ignore exceptions of the specified types.

public UnnamedWaitBuilder IgnoringTheseExceptionTypes(params Type[] ignoredExceptionTypes)

Parameters

ignoredExceptionTypes Type[]

A collection of exception types to be ignored when polling the predicate function.

Returns

UnnamedWaitBuilder

Remarks

When evaluating the predicate/condition function, the WebDriver may throw exceptions, such as if an element doesn't exist. Use this method to specify a collection of exception types which should be ignored. If an exception thrown of one of these types then the WebDriver wait will treat it the same as a false outcome and continue to poll the predicate.

This method is optional. If it is not called then no exception types will be ignored.

Exceptions

InvalidOperationException

Thrown if the ignored exception types have already been set.

Named(string)

Configures the wait action to use a short, descriptive, human-readable name summarising what the performable is waiting for.

public UnnamedWaitBuilder Named(string name)

Parameters

name string

The name to use.

Returns

UnnamedWaitBuilder

The same wait builder, so that calls may be chained.

Remarks

Use of this method is optional but strongly recommended. Giving the wait performable a name will make it easier to understand.

Exceptions

ArgumentNullException

Thrown if the name is null.

InvalidOperationException

Thrown if the name has already been set.

WithPollingInterval(TimeSpan)

Configures the wait action which will be created to use a specified polling interval.

public UnnamedWaitBuilder WithPollingInterval(TimeSpan pollingInterval)

Parameters

pollingInterval TimeSpan

The polling interval to use.

Returns

UnnamedWaitBuilder

The same wait builder, so that calls may be chained.

Remarks

The polling interval is the amount of time that the WebDriver will wait between each evaluation of the predicate function.

This method is optional. If it is not called then Screenplay will not specify a polling interval. Selenium will then use its own default interval, which is 500ms.

Choosing a polling interval is a balance between responsiveness and resource usage. A shorter polling interval may lead to quicker detection of the condition being met (a more responsive predicate), but at the cost of increased network usage as more round-trips are made to the WebDriver. Conversely, a longer polling interval reduces network traffic but may result in a less responsive predicate. If you are not sure what to choose, it's recommended not to use this method; use the default provided by Selenium.

Exceptions

InvalidOperationException

Thrown if the polling interval has already been set.