/** * Sets an option selected by a partial text match * @param String $text * @throws \Exception */ public function selectByPartialText($text) { $options = $this->_element->findElements(By::xPath(".//option[contains(text(), '" . $text . "')]")); $matched = false; foreach ($options as $option) { if (!$option->isSelected()) { $option->click(); } $matched = true; } if (!$matched) { throw new \Exception("Cannot locate option in select element with text: " . $text); } }
/** * @param By $by * @return ElementList */ public function find(By $by) { return new ElementList($this->deduplicate($by->findElements($this->getElements()))); }