/** * @throws Exception If element not found, rather than fatal'ing (method call on non-obj) * @author Ronan Chilvers <*****@*****.**> */ public function apply(Connection $connection) { $formSelector = $this->formSelector; // Apply test entries foreach ($this->textEntries as $selector => $text) { $selector = "{$formSelector} {$selector}"; $element = $connection->getElement($selector); if (!$element instanceof WebDriverElement) { throw new Exception('Unable to find Element by selector: ' . $selector); } $element->clear(); $element->sendKeys($text); } foreach ($this->selectEntries as $selector => $option) { $selector = "{$selector} option[value='{$option}']"; $element = $connection->getElement($selector); if (!$element instanceof WebDriverElement) { throw new Exception('Unable to find Element by selector: ' . $selector); } $element->click(); } }
/** * Get the web driver connection * * @return RemoteWebDriver * @author Ronan Chilvers <*****@*****.**> */ protected function getDriver() { if (!$this->driver instanceof Connection) { $this->driver = Connection::create($this->getConnectionUrl(), $this->getCapabilities()); if ($host = $this->getDefaultHost()) { $this->driver->setDefaultHost($host); } } return $this->driver; }