Table of Contents

Class PerformableBuilder

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

Builder type for creating performables which interact with Selenium WebDriver via Screenplay.

public static class PerformableBuilder
Inheritance
PerformableBuilder
Inherited Members

Remarks

Consume this class from your own Screenplay logic with using static CSF.Screenplay.Selenium.PerformableBuilder;.

Methods

ClearAllDomainCookies()

Gets a performable action which clears all cookies for the current domain.

public static IPerformable ClearAllDomainCookies()

Returns

IPerformable

A performable action

ClearLocalStorage()

Gets a performable action which clears the local storage for the current domain.

public static IPerformable ClearLocalStorage()

Returns

IPerformable

A performable action

Remarks

This method gets a performable which will throw an exception if the WebDriver does not support the execution of JavaScript. To avoid this, consider using ClearLocalStorageIfSupported() instead.

ClearLocalStorageIfSupported()

Gets a performable action which clears the local storage for the current domain if the WebDriver supports it.

public static IPerformable ClearLocalStorageIfSupported()

Returns

IPerformable

A performable action

Remarks

This method gets a performable which will do nothing if the WebDriver does not support execution of JavaScript.

ClearTheContentsOf(ITarget)

Gets a performable action which clears the contents of the specified target element.

public static IPerformable ClearTheContentsOf(ITarget target)

Parameters

target ITarget

The target element whose contents will be cleared.

Returns

IPerformable

A performable action

ClickOn(ITarget)

Gets a performable action which represents an actor clicking on a specified target element.

public static IPerformable ClickOn(ITarget target)

Parameters

target ITarget

The target element on which to click.

Returns

IPerformable

A performable action

DeleteTheCookieNamed(string)

Gets a performable action which deletes a single named cookie.

public static IPerformable DeleteTheCookieNamed(string cookieName)

Parameters

cookieName string

Returns

IPerformable

A performable action

DeselectEverythingFrom(ITarget)

Gets a performable which represents an actor deselecting everything from a <select> element.

public static IPerformable DeselectEverythingFrom(ITarget target)

Parameters

target ITarget

A target which represents an HTML <select> element

Returns

IPerformable

A performable action

Remarks

As might be expected, the target parameter must represent a <select> element or the resulting performable will raise an exception.

DeselectTheOption(int)

Gets a builder which will create a performable which represents an actor deselecting a specified option from a <select> element.

public static FromTargetActionBuilder DeselectTheOption(int optionIndex)

Parameters

optionIndex int

The zero-based index of an option to deselect

Returns

FromTargetActionBuilder

A builder by which a target element is chosen

Remarks

This overload deselects the option by its zero-based index. As might be expected, the target which is specified in the builder must represent a <select> element or the resulting performable will raise an exception.

DeselectTheOption(string)

Gets a builder which will create a performable which represents an actor deselecting a specified option from a <select> element.

public static FromTargetActionBuilder DeselectTheOption(string optionText)

Parameters

optionText string

The text of the option to deselect

Returns

FromTargetActionBuilder

A builder by which a target element is chosen

Remarks

This overload deselects the option by its displayed text. As might be expected, the target which is specified in the builder must represent a <select> element or the resulting performable will raise an exception.

DeselectTheOptionWithValue(string)

Gets a builder which will create a performable which represents an actor deselecting a specified option from a <select> element.

public static FromTargetActionBuilder DeselectTheOptionWithValue(string optionValue)

Parameters

optionValue string

The underlying value of the option to deselect

Returns

FromTargetActionBuilder

A builder by which a target element is chosen

Remarks

This overload deselects the option by its underlying value attribute, instead of its displayed text. As might be expected, the target which is specified in the builder must represent a <select> element or the resulting performable will raise an exception.

EnterTheText(params string[])

Gets a builder for creating a performable action which represents an actor typing text into a target element.

public static SendKeysBuilder EnterTheText(params string[] text)

Parameters

text string[]

The text/keys for the actor to type.

Returns

SendKeysBuilder

A builder with which the user may select a target element.

Remarks

This may be used to send more than normal/printable text to the specified element. Special/nonprintable keys may be sent by using the OpenQA.Selenium.Keys class.

