Table of Contents

Interface ITarget

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

A target is an object which may be interacted with by Selenium-based Screenplay performables.

public interface ITarget : IHasName
Inherited Members
Extension Methods

Remarks

Targets roughly correspond to the concept of 'elements' in Selenium WebDriver; the targets abstraction may by implemented by objects which contain one or more Selenium IWebElement instances.

Targets might alternatively be implemented by objects which contain selector information, such as a CSS selector, XPath an id attribute. In this scenario the target is conceptually 'a specification for finding elements'. A selector/specification-based target may be used to find elements at runtime, via the GetElements(IWebDriver) method.

Methods

GetElement(IWebDriver)

Gets a single Selenium element which matches the current target.

SeleniumElement GetElement(IWebDriver driver)

Parameters

driver IWebDriver

A Selenium Web Driver

Returns

SeleniumElement

A SeleniumElement which matches the target

Remarks

This method may invoke the specified Selenium IWebDriver to get the element which matches a specification/selector. Alternatively if the target implementation already represents one or more concrete element instances then it will be returned directly. Crucially, if the target represents multiple elements then this method will return only the first element.

Exceptions

TargetNotFoundException

If the target does not yield an HTML element

GetElements(IWebDriver)

Gets a collection of Selenium elements which match the current target.

SeleniumElementCollection GetElements(IWebDriver driver)

Parameters

driver IWebDriver

A Selenium Web Driver

Returns

SeleniumElementCollection

A collection of zero or more Selenium elements

Remarks

This method may invoke the specified Selenium IWebDriver to find elements which match a specification/selector. Alternatively if the target implementation already represents one or more concrete element instances then these will be returned directly.