public function FormManipulationTrait::selectOption in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/jcalderonzumba/mink-phantomjs-driver/src/FormManipulationTrait.php \Zumba\Mink\Driver\FormManipulationTrait::selectOption()
Selects an option
Parameters
string $xpath:
string $value:
bool $multiple:
Return value
bool
Throws
File
- vendor/
jcalderonzumba/ mink-phantomjs-driver/ src/ FormManipulationTrait.php, line 77
Class
- FormManipulationTrait
- Trait FormManipulationTrait @package Zumba\Mink\Driver
Namespace
Zumba\Mink\DriverCode
public function selectOption($xpath, $value, $multiple = false) {
$element = $this
->findElement($xpath, 1);
$tagName = strtolower($this->browser
->tagName($element["page_id"], $element["ids"][0]));
$attributes = $this->browser
->attributes($element["page_id"], $element["ids"][0]);
if (!in_array($tagName, array(
"input",
"select",
))) {
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 ($tagName === "input" && $attributes["type"] != "radio") {
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));
}
return $this->browser
->selectOption($element["page_id"], $element["ids"][0], $value, $multiple);
}