For convenience, especially when using the Selenium Keys class mentioned above, this method accepts a params array of strings. If an array of strings is passed, they will be concatenated together before being sent to the element as a single string. The array/params syntax is used to allow a consumer to pass multiple strings (perhaps each only one character) as a single argument, without needing to manually concatenate them.

ExecuteAScript(NamedScript)

Gets a a performable action which executes some JavaScript in the web browser.

public static ExecuteJavaScript ExecuteAScript(NamedScript script)

Parameters

script NamedScript

A named JavaScript.

Returns

ExecuteJavaScript

A builder object

Remarks

This is the recommended way to execute JavaScript in the browser. Use of the NamedScript, NamedScriptWithResult<TResult> and their other related generic types provides a simple type-safe mechanism of executing scripts.

Scripts executed with this method are not expected to return a result. If they do, their result is discarded and unused.

ExecuteAScript<TResult>(NamedScriptWithResult<TResult>)

Gets a a performable action which executes some JavaScript in the web browser, and gets the result returned by the script.

public static ExecuteJavaScriptAndGetResult<TResult> ExecuteAScript<TResult>(NamedScriptWithResult<TResult> script)

Parameters

script NamedScriptWithResult<TResult>

A named JavaScript.

Returns

ExecuteJavaScriptAndGetResult<TResult>

A builder object

Type Parameters

TResult

The expected return type of the script

Remarks

This is the recommended way to execute JavaScript in the browser. Use of the NamedScript, NamedScriptWithResult<TResult> and their other related generic types provides a simple type-safe mechanism of executing scripts.

ExecuteAScript<T1>(NamedScript<T1>, T1)

Gets a performable action which executes some JavaScript in the web browser.

public static ExecuteJavaScript ExecuteAScript<T1>(NamedScript<T1> script, T1 p1)

Parameters

script NamedScript<T1>

A named JavaScript.

p1 T1

The value for the first script parameter.

Returns

ExecuteJavaScript

A builder object

Type Parameters

T1

The type of script parameter 1

Remarks

This is the recommended way to execute JavaScript in the browser. Use of the NamedScript, NamedScriptWithResult<TResult> and their other related generic types provides a simple type-safe mechanism of executing scripts.

Scripts executed with this method are not expected to return a result. If they do, their result is discarded and unused.

ExecuteAScript<T1, TResult>(NamedScriptWithResult<T1, TResult>, T1)

Gets a performable action which executes some JavaScript in the web browser.

public static ExecuteJavaScriptAndGetResult<TResult> ExecuteAScript<T1, TResult>(NamedScriptWithResult<T1, TResult> script, T1 p1)

Parameters

script NamedScriptWithResult<T1, TResult>

A named JavaScript.

p1 T1

The value for the first script parameter.

Returns

ExecuteJavaScriptAndGetResult<TResult>

A builder object

Type Parameters

T1

The type of script parameter 1

TResult

The expected return type of the script

Remarks

This is the recommended way to execute JavaScript in the browser. Use of the NamedScript, NamedScriptWithResult<TResult> and their other related generic types provides a simple type-safe mechanism of executing scripts.

Scripts executed with this method are not expected to return a result. If they do, their result is discarded and unused.

ExecuteAScript<T1, T2>(NamedScript<T1, T2>, T1, T2)

Gets a performable action which executes some JavaScript in the web browser.

public static ExecuteJavaScript ExecuteAScript<T1, T2>(NamedScript<T1, T2> script, T1 p1, T2 p2)

Parameters

script NamedScript<T1, T2>

A named JavaScript.

p1 T1

The value for the first script parameter.

p2 T2

The value for the second script parameter.

Returns

ExecuteJavaScript

A builder object

Type Parameters

T1

The type of script parameter 1

T2

The type of script parameter 2

Remarks

This is the recommended way to execute JavaScript in the browser. Use of the NamedScript, NamedScriptWithResult<TResult> and their other related generic types provides a simple type-safe mechanism of executing scripts.

Scripts executed with this method are not expected to return a result. If they do, their result is discarded and unused.

ExecuteAScript<T1, T2, TResult>(NamedScriptWithResult<T1, T2, TResult>, T1, T2)

Gets a performable action which executes some JavaScript in the web browser.

public static ExecuteJavaScriptAndGetResult<TResult> ExecuteAScript<T1, T2, TResult>(NamedScriptWithResult<T1, T2, TResult> script, T1 p1, T2 p2)

Parameters

