You are here

public function BrowserKitDriver::isSelected in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/behat/mink-browserkit-driver/src/BrowserKitDriver.php \Behat\Mink\Driver\BrowserKitDriver::isSelected()

Checks whether select option, located by it's XPath query, is selected.

Parameters

string $xpath:

Return value

Boolean

Throws

UnsupportedDriverActionException When operation not supported by the driver

DriverException When the operation cannot be done

Overrides CoreDriver::isSelected

See also

\Behat\Mink\Element\NodeElement::isSelected

File

vendor/behat/mink-browserkit-driver/src/BrowserKitDriver.php, line 458

Class

BrowserKitDriver
Symfony2 BrowserKit driver.

Namespace

Behat\Mink\Driver

Code

public function isSelected($xpath) {
  $optionValue = $this
    ->getOptionValue($this
    ->getCrawlerNode($this
    ->getFilteredCrawler($xpath)));
  $selectField = $this
    ->getFormField('(' . $xpath . ')/ancestor-or-self::*[local-name()="select"]');
  $selectValue = $selectField
    ->getValue();
  return is_array($selectValue) ? in_array($optionValue, $selectValue, true) : $optionValue === $selectValue;
}