class Select extends AbstractTypifiedElement implements ISimpleSetter (View source)

Represents web page select control.

Constants

CRITERION_TAG

CRITERION_ATTRS

Properties

private string $_name Name of the element. from AbstractTypifiedElement
private WebElement $_wrappedElement Wrapped element. from AbstractTypifiedElement
private IPageFactory $_pageFactory Stores instance of used page factory. from AbstractTypifiedElement
protected array $acceptanceCriteria List of acceptance criteria.

Methods

__construct(WebElement $wrapped_element, IPageFactory $page_factory)

Specifies wrapped WebElement.

fromNodeElement(NodeElement $node_element, IPageFactory $page_factory)

Creates Element instance based on existing NodeElement instance.

void
assertWrappedElement()

Checks that wrapped element meets the acceptance criteria.

boolean
isTagNameMatching(array $criterion)

Checks if the tag name(s) of the criterion are matching.

boolean
isAttributeMatching(array $criterion)

Checks if the attributes of the criterion are matching.

boolean
isValueMatchingCriterionDefinition(string $value, string $criterion)

Checks if passed value matching the defined criterion.

getWrappedElement()

Returns wrapped element.

setName(string $name)

Sets a name of an element.

string
getName()

Returns name of the entity.

Session
getSession() deprecated

Returns element session.

getPageFactory()

Returns page factory, used during object creation.

boolean
isVisible()

Checks whether current node is visible on page.

boolean
isValid()

Checks if an element is still valid.

boolean
hasAttribute(string $name)

Checks whether element has attribute with specified name.

mixed|null
getAttribute(string $name)

Returns specified attribute value.

string
getXpath()

Returns XPath for handled element.

string
getTagName()

Returns current node tag name.

Escaper
getXpathEscaper()

Returns the XPath escaper.

boolean
isSeleniumDriver()

Checks, that Selenium driver is used.

string
__toString()

Returns string representation of element.

Expectation
shouldReceive(string $name)

No description

boolean
isMultiple()

Indicates whether this select element support selecting multiple options at the same time.

getOptions()

Returns all options belonging to this select tag.

getOptionsByValue(mixed $value)

Returns all options having given value.

getOptionsByText(string $text, boolean $exact_match = true)

Returns all options that display text matching the argument.

getSelectedOptions()

Returns all selected options belonging to this select tag.

getFirstSelectedOption()

The first selected option in this select tag (or the currently selected option in a normal select).

selectByText(string $text, boolean $exact_match = true)

Select all options that display text matching the argument.

deselectByText(string $text, boolean $exact_match = true)

Deselect all options that display text matching the argument.

selectByValue(mixed $value)

Select all options that have a value matching the argument.

deselectByValue(mixed $value)

Deselect all options that have a value matching the argument.

selectAll()

Selects all options.

setSelected(array $values)

Replaces current selection with given one.

deselectAll()

Deselects all options.

setValue(mixed $value)

Sets value to the element.

selectOptions(array $options, boolean $first_only = false)

Select given options.

wrapOptions(array $nodes)

Wraps each of NodeElement in array with a SelectOption class.

void
assertMultiSelect()

Throws an exception when it's not a multiselect.

Details

__construct(WebElement $wrapped_element, IPageFactory $page_factory)

Specifies wrapped WebElement.

Parameters

WebElement $wrapped_element Element to be wrapped.
IPageFactory $page_factory Page factory.

static INodeElementAware fromNodeElement(NodeElement $node_element, IPageFactory $page_factory)

Creates Element instance based on existing NodeElement instance.

Parameters

NodeElement $node_element Node element.
IPageFactory $page_factory Page factory.

Return Value

INodeElementAware

protected void assertWrappedElement()

Checks that wrapped element meets the acceptance criteria.

Return Value

void

Exceptions

TypifiedElementException When no criteria matches.

protected boolean isTagNameMatching(array $criterion)

Checks if the tag name(s) of the criterion are matching.

Parameters

array $criterion The criterion.

Return Value

boolean

protected boolean isAttributeMatching(array $criterion)

Checks if the attributes of the criterion are matching.

Parameters

array $criterion The criterion.

Return Value

boolean

protected boolean isValueMatchingCriterionDefinition(string $value, string $criterion)