script NamedScriptWithResult<T1, T2, TResult>

A named JavaScript.

p1 T1

The value for the first script parameter.

p2 T2

The value for the second script parameter.

Returns

ExecuteJavaScriptAndGetResult<TResult>

A builder object

Type Parameters

T1

The type of script parameter 1

T2

The type of script parameter 2

TResult

The expected return type of the script

Remarks

This is the recommended way to execute JavaScript in the browser. Use of the NamedScript, NamedScriptWithResult<TResult> and their other related generic types provides a simple type-safe mechanism of executing scripts.

Scripts executed with this method are not expected to return a result. If they do, their result is discarded and unused.

ExecuteAScript<T1, T2, T3>(NamedScript<T1, T2, T3>, T1, T2, T3)

Gets a performable action which executes some JavaScript in the web browser.

public static ExecuteJavaScript ExecuteAScript<T1, T2, T3>(NamedScript<T1, T2, T3> script, T1 p1, T2 p2, T3 p3)

Parameters

script NamedScript<T1, T2, T3>

A named JavaScript.

p1 T1

The value for the first script parameter.

p2 T2

The value for the second script parameter.

p3 T3

The value for the third script parameter.

Returns

ExecuteJavaScript

A builder object

Type Parameters

T1

The type of script parameter 1

T2

The type of script parameter 2

T3

The type of script parameter 3

Remarks

This is the recommended way to execute JavaScript in the browser. Use of the NamedScript, NamedScriptWithResult<TResult> and their other related generic types provides a simple type-safe mechanism of executing scripts.

Scripts executed with this method are not expected to return a result. If they do, their result is discarded and unused.

ExecuteAScript<T1, T2, T3, TResult>(NamedScriptWithResult<T1, T2, T3, TResult>, T1, T2, T3)

Gets a performable action which executes some JavaScript in the web browser.

public static ExecuteJavaScriptAndGetResult<TResult> ExecuteAScript<T1, T2, T3, TResult>(NamedScriptWithResult<T1, T2, T3, TResult> script, T1 p1, T2 p2, T3 p3)

Parameters

script NamedScriptWithResult<T1, T2, T3, TResult>

A named JavaScript.

p1 T1

The value for the first script parameter.

p2 T2

The value for the second script parameter.

p3 T3

The value for the third script parameter.

Returns

ExecuteJavaScriptAndGetResult<TResult>

A builder object

Type Parameters

T1

The type of script parameter 1

T2

The type of script parameter 2

T3

The type of script parameter 3

TResult

The expected return type of the script

Remarks

This is the recommended way to execute JavaScript in the browser. Use of the NamedScript, NamedScriptWithResult<TResult> and their other related generic types provides a simple type-safe mechanism of executing scripts.

Scripts executed with this method are not expected to return a result. If they do, their result is discarded and unused.

ExecuteAScript<T1, T2, T3, T4>(NamedScript<T1, T2, T3, T4>, T1, T2, T3, T4)

Gets a performable action which executes some JavaScript in the web browser.

public static ExecuteJavaScript ExecuteAScript<T1, T2, T3, T4>(NamedScript<T1, T2, T3, T4> script, T1 p1, T2 p2, T3 p3, T4 p4)

Parameters

script NamedScript<T1, T2, T3, T4>

A named JavaScript.

p1 T1

The value for the first script parameter.

p2 T2

The value for the second script parameter.

p3 T3

The value for the third script parameter.

p4 T4

The value for the fourth script parameter.

Returns

ExecuteJavaScript

A builder object

Type Parameters

T1

The type of script parameter 1

T2

The type of script parameter 2

T3

The type of script parameter 3

T4

The type of script parameter 4

Remarks

This is the recommended way to execute JavaScript in the browser. Use of the NamedScript, NamedScriptWithResult<TResult> and their other related generic types provides a simple type-safe mechanism of executing scripts.

Scripts executed with this method are not expected to return a result. If they do, their result is discarded and unused.

ExecuteAScript<T1, T2, T3, T4, TResult>(NamedScriptWithResult<T1, T2, T3, T4, TResult>, T1, T2, T3, T4)

Gets a performable action which executes some JavaScript in the web browser.

public static ExecuteJavaScriptAndGetResult<TResult> ExecuteAScript<T1, T2, T3, T4, TResult>(NamedScriptWithResult<T1, T2, T3, T4, TResult> script, T1 p1, T2 p2, T3 p3, T4 p4)

