Table of Contents

Class TextQuery

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

A query to get the text content of a Selenium element.

public class TextQuery : IQuery<string>, IHasName
Inheritance
TextQuery
Implements
Inherited Members

Remarks

When reading text from the web browser, depending upon the whitespace-trimming parameter, this query will or will not trim leading/trailing whitespace. This functionality is present because some browsers (Safari) include whitespace at the beginning/end of text read from the browser which isn't visible to the end user. This is typically the space which is inherent in the markup, but which browsers ignore when actually displaying content. Other WebDriver implementations do not include this leading/trailing whitespace.

When whitespace is trimmed, this provides a more consistent cross-browser experience when reading the text of an element. The consequence is that sometimes, when reading leading/trailing whitespace is intended, we must pass a different parameter value.

Constructors

TextQuery(bool)

Initializes a new instance of the TextQuery class.

public TextQuery(bool trimWhitespace = true)

Parameters

trimWhitespace bool

If true, leading & trailing whitespace will be trimmed from the returned text content; if true it will not.

Properties

Name

Gets the human-readable name of the current object.

public string Name { get; }

Property Value

string

Remarks

null is strongly discouraged here. All types which implement IHasName should return a non-null response from this property.

Methods

GetValue(SeleniumElement)

Gets the current value from a Selenium element.

public string GetValue(SeleniumElement element)

Parameters

element SeleniumElement

The Selenium element.

Returns

string

The value of type string.

See Also