Checks if passed value matching the defined criterion.

Parameters

string $value Value to match.
string $criterion The criterion.

Return Value

boolean

WebElement getWrappedElement()

Returns wrapped element.

Return Value

WebElement

ITypifiedElement setName(string $name)

Sets a name of an element.

This method is used by initialization mechanism and is not intended to be used directly.

Parameters

string $name Name to set.

Return Value

ITypifiedElement

string getName()

Returns name of the entity.

Return Value

string

Session getSession() deprecated

deprecated Accessing the session from the element is deprecated as of 1.2 and will be impossible in 2.0.

Returns element session.

Return Value

Session

protected IPageFactory getPageFactory()

Returns page factory, used during object creation.

Return Value

IPageFactory

boolean isVisible()

Checks whether current node is visible on page.

Return Value

boolean

boolean isValid()

Checks if an element is still valid.

Return Value

boolean

boolean hasAttribute(string $name)

Checks whether element has attribute with specified name.

Parameters

string $name Attribute name.

Return Value

boolean

mixed|null getAttribute(string $name)

Returns specified attribute value.

Parameters

string $name Attribute name.

Return Value

mixed|null

string getXpath()

Returns XPath for handled element.

Return Value

string

string getTagName()

Returns current node tag name.

Return Value

string

Escaper getXpathEscaper()

Returns the XPath escaper.

Return Value

Escaper

protected boolean isSeleniumDriver()

Checks, that Selenium driver is used.

Return Value

boolean

string __toString()

Returns string representation of element.

Return Value

string

Expectation shouldReceive(string $name)

Parameters

string $name

Return Value

Expectation

boolean isMultiple()

Indicates whether this select element support selecting multiple options at the same time.

Return Value

boolean

SelectOption[] getOptions()

Returns all options belonging to this select tag.

Return Value

SelectOption[]

SelectOption[] getOptionsByValue(mixed $value)

Returns all options having given value.

Parameters

mixed $value Value of option to selected.

Return Value

SelectOption[]

SelectOption[] getOptionsByText(string $text, boolean $exact_match = true)

Returns all options that display text matching the argument.

Parameters

string $text Text of the option to be selected.
boolean $exact_match Search for exact text.

Return Value

SelectOption[]

SelectOption[] getSelectedOptions()

Returns all selected options belonging to this select tag.

Return Value

SelectOption[]

SelectOption getFirstSelectedOption()

The first selected option in this select tag (or the currently selected option in a normal select).

Return Value

SelectOption

Exceptions

SelectException When no options were selected.

Select selectByText(string $text, boolean $exact_match = true)

Select all options that display text matching the argument.

Parameters

string $text The visible text to match against.
boolean $exact_match Search for exact text.

Return Value

Select

Exceptions

SelectException No options were found by given text.

Select deselectByText(string $text, boolean $exact_match = true)

Deselect all options that display text matching the argument.

Parameters

string $text The visible text to match against.
boolean $exact_match Search for exact text.

Return Value

Select

Select selectByValue(mixed $value)

Select all options that have a value matching the argument.

Parameters

mixed $value The value to match against.

Return Value

Select

Exceptions

SelectException When option with given value can't be found.

Select deselectByValue(mixed $value)

Deselect all options that have a value matching the argument.

Parameters

mixed $value Value of an option be be deselected.

Return Value

Select

Select selectAll()

Selects all options.

Return Value

Select

Select setSelected(array $values)

Replaces current selection with given one.

Parameters

array $values Values of options to select.

Return Value

Select

Select deselectAll()

Deselects all options.

Return Value

Select

ISimpleSetter setValue(mixed $value)

Sets value to the element.

Parameters

mixed $value New value.

Return Value

ISimpleSetter

protected Select selectOptions(array $options, boolean $first_only = false)

Select given options.

Parameters

array $options Options to be selected.
boolean $first_only Select only first option.

Return Value

Select

protected SelectOption[] wrapOptions(array $nodes)

Wraps each of NodeElement in array with a SelectOption class.

Parameters

array $nodes Nodes.

Return Value

SelectOption[]

protected void assertMultiSelect()

Throws an exception when it's not a multiselect.

Return Value

void

Exceptions

SelectException If the SELECT does not support multiple selections.