Parameters

script NamedScriptWithResult<T1, T2, T3, T4, TResult>

A named JavaScript.

p1 T1

The value for the first script parameter.

p2 T2

The value for the second script parameter.

p3 T3

The value for the third script parameter.

p4 T4

The value for the fourth script parameter.

Returns

ExecuteJavaScriptAndGetResult<TResult>

A builder object

Type Parameters

T1

The type of script parameter 1

T2

The type of script parameter 2

T3

The type of script parameter 3

T4

The type of script parameter 4

TResult

The expected return type of the script

Remarks

This is the recommended way to execute JavaScript in the browser. Use of the NamedScript, NamedScriptWithResult<TResult> and their other related generic types provides a simple type-safe mechanism of executing scripts.

Scripts executed with this method are not expected to return a result. If they do, their result is discarded and unused.

ExecuteAScript<T1, T2, T3, T4, T5>(NamedScript<T1, T2, T3, T4, T5>, T1, T2, T3, T4, T5)

Gets a performable action which executes some JavaScript in the web browser.

public static ExecuteJavaScript ExecuteAScript<T1, T2, T3, T4, T5>(NamedScript<T1, T2, T3, T4, T5> script, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5)

Parameters

script NamedScript<T1, T2, T3, T4, T5>

A named JavaScript.

p1 T1

The value for the first script parameter.

p2 T2

The value for the second script parameter.

p3 T3

The value for the third script parameter.

p4 T4

The value for the fourth script parameter.

p5 T5

The value for the fifth script parameter.

Returns

ExecuteJavaScript

A builder object

Type Parameters

T1

The type of script parameter 1

T2

The type of script parameter 2

T3

The type of script parameter 3

T4

The type of script parameter 4

T5

The type of script parameter 5

Remarks

This is the recommended way to execute JavaScript in the browser. Use of the NamedScript, NamedScriptWithResult<TResult> and their other related generic types provides a simple type-safe mechanism of executing scripts.

Scripts executed with this method are not expected to return a result. If they do, their result is discarded and unused.

ExecuteAScript<T1, T2, T3, T4, T5, TResult>(NamedScriptWithResult<T1, T2, T3, T4, T5, TResult>, T1, T2, T3, T4, T5)

Gets a performable action which executes some JavaScript in the web browser.

public static ExecuteJavaScriptAndGetResult<TResult> ExecuteAScript<T1, T2, T3, T4, T5, TResult>(NamedScriptWithResult<T1, T2, T3, T4, T5, TResult> script, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5)

Parameters

script NamedScriptWithResult<T1, T2, T3, T4, T5, TResult>

A named JavaScript.

p1 T1

The value for the first script parameter.

p2 T2

The value for the second script parameter.

p3 T3

The value for the third script parameter.

p4 T4

The value for the fourth script parameter.

p5 T5

The value for the fifth script parameter.

Returns

ExecuteJavaScriptAndGetResult<TResult>

A builder object

Type Parameters

T1

The type of script parameter 1

T2

The type of script parameter 2

T3

The type of script parameter 3

T4

The type of script parameter 4

T5

The type of script parameter 5

TResult

The expected return type of the script

Remarks

This is the recommended way to execute JavaScript in the browser. Use of the NamedScript, NamedScriptWithResult<TResult> and their other related generic types provides a simple type-safe mechanism of executing scripts.

Scripts executed with this method are not expected to return a result. If they do, their result is discarded and unused.

ExecuteAScript<T1, T2, T3, T4, T5, T6>(NamedScript<T1, T2, T3, T4, T5, T6>, T1, T2, T3, T4, T5, T6)

Gets a performable action which executes some JavaScript in the web browser.

public static ExecuteJavaScript ExecuteAScript<T1, T2, T3, T4, T5, T6>(NamedScript<T1, T2, T3, T4, T5, T6> script, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, T6 p6)

Parameters

script NamedScript<T1, T2, T3, T4, T5, T6>

A named JavaScript.

p1 T1

The value for the first script parameter.

p2 T2

The value for the second script parameter.

p3 T3

The value for the third script parameter.

p4 T4

The value for the fourth script parameter.

p5 T5

The value for the fifth script parameter.

