/** * @return $this * @throws WebDriverException */ public function clear() { try { $this->element->clear(); return $this; } catch (WebDriverException $exception) { $this->dispatchOnException($exception); } }
/** * @param WebDriverElement $element * @param string $value */ protected function _setFieldText(WebDriverElement $element, $value) { $element->clear(); $element->sendKeys($value); }
protected function setValue(WebDriverElement $element, $value) { $element->clear(); if ($value) { $element->sendKeys($value); } }
/** * Types on an web driver element. * * @param WebDriverElement $element Element to interact with. * @param string $value Value that should be typed on the element. * @param bool $clear Clear the element before typing when true. * * @deprecated Will be removed in future versions. Use expectType to improve the stability of your test cases. * @return $this Same instance for chained method calls. */ public function type(WebDriverElement $element, $value, $clear) { if ($this->isFailed()) { return $this; } if ($this->isFailed()) { return $this; } if ($clear) { $condition = true; $counter = 0; while ($condition) { try { $element->clear(); $condition = false; } catch (InvalidElementStateException $e) { echo InvalidElementStateException::class . ' thrown.'; if ($counter > 50) { $condition = false; } $counter++; } catch (StaleElementReferenceException $e) { echo StaleElementReferenceException::class . ' thrown.'; if ($counter > 50) { $condition = false; } $counter++; } } } $this->_logTyping($element, $value)->sendKeys($value); return $this; }