Class QueryPredicatePrototypeBuilder
- Namespace
- CSF.Screenplay.Selenium.Builders
- Assembly
- CSF.Screenplay.Selenium.dll
Provides methods to build WebDriver predicate functions for a target element.
public class QueryPredicatePrototypeBuilder
- Inheritance
-
QueryPredicatePrototypeBuilder
- Inherited Members
Remarks
These are generally used for WebDriver waits, to wait until a target element meets the specified conditions.
Constructors
QueryPredicatePrototypeBuilder(ITarget, bool)
Initializes a new instance of the QueryPredicatePrototypeBuilder class for creating instances of QueryPredicatePrototype<TQueryable> which are suitable for use as either WaitUntilPredicate<T> or CSF.Specifications.ISpecificationFunction<T>.
public QueryPredicatePrototypeBuilder(ITarget target, bool multiElement)
Parameters
targetITargetThe target element for the queries.
multiElementboolIf set to true then this builder will get a predicate which works for targets which represent a collection of HTML elements; otherwise it will get a predicate for a single HTML element.
Methods
AllClasses(params string[])
Creates a query predicate for the presence of all the specified HTML classes (amongst the class attribute's values).
public QueryPredicatePrototype<string> AllClasses(params string[] classes)
Parameters
classesstring[]The names of the classes to query.
Returns
- QueryPredicatePrototype<string>
A QueryPredicatePrototype<TQueryable>, which may be converted to a full predicate.
Remarks
Note that this specification makes use of Selenium's GetAttribute method.
The behaviour of that method in fact queries the DOM property of the element first, before querying the HTML attribute.
It also has special handling for certain attributes such as class & readonly attributes (substituting them with className
and readOnly respectively when querying DOM properties).
Finally, 'boolean' attribute values are returned with either the string true if present or null if not.
Attribute(string)
Creates a query predicate for the presence of a specified HTML attribute.
public QueryPredicatePrototype<string> Attribute(string attributeName)
Parameters
attributeNamestringThe name of the attribute to query.
Returns
- QueryPredicatePrototype<string>
A QueryPredicatePrototype<TQueryable>, which may be converted to a full predicate.
Remarks
Note that this specification makes use of Selenium's GetAttribute method.
The behaviour of that method in fact queries the DOM property of the element first, before querying the HTML attribute.
It also has special handling for certain attributes such as class & readonly attributes (substituting them with className
and readOnly respectively when querying DOM properties).
Finally, 'boolean' attribute values are returned with either the string true if present or null if not.
AttributeValue(string, Func<string, bool>)
Creates a query predicate based on a specified HTML attribute and a predicate for the attribute's value.
public QueryPredicatePrototype<string> AttributeValue(string attributeName, Func<string, bool> predicate)
Parameters
attributeNamestringThe name of the attribute to query.
predicateFunc<string, bool>The predicate to apply to the attribute value.
Returns
- QueryPredicatePrototype<string>
A QueryPredicatePrototype<TQueryable>, which may be converted to a full predicate.
Remarks
Note that this specification makes use of Selenium's GetAttribute method.
The behaviour of that method in fact queries the DOM property of the element first, before querying the HTML attribute.
It also has special handling for certain attributes such as class & readonly attributes (substituting them with className
and readOnly respectively when querying DOM properties).
Finally, 'boolean' attribute values are returned with either the string true if present or null if not.
Note that the last behaviour, described above, means that this method may be used to match elements which do not have the specified attribute, by using a predicate which checks for null.
AttributeValue(string, string)
Creates a query predicate for the presence of a specified HTML attribute, with a specified value.
public QueryPredicatePrototype<string> AttributeValue(string attributeName, string value)
Parameters
attributeNamestringThe name of the attribute to query.
valuestringThe value of the attribute to query.
Returns
- QueryPredicatePrototype<string>
A QueryPredicatePrototype<TQueryable>, which may be converted to a full predicate.
Remarks
Note that this specification makes use of Selenium's GetAttribute method.
The behaviour of that method in fact queries the DOM property of the element first, before querying the HTML attribute.
It also has special handling for certain attributes such as class & readonly attributes (substituting them with className
and readOnly respectively when querying DOM properties).
Finally, 'boolean' attribute values are returned with either the string true if present or null if not.
Class(string)
Creates a query predicate for the presence of a specified HTML class (amongst the class attribute's values).
public QueryPredicatePrototype<string> Class(string @class)
Parameters
classstringThe name of the class to query.
Returns
- QueryPredicatePrototype<string>
A QueryPredicatePrototype<TQueryable>, which may be converted to a full predicate.
Remarks
Note that this specification makes use of Selenium's GetAttribute method.
The behaviour of that method in fact queries the DOM property of the element first, before querying the HTML attribute.
It also has special handling for certain attributes such as class & readonly attributes (substituting them with className
and readOnly respectively when querying DOM properties).
Finally, 'boolean' attribute values are returned with either the string true if present or null if not.
Clickability(bool)
Creates a query predicate based on whether or not the element is clickable.
public QueryPredicatePrototype<bool> Clickability(bool value)
Parameters
valueboolThe value to compare against the element's "clickability".
Returns
- QueryPredicatePrototype<bool>
A QueryPredicatePrototype<TQueryable>, which may be converted to a full predicate.
Clickability(Func<bool, bool>)
Creates a query predicate based on whether or not the element is clickable.
public QueryPredicatePrototype<bool> Clickability(Func<bool, bool> predicate)
Parameters
Returns
- QueryPredicatePrototype<bool>
A QueryPredicatePrototype<TQueryable>, which may be converted to a full predicate.
Clickable()
Creates a query predicate based on whether the element is clickable.
public QueryPredicatePrototype<bool> Clickable()
Returns
- QueryPredicatePrototype<bool>
A QueryPredicatePrototype<TQueryable>, which may be converted to a full predicate.
CssProperty(string, Func<string, bool>)
Creates a query predicate based on a specified CSS property and a predicate for the property's value.
public QueryPredicatePrototype<string> CssProperty(string propertyName, Func<string, bool> predicate)
Parameters
propertyNamestringThe name of the property to query.
predicateFunc<string, bool>The predicate to apply to the property value.
Returns
- QueryPredicatePrototype<string>
A QueryPredicatePrototype<TQueryable>, which may be converted to a full predicate.
CssProperty(string, string)
Creates a query predicate based on a specified CSS property and a desired value for that property.
public QueryPredicatePrototype<string> CssProperty(string propertyName, string value)
Parameters
propertyNamestringThe name of the property to query.
valuestringThe value to compare against the property value.
Returns
- QueryPredicatePrototype<string>
A QueryPredicatePrototype<TQueryable>, which may be converted to a full predicate.
Location(Point)
Creates a query predicate based on the element's location (its top-left corner).
public QueryPredicatePrototype<Point> Location(Point value)
Parameters
valuePointThe value to compare against the element's location.
Returns
- QueryPredicatePrototype<Point>
A QueryPredicatePrototype<TQueryable>, which may be converted to a full predicate.
Location(Func<Point, bool>)
Creates a query predicate based on the element's location (its top-left corner).
public QueryPredicatePrototype<Point> Location(Func<Point, bool> predicate)
Parameters
Returns
- QueryPredicatePrototype<Point>
A QueryPredicatePrototype<TQueryable>, which may be converted to a full predicate.
NotClass(string)
Creates a query predicate for the absence of a specified HTML class (amongst the class attribute's values).
public QueryPredicatePrototype<string> NotClass(string @class)
Parameters
classstringThe name of the class to query.
Returns
- QueryPredicatePrototype<string>
A QueryPredicatePrototype<TQueryable>, which may be converted to a full predicate.
Remarks
Note that this specification makes use of Selenium's GetAttribute method.
The behaviour of that method in fact queries the DOM property of the element first, before querying the HTML attribute.
It also has special handling for certain attributes such as class & readonly attributes (substituting them with className
and readOnly respectively when querying DOM properties).
Finally, 'boolean' attribute values are returned with either the string true if present or null if not.
NotClickable()
Creates a query predicate based on whether the element is clickable.
public QueryPredicatePrototype<bool> NotClickable()
Returns
- QueryPredicatePrototype<bool>
A QueryPredicatePrototype<TQueryable>, which may be converted to a full predicate.
NotVisible()
Creates a query predicate based on whether the element is not visible.
public QueryPredicatePrototype<bool> NotVisible()
Returns
- QueryPredicatePrototype<bool>
A QueryPredicatePrototype<TQueryable>, which may be converted to a full predicate.
Options(Func<IReadOnlyList<Option>, bool>)
Creates a query predicate based on the <option> elements, which are children of the current element, regardless of their selected state.
public QueryPredicatePrototype<IReadOnlyList<Option>> Options(Func<IReadOnlyList<Option>, bool> predicate)
Parameters
predicateFunc<IReadOnlyList<Option>, bool>The predicate to apply to the element's options.
Returns
- QueryPredicatePrototype<IReadOnlyList<Option>>
A QueryPredicatePrototype<TQueryable>, which may be converted to a full predicate.
OptionsWithText(params string[])
Creates a query predicate based on the <option> elements, which are children of the current element, regardless of their selected state.
public QueryPredicatePrototype<IReadOnlyList<Option>> OptionsWithText(params string[] optionTexts)
Parameters
optionTextsstring[]The display text of the options to match against.
Returns
- QueryPredicatePrototype<IReadOnlyList<Option>>
A QueryPredicatePrototype<TQueryable>, which may be converted to a full predicate.
Remarks
This specification will match the element if its options are precisely those specified by optionTexts.
The order of the options does not matter, but they must match exactly.
This method identifies the options by their display text.
OptionsWithValue(params string[])
Creates a query predicate based on the <option> elements, which are children of the current element, regardless of their selected state.
public QueryPredicatePrototype<IReadOnlyList<Option>> OptionsWithValue(params string[] optionValues)
Parameters
optionValuesstring[]The DOM values of the options to match against.
Returns
- QueryPredicatePrototype<IReadOnlyList<Option>>
A QueryPredicatePrototype<TQueryable>, which may be converted to a full predicate.
Remarks
This specification will match the element if its options are precisely those specified by optionValues.
The order of the options does not matter, but they must match exactly.
This method identifies the options by their DOM value.
SelectedOptions(Func<IReadOnlyList<Option>, bool>)
Creates a query predicate based on the <option> elements, which are children of the current element, which are selected.
public QueryPredicatePrototype<IReadOnlyList<Option>> SelectedOptions(Func<IReadOnlyList<Option>, bool> predicate)
Parameters
predicateFunc<IReadOnlyList<Option>, bool>The predicate to apply to the element's selected options.
Returns
- QueryPredicatePrototype<IReadOnlyList<Option>>
A QueryPredicatePrototype<TQueryable>, which may be converted to a full predicate.
SelectedOptionsWithText(params string[])
Creates a query predicate based on the <option> elements, which are children of the current element, which are selected.
public QueryPredicatePrototype<IReadOnlyList<Option>> SelectedOptionsWithText(params string[] optionTexts)
Parameters
optionTextsstring[]The display text of the options to match against.
Returns
- QueryPredicatePrototype<IReadOnlyList<Option>>
A QueryPredicatePrototype<TQueryable>, which may be converted to a full predicate.
Remarks
This specification will match the element if its selected options are precisely those specified by optionTexts.
The order of the options does not matter, but they must match exactly.
This method identifies the options by their display text.
SelectedOptionsWithValue(params string[])
Creates a query predicate based on the <option> elements, which are children of the current element, which are selected.
public QueryPredicatePrototype<IReadOnlyList<Option>> SelectedOptionsWithValue(params string[] optionValues)
Parameters
optionValuesstring[]The DOM values of the options to match against.
Returns
- QueryPredicatePrototype<IReadOnlyList<Option>>
A QueryPredicatePrototype<TQueryable>, which may be converted to a full predicate.
Remarks
This specification will match the element if its selected options are precisely those specified by optionValues.
The order of the options does not matter, but they must match exactly.
This method identifies the options by their DOM value.
Size(Size)
Creates a query predicate based on the element's size (width & height in pixels).
public QueryPredicatePrototype<Size> Size(Size value)
Parameters
valueSizeThe value to compare against the element's size.
Returns
- QueryPredicatePrototype<Size>
A QueryPredicatePrototype<TQueryable>, which may be converted to a full predicate.
Size(Func<Size, bool>)
Creates a query predicate based on the element's size (width & height in pixels).
public QueryPredicatePrototype<Size> Size(Func<Size, bool> predicate)
Parameters
Returns
- QueryPredicatePrototype<Size>
A QueryPredicatePrototype<TQueryable>, which may be converted to a full predicate.
Text(Func<string, bool>)
Creates a query predicate based on the element's text content.
public QueryPredicatePrototype<string> Text(Func<string, bool> predicate)
Parameters
Returns
- QueryPredicatePrototype<string>
A QueryPredicatePrototype<TQueryable>, which may be converted to a full predicate.
Text(string)
Creates a query predicate based on the element's text content.
public QueryPredicatePrototype<string> Text(string value)
Parameters
valuestringThe value to compare against the element's text.
Returns
- QueryPredicatePrototype<string>
A QueryPredicatePrototype<TQueryable>, which may be converted to a full predicate.
UnselectedOptions(Func<IReadOnlyList<Option>, bool>)
Creates a query predicate based on the <option> elements, which are children of the current element, which are not selected.
public QueryPredicatePrototype<IReadOnlyList<Option>> UnselectedOptions(Func<IReadOnlyList<Option>, bool> predicate)
Parameters
predicateFunc<IReadOnlyList<Option>, bool>The predicate to apply to the element's unselected options.
Returns
- QueryPredicatePrototype<IReadOnlyList<Option>>
A QueryPredicatePrototype<TQueryable>, which may be converted to a full predicate.
UnselectedOptionsWithText(params string[])
Creates a query predicate based on the <option> elements, which are children of the current element, which are not selected.
public QueryPredicatePrototype<IReadOnlyList<Option>> UnselectedOptionsWithText(params string[] optionTexts)
Parameters
optionTextsstring[]The display text of the options to match against.
Returns
- QueryPredicatePrototype<IReadOnlyList<Option>>
A QueryPredicatePrototype<TQueryable>, which may be converted to a full predicate.
Remarks
This specification will match the element if its unselected options are precisely those specified by optionTexts.
The order of the options does not matter, but they must match exactly.
This method identifies the options by their display text.
UnselectedOptionsWithValue(params string[])
Creates a query predicate based on the <option> elements, which are children of the current element, which are not selected.
public QueryPredicatePrototype<IReadOnlyList<Option>> UnselectedOptionsWithValue(params string[] optionValues)
Parameters
optionValuesstring[]The DOM values of the options to match against.
Returns
- QueryPredicatePrototype<IReadOnlyList<Option>>
A QueryPredicatePrototype<TQueryable>, which may be converted to a full predicate.
Remarks
This specification will match the element if its unselected options are precisely those specified by optionValues.
The order of the options does not matter, but they must match exactly.
This method identifies the options by their DOM value.
Value(Func<string, bool>)
Creates a query predicate based on the element's DOM value.
public QueryPredicatePrototype<string> Value(Func<string, bool> predicate)
Parameters
Returns
- QueryPredicatePrototype<string>
A QueryPredicatePrototype<TQueryable>, which may be converted to a full predicate.
Value(string)
Creates a query predicate based on the element's DOM value.
public QueryPredicatePrototype<string> Value(string value)
Parameters
valuestringThe value to compare against the element's DOM value.
Returns
- QueryPredicatePrototype<string>
A QueryPredicatePrototype<TQueryable>, which may be converted to a full predicate.
Visibility(bool)
Creates a query predicate based on whether or not the element is visible.
public QueryPredicatePrototype<bool> Visibility(bool value)
Parameters
valueboolThe value to compare against the element's visibility.
Returns
- QueryPredicatePrototype<bool>
A QueryPredicatePrototype<TQueryable>, which may be converted to a full predicate.
Visibility(Func<bool, bool>)
Creates a query predicate based on whether or not the element is visible.
public QueryPredicatePrototype<bool> Visibility(Func<bool, bool> predicate)
Parameters
Returns
- QueryPredicatePrototype<bool>
A QueryPredicatePrototype<TQueryable>, which may be converted to a full predicate.
Visible()
Creates a query predicate based on whether the element is visible.
public QueryPredicatePrototype<bool> Visible()
Returns
- QueryPredicatePrototype<bool>
A QueryPredicatePrototype<TQueryable>, which may be converted to a full predicate.