p6 T6

The value for the sixth script parameter.

Returns

ExecuteJavaScript

A builder object

Type Parameters

T1

The type of script parameter 1

T2

The type of script parameter 2

T3

The type of script parameter 3

T4

The type of script parameter 4

T5

The type of script parameter 5

T6

The type of script parameter 6

Remarks

This is the recommended way to execute JavaScript in the browser. Use of the NamedScript, NamedScriptWithResult<TResult> and their other related generic types provides a simple type-safe mechanism of executing scripts.

Scripts executed with this method are not expected to return a result. If they do, their result is discarded and unused.

ExecuteAScript<T1, T2, T3, T4, T5, T6, TResult>(NamedScriptWithResult<T1, T2, T3, T4, T5, T6, TResult>, T1, T2, T3, T4, T5, T6)

Gets a performable action which executes some JavaScript in the web browser.

public static ExecuteJavaScriptAndGetResult<TResult> ExecuteAScript<T1, T2, T3, T4, T5, T6, TResult>(NamedScriptWithResult<T1, T2, T3, T4, T5, T6, TResult> script, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, T6 p6)

Parameters

script NamedScriptWithResult<T1, T2, T3, T4, T5, T6, TResult>

A named JavaScript.

p1 T1

The value for the first script parameter.

p2 T2

The value for the second script parameter.

p3 T3

The value for the third script parameter.

p4 T4

The value for the fourth script parameter.

p5 T5

The value for the fifth script parameter.

p6 T6

The value for the sixth script parameter.

Returns

ExecuteJavaScriptAndGetResult<TResult>

A builder object

Type Parameters

T1

The type of script parameter 1

T2

The type of script parameter 2

T3

The type of script parameter 3

T4

The type of script parameter 4

T5

The type of script parameter 5

T6

The type of script parameter 6

TResult

The expected return type of the script

Remarks

This is the recommended way to execute JavaScript in the browser. Use of the NamedScript, NamedScriptWithResult<TResult> and their other related generic types provides a simple type-safe mechanism of executing scripts.

Scripts executed with this method are not expected to return a result. If they do, their result is discarded and unused.

ExecuteAScript<T1, T2, T3, T4, T5, T6, T7>(NamedScript<T1, T2, T3, T4, T5, T6, T7>, T1, T2, T3, T4, T5, T6, T7)

Gets a performable action which executes some JavaScript in the web browser.

public static ExecuteJavaScript ExecuteAScript<T1, T2, T3, T4, T5, T6, T7>(NamedScript<T1, T2, T3, T4, T5, T6, T7> script, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, T6 p6, T7 p7)

Parameters

script NamedScript<T1, T2, T3, T4, T5, T6, T7>

A named JavaScript.

p1 T1

The value for the first script parameter.

p2 T2

The value for the second script parameter.

p3 T3

The value for the third script parameter.

p4 T4

The value for the fourth script parameter.

p5 T5

The value for the fifth script parameter.

p6 T6

The value for the sixth script parameter.

p7 T7

The value for the seventh script parameter.

Returns

ExecuteJavaScript

A builder object

Type Parameters

T1

The type of script parameter 1

T2

The type of script parameter 2

T3

The type of script parameter 3

T4

The type of script parameter 4

T5

The type of script parameter 5

T6

The type of script parameter 6

T7

The type of script parameter 7

Remarks

This is the recommended way to execute JavaScript in the browser. Use of the NamedScript, NamedScriptWithResult<TResult> and their other related generic types provides a simple type-safe mechanism of executing scripts.

Scripts executed with this method are not expected to return a result. If they do, their result is discarded and unused.

ExecuteAScript<T1, T2, T3, T4, T5, T6, T7, TResult>(NamedScriptWithResult<T1, T2, T3, T4, T5, T6, T7, TResult>, T1, T2, T3, T4, T5, T6, T7)

Gets a performable action which executes some JavaScript in the web browser.

public static ExecuteJavaScriptAndGetResult<TResult> ExecuteAScript<T1, T2, T3, T4, T5, T6, T7, TResult>(NamedScriptWithResult<T1, T2, T3, T4, T5, T6, T7, TResult> script, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, T6 p6, T7 p7)

Parameters

script NamedScriptWithResult<T1, T2, T3, T4, T5, T6, T7, TResult>

