Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. BrowserKitDriver.php

function BrowserKitDriver::selectOption

Overrides CoreDriver::selectOption

File

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

Class

BrowserKitDriver
Symfony BrowserKit driver.

Namespace

Behat\Mink\Driver

Code

public function selectOption(string $xpath, string $value, bool $multiple = false) {
    $field = $this->getFormField($xpath);
    if (!$field instanceof ChoiceFormField) {
        throw new DriverException(sprintf('Impossible to select an option on the element with XPath "%s" as it is not a select or radio input', $xpath));
    }
    if ($multiple) {
        $oldValue = (array) $field->getValue();
        $oldValue[] = $value;
        $value = $oldValue;
    }
    $field->select($value);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal