Class CssSelector
- Namespace
- CSF.Screenplay.Selenium.Elements
- Assembly
- CSF.Screenplay.Selenium.dll
Concrete implementation of Locator which locates elements by a CSS selector value.
public class CssSelector : Locator, ITarget, IHasName
- Inheritance
-
CssSelector
- Implements
- Inherited Members
- Extension Methods
Remarks
This class wraps Selenium's CssSelector(string) functionality. The purpose is provide a type which derives from ITarget, compatible with the Selenium extension's performables. This class also provides opportunity to add a human-readable Name to the element specification. This optional, but recommended, technique improves the readability of Screenplay reports.
Constructors
CssSelector(string, string)
Initializes a new instance of the CssSelector class.
public CssSelector(string cssSelector, string name = null)
Parameters
cssSelectorstringThe CSS selector by which to locate elements.
namestringAn optional human-readable name of the locator which describes the elements it matches.
Fields
AnyElement
Gets a CSS-based locator which matches all/any descendent elements.
public static readonly CssSelector AnyElement
Field Value
Remarks
This locator is equivalent to the CSS selector *, which matches any & all descendent elements.
BodyElement
Gets a CSS-based locator which matches the HTML body element.
public static readonly CssSelector BodyElement
Field Value
Remarks
This locator is equivalent to the CSS selector body, which matches the root of the rendered page.
Methods
GetDefaultName()
Gets a value for Name if none has been specified.
protected override string GetDefaultName()
Returns
- string
A default name
GetLocator()
Gets the Selenium locator instance for finding HTML elements.
public override By GetLocator()
Returns
- By
A Selenium
Byobject used to locate elements.