A named JavaScript.

p1 T1

The value for the first script parameter.

p2 T2

The value for the second script parameter.

p3 T3

The value for the third script parameter.

p4 T4

The value for the fourth script parameter.

p5 T5

The value for the fifth script parameter.

p6 T6

The value for the sixth script parameter.

p7 T7

The value for the seventh script parameter.

Returns

ExecuteJavaScriptAndGetResult<TResult>

A builder object

Type Parameters

T1

The type of script parameter 1

T2

The type of script parameter 2

T3

The type of script parameter 3

T4

The type of script parameter 4

T5

The type of script parameter 5

T6

The type of script parameter 6

T7

The type of script parameter 7

TResult

The expected return type of the script

Remarks

This is the recommended way to execute JavaScript in the browser. Use of the NamedScript, NamedScriptWithResult<TResult> and their other related generic types provides a simple type-safe mechanism of executing scripts.

Scripts executed with this method are not expected to return a result. If they do, their result is discarded and unused.

ExecuteCustomScript(string)

Gets a builder for a performable action which executes some arbitrary JavaScript in the web browser.

public static ExecuteJavaScriptBuilder ExecuteCustomScript(string scriptBody)

Parameters

scriptBody string

The body of the JavaScript to execute.

Returns

ExecuteJavaScriptBuilder

A builder object

Remarks

This method may be used for building an arbitrary script, but where possible it is recommended to use one of the overloads of ExecuteAScript(NamedScript). These methods accept either a NamedScript, a NamedScriptWithResult<TResult>, or one of their other related generic types. These overloads provide type safety for parameters, return types, and ensure that the name of the script is pre-specified at design time.

Scripts executed with this method are not expected to return a result. If they do, their result is discarded and unused.

ExecuteCustomScriptWithResult<TResult>(string)

Gets a builder for a performable action which executes some JavaScript in the web browser and returns a result from that script.

public static ExecuteJavaScriptBuilderWithResult<TResult> ExecuteCustomScriptWithResult<TResult>(string scriptBody)

Parameters

scriptBody string

The body of the JavaScript to execute.

Returns

ExecuteJavaScriptBuilderWithResult<TResult>

A builder object

Type Parameters

TResult

Remarks

This action is for executing a script which is expected to return a result. This method may be used for building an arbitrary script, but where possible it is recommended to use one of the overloads of this method which accepts either a NamedScript, a NamedScriptWithResult<TResult>, or one of their other related generic types. These overloads provide type safety for parameters, return types, and ensure that the name of the script is pre-specified at design time.

Filter(SeleniumElementCollection)

Gets a builder which may be used to create a performable question which filters a collection of elements for those which match a specification.

public static FilterElementsBuilder Filter(SeleniumElementCollection elements)

Parameters

elements SeleniumElementCollection

The collection of elements to filter.

Returns

FilterElementsBuilder

A builder with which consuming logic must provide a specification.

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".

See Also

FindAnElementOnThePage()

Gets a builder which may be used to create a performable action which finds a single element within the body of the page.

public static FindElementBuilder FindAnElementOnThePage()

Returns

FindElementBuilder

A builder, which may be used to configure/get a question that finds an element

Remarks

If you want to find an element which is a descendent of a specified target, consider using FindAnElementWithin(ITarget) instead.

FindAnElementWithin(ITarget)

Gets a builder which may be used to create a performable action which finds a single element within a specified target.

public static FindElementBuilder FindAnElementWithin(ITarget target)

Parameters

target ITarget

The target within which to find HTML elements

Returns

FindElementBuilder

A builder, which may be used to configure/get a question that finds an element

Remarks

If you only want to find an element within the <body> element of the page, consider using FindAnElementOnThePage() instead.

FindElementsOnThePage()

Gets a builder which may be used to create a performable action which finds a collection of elements within the body of the page.

public static FindElementsBuilder FindElementsOnThePage()

Returns

FindElementsBuilder

A builder, which may be used to configure/get a question that finds elements

Remarks

If you want to find elements which are descendents of a specified target, consider using FindElementsWithin(ITarget) instead.

FindElementsWithin(ITarget)

Gets a builder which may be used to create a performable action which finds a collection of elements within a specified target.

public static FindElementsBuilder FindElementsWithin(ITarget target)

Parameters

target ITarget

The target within which to find HTML elements

