Пример #1
0
 protected function setClicked(WebDriverElement $element, $value)
 {
     $checked = (bool) $element->getAttribute('checked');
     if ((bool) $checked != (bool) $value) {
         $element->click();
     }
 }
Пример #2
0
 protected function execute(WebDriverElement $element)
 {
     $this->webdriver->getMouse()->mouseMove($element->getCoordinates());
     if ($this->themeConfiguration->getUseClicksToNavigate()) {
         $this->webdriver->getMouse()->click();
     }
 }
Пример #3
0
 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';
 }
Пример #4
0
 public static function elementRemoved(WebDriverElement $element)
 {
     return new WebDriverExpectedCondition(function () use($element) {
         try {
             $element->isDisplayed();
             return false;
         } catch (\Exception $e) {
             return true;
         }
     });
 }
Пример #5
0
 /**
 * Switch to the iframe by its id or name.
 *
 * @param WebDriverElement|string $frame The WebDriverElement,
                                         the id or the name of the frame.
 * @return WebDriver The driver focused on the given frame.
 */
 public function frame($frame)
 {
     if ($frame instanceof WebDriverElement) {
         $id = array('ELEMENT' => $frame->getID());
     } else {
         $id = (string) $frame;
     }
     $params = array('id' => $id);
     $this->executor->execute(DriverCommand::SWITCH_TO_FRAME, $params);
     return $this->driver;
 }
Пример #6
0
 /**
  * Test if two element IDs refer to the same DOM element.
  *
  * @param WebDriverElement $other
  * @return bool
  */
 public function equals(WebDriverElement $other)
 {
     try {
         return $this->element->equals($other);
     } catch (WebDriverException $exception) {
         $this->dispatchOnException($exception);
     }
 }
 protected function setValue(WebDriverElement $element, $value)
 {
     $element->clear();
     if ($value) {
         $element->sendKeys($value);
     }
 }
Пример #8
0
 /**
  * Wait until an element is no longer attached to the DOM.
  *
  * @param WebDriverElement $element The element to wait for.
  * @return bool WebDriverExpectedCondition false if the element is still
  *         attached to the DOM, true otherwise.
  */
 public static function stalenessOf(WebDriverElement $element)
 {
     return new WebDriverExpectedCondition(function ($driver) use($element) {
         try {
             $element->isEnabled();
             return false;
         } catch (StaleElementReferenceException $e) {
             return 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 . '>';
 }
Пример #10
0
 /**
  * Test if two element IDs refer to the same DOM element.
  *
  * @param WebDriverElement $other
  * @return bool
  */
 public function equals(WebDriverElement $other)
 {
     return $this->executor->execute(DriverCommand::ELEMENT_EQUALS, array(':id' => $this->id, ':other' => $other->getID()));
 }
Пример #11
0
 public function elementAttached(WebDriverElement $element)
 {
     try {
         $element->isDisplayed();
         return true;
     } catch (\Exception $e) {
         return false;
     }
 }
Пример #12
0
 public function getBreadCrumbText()
 {
     $this->extract();
     $text = preg_replace('/\\s+/', ' ', $this->element->getText());
     return $text;
 }
Пример #13
0
 /**
  * @param WebDriverElement $element
  * @param int $xoffset
  * @param int $yoffset
  *
  * @return RemoteTouchScreen The instance.
  */
 public function scrollFromElement(WebDriverElement $element, $xoffset, $yoffset)
 {
     $this->executor->execute(DriverCommand::TOUCH_SCROLL, array('element' => $element->getID(), 'xoffset' => $xoffset, 'yoffset' => $yoffset));
     return $this;
 }
Пример #14
0
 public function assert()
 {
     $rightCoord = $this->rightElement->getLocation();
     $leftCoord = $this->leftElement->getLocation();
     $this->getTestCase()->assertGreaterThan($leftCoord->getX(), $rightCoord->getX(), 'The "right" element was not to the right of the "left" element');
 }
Пример #15
0
 public function assert()
 {
     $aboveCoord = $this->aboveElement->getLocation();
     $belowCoord = $this->belowElement->getLocation();
     $this->getTestCase()->assertGreaterThan($aboveCoord->getY(), $belowCoord->getY(), 'The "below" element was not below the "above" element');
 }
Пример #16
0
 /**
  * @param WebDriverElement $element
  * @param string           $value
  */
 protected function _setFieldText(WebDriverElement $element, $value)
 {
     $element->clear();
     $element->sendKeys($value);
 }
 /**
  * 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 . '/>';
 }