protected function setClicked(WebDriverElement $element, $value) { $checked = (bool) $element->getAttribute('checked'); if ((bool) $checked != (bool) $value) { $element->click(); } }
/** * @param string $attribute_name * @return string * @throws WebDriverException */ public function getAttribute($attribute_name) { try { return $this->element->getAttribute($attribute_name); } catch (WebDriverException $exception) { $this->dispatchOnException($exception); } }
public function __construct(WebDriverElement $element) { $tag_name = $element->getTagName(); if ($tag_name !== 'select') { throw new UnexpectedTagNameException('select', $tag_name); } $this->element = $element; $value = $element->getAttribute('multiple'); $this->isMulti = $value === 'true'; }
/** * Returns the html of the expected element. * * @param WebDriverElement $element * * @return string */ private function _getClickingElementsHtml(WebDriverElement $element) { if ($element instanceof WebDriverElementNull || $this->isFailed()) { return $element; } $id = $element->getAttribute('id') !== '' ? $element->getAttribute('id') : null; $class = $element->getAttribute('class') !== '' ? $element->getAttribute('class') : null; $disabled = $element->getAttribute('disabled') !== '' ? $element->getAttribute('disabled') : null; $href = $element->getAttribute('href') !== '' ? $element->getAttribute('href') : null; $idValue = $id ? ' id="' . trim($id) . '"' : null; $classValue = $class ? ' class="' . trim($class) . '"' : null; $disabledValue = $disabled ? ' disabled' : null; $hrefValue = $href ? ' href="' . trim($href) . '"' : null; $tagName = $element->getTagName(); $tagText = $element->getText(); return '<' . $tagName . $idValue . $classValue . $disabledValue . $hrefValue . '>' . $tagText . '</' . $tagName . '>'; }
/** * Returns the html of the expected element. * * @param WebDriverElement $element * * @return string */ private function _getTypingElementsHtml(WebDriverElement $element) { $id = $element->getAttribute('id') !== '' ? $element->getAttribute('id') : null; $class = $element->getAttribute('class') !== '' ? $element->getAttribute('class') : null; $name = $element->getAttribute('name') !== '' ? $element->getAttribute('name') : null; $type = $element->getAttribute('type') !== '' ? $element->getAttribute('type') : null; $placeholder = $element->getAttribute('placeholder') !== '' ? $element->getAttribute('placeholder') : null; $value = $element->getAttribute('value') !== '' ? $element->getAttribute('value') : null; $idValue = $id ? ' id="' . trim($id) . '"' : null; $classValue = $class ? ' class="' . trim($class) . '"' : null; $nameValue = $name ? ' name="' . trim($name) . '"' : null; $typeValue = $type ? ' type="' . trim($type) . '"' : null; $placeholderValue = $placeholder ? ' placeholder="' . trim($placeholder) . '"' : null; $valueValue = $value ? ' value="' . trim($value) . '"' : null; return '<input' . $idValue . $classValue . $nameValue . $typeValue . $placeholderValue . $valueValue . '/>'; }