Returns

FindElementsBuilder

A builder, which may be used to configure/get a question that finds elements

Remarks

If you only want to find elements within the <body> element of the page, consider using FindElementsOnThePage() instead.

OpenTheUrl(NamedUri)

Gets a performable action which opens a URL.

public static IPerformable OpenTheUrl(NamedUri uri)

Parameters

uri NamedUri

The uri at which to open the web browser.

Returns

IPerformable

A performable

Remarks

If the specified Uri is a relative Uri, then this task will use the actor's UseABaseUri ability (if present) to transform the relative Uri into an absolute one. The specified Uri will be used directly if it is already absolute.

ReadFromTheCollectionOfElements(ITarget)

Gets a builder which may be used to create a performable question which reads a collection of the same information from a collection of elements.

public static QuestionMultiQueryBuilder ReadFromTheCollectionOfElements(ITarget element)

Parameters

element ITarget

The elements to interrogate for values.

Returns

QuestionMultiQueryBuilder

A builder which chooses the query

Remarks

This question makes use of an IQuery<T> to interrogate each element element in the collection and return a series of corresponding values.

ReadFromTheElement(ITarget)

Gets a builder which may be used to create a performable question which reads a piece of information from a single element.

public static QuestionQueryBuilder ReadFromTheElement(ITarget element)

Parameters

element ITarget

The element to interrogate for a value.

Returns

QuestionQueryBuilder

A builder which chooses the query

Remarks

This question makes use of an IQuery<T> to interrogate a single element and return a value.

ReadTheWindowTitle()

Gets a performable question which reads the title of the current browser window.

public static GetWindowTitle ReadTheWindowTitle()

Returns

GetWindowTitle

A performable question.

SaveTheScreenshot(Screenshot)

Gets a performable action which saves a screenshot to a file.

public static SaveScreenshotBuilder SaveTheScreenshot(Screenshot screenshot)

Parameters

screenshot Screenshot

The Selenium screenshot instance

Returns

SaveScreenshotBuilder

A performable

Remarks

This method returns a builder object which may be used to specify a short name for the screenshot. This allows it to be quickly identified in the report.

If you only want to take a screenshot and save it as an asset file, please consider TakeAndSaveAScreenshot() instead of this method.

SelectTheOption(int)

Gets a builder which will create a performable which represents an actor selecting a specified option from a <select> element.

public static FromTargetActionBuilder SelectTheOption(int optionIndex)

Parameters

optionIndex int

The zero-based index of an option to select

Returns

FromTargetActionBuilder

A builder by which a target element is chosen

Remarks

This overload selects the option by its zero-based index. As might be expected, the target which is specified in the builder must represent a <select> element or the resulting performable will raise an exception.

SelectTheOption(string)

Gets a builder which will create a performable which represents an actor selecting a specified option from a <select> element.

public static FromTargetActionBuilder SelectTheOption(string optionText)

Parameters

optionText string

The text of the option to select

Returns

FromTargetActionBuilder

A builder by which a target element is chosen

Remarks

This overload selects the option by its displayed text. As might be expected, the target which is specified in the builder must represent a <select> element or the resulting performable will raise an exception.

SelectTheOptionWithValue(string)

Gets a builder which will create a performable which represents an actor selecting a specified option from a <select> element.

public static FromTargetActionBuilder SelectTheOptionWithValue(string optionValue)

Parameters

optionValue string

The underlying value of the option to select

Returns

FromTargetActionBuilder

A builder by which a target element is chosen

Remarks

This overload selects the option by its underlying value attribute, instead of its displayed text. As might be expected, the target which is specified in the builder must represent a <select> element or the resulting performable will raise an exception.

TakeAScreenshot()

Gets a performable question which takes a screenshot of the current web page and returns it.

public static IPerformableWithResult<Screenshot> TakeAScreenshot()

Returns

IPerformableWithResult<Screenshot>

A performable

Remarks

If you only want to take a screenshot and save it as an asset file, please consider TakeAndSaveAScreenshot() instead of this method.

This method will raise an exception if the WebDriver is not capable of taking screenshots. If you want to avoid this, consider using TakeAScreenshotIfSupported() instead.

TakeAScreenshotIfSupported()

Gets a performable question which takes a screenshot of the current web page and returns it, if the WebDriver is capable of doing so.

