function Selenium2Driver::selectOptionOnElement
Throws
2 calls to Selenium2Driver::selectOptionOnElement()
- Selenium2Driver::selectOption in vendor/
lullabot/ mink-selenium2-driver/ src/ Selenium2Driver.php - Selects option from select field or value in radio group located by its XPath query.
- Selenium2Driver::setValue in vendor/
lullabot/ mink-selenium2-driver/ src/ Selenium2Driver.php - Sets element's value by its XPath query.
File
-
vendor/
lullabot/ mink-selenium2-driver/ src/ Selenium2Driver.php, line 1239
Class
- Selenium2Driver
- Selenium2 driver.
Namespace
Behat\Mink\DriverCode
private function selectOptionOnElement(Element $element, string $value, bool $multiple = false) : void {
$escapedValue = $this->xpathEscaper
->escapeLiteral($value);
// The value of an option is the normalized version of its text when it has no value attribute
$optionQuery = sprintf('.//option[@value = %s or (not(@value) and normalize-space(.) = %s)]', $escapedValue, $escapedValue);
$option = $element->element('xpath', $optionQuery);
if ($multiple || !$element->attribute('multiple')) {
if (!$option->selected()) {
$option->click();
}
return;
}
// Deselect all options before selecting the new one
$this->deselectAllOptions($element);
$option->click();
}