public static IPerformableWithResult<Screenshot> TakeAScreenshotIfSupported()

Returns

IPerformableWithResult<Screenshot>

A performable

Remarks

If you only want to take a screenshot and save it as an asset file, please consider TakeAndSaveAScreenshot() instead of this method.

This method will not raise an exception if the WebDriver is not capable of taking screenshots. Instead, it will return a value task of null. If you wish to use a performable which will raise an exception if the WebDriver is not capable of taking screenshots, consider using TakeAScreenshot() instead.

TakeAndSaveAScreenshot()

Gets a performable taek which takes a screenshot and saves it to a file, using an optional short name.

public static TakeAndSaveScreenshotBuilder TakeAndSaveAScreenshot()

Returns

TakeAndSaveScreenshotBuilder

A performable

Remarks

This method may be used to specify a short name for the screenshot. This allows it to be quickly identified in the report.

This method will raise an exception if the WebDriver is not capable of taking screenshots. If you want to avoid this, consider using TakeAndSaveAScreenshotIfSupported() instead.

TakeAndSaveAScreenshotIfSupported()

Gets a performable taek which takes a screenshot and saves it to a file, using an optional short name.

public static TakeAndSaveScreenshotBuilder TakeAndSaveAScreenshotIfSupported()

Returns

TakeAndSaveScreenshotBuilder

A performable

Remarks

This method may be used to specify a short name for the screenshot. This allows it to be quickly identified in the report.

This method will not raise an exception if the WebDriver is not capable of taking screenshots. Instead, it will do nothing. If you wish to use a performable which will raise an exception if the WebDriver is not capable of taking screenshots, consider using TakeAndSaveAScreenshot() instead.

WaitFor(TimeSpan)

Gets a performable action that waits for a specified amount of time.

public static WaitForSomeTime WaitFor(TimeSpan duration)

Parameters

duration TimeSpan

The duration for which to wait.

Returns

WaitForSomeTime

A performable action.

Remarks

This kind of wait waits for a specified time. If you want to wait until a condition is met, consider using either WaitUntil(Func<IWebDriver, bool>) or WaitUntil(IBuildsElementPredicates) instead.

WaitUntil(IBuildsElementPredicates)

Gets a builder which will create a performable question that waits until a predicate returns a successful result.

public static NamedWaitBuilder WaitUntil(IBuildsElementPredicates predicate)

Parameters

predicate IBuildsElementPredicates

A predicate which, when it returns a successful result, the wait is over.

Returns

NamedWaitBuilder

A builder for creating a wait action.

Remarks

The prupose of waiting in this manner is to wait for something to happen on the web page, such as an element being present, or having content that matches a specification.

The builder object returned by this method has a number of optional configuration methods.

Create the predicate paramater value by using one of the following extension methods. These extension methods provide a fluent interface to create a predicate for one or more elements (described by a single ITarget), as well as providing a human-readable name for the predicate.

Exceptions

ArgumentNullException

Thrown if the predicate is null.

ArgumentException

Thrown if the result type of the predicate is a value type other than boolean.

WaitUntil(Func<IWebDriver, bool>)

Gets a builder which will create a performable question that waits until a predicate returns a true result.

public static UnnamedWaitBuilder WaitUntil(Func<IWebDriver, bool> predicate)

Parameters

predicate Func<IWebDriver, bool>

A predicate which, when it returns a true result, the wait is over.

Returns

UnnamedWaitBuilder

A builder for creating a wait action.

Remarks

The purpose of waiting in this manner is to wait for something to happen on the web page, such as an element being present, or having content that matches a specification.

The builder object returned by this method has a number of optional configuration methods. Of these, consumers are strongly encouraged to use Named(string) to give the wait action a short, descriptive name which will appear in reports.

Take note that it is very normal for the predicate to make use of closures to access elements from outside its own scope. For example, the predicate function may refer to an element which is referenced by a variable in the calling method.

Where possible, consider using the other overload of this method: WaitUntil(IBuildsElementPredicates), as it provides a more fluent interface for describing the predicate. This overload is provided only for scenarios in which the predicate to end the wait is too complex to be easily expressed using the fluent interface.

Exceptions

ArgumentNullException

Thrown if the predicate is null.

ArgumentException

Thrown if the result type of the predicate is a value type other than boolean.