コード例 #1
0
 /**
  * Move the web drivers mouse to the expected element.
  *
  * @param RemoteWebElement $element Element to hover.
  * @param bool|null        $click   (Optional) Click at the hovered element after moving.
  *
  * @return MouseTrait|$this Same instance for chained method calls.
  */
 public function moveMouseToElement(RemoteWebElement $element, $click = null)
 {
     $mouse = $this->getWebDriver()->getMouse()->mouseMove($element->getCoordinates());
     $click ? $mouse->click() : null;
     return $this;
 }
コード例 #2
0
 /**
  * Create screenshot for an element
  *
  * @param string $referenceImageName
  * @param RemoteWebElement $element
  * @return \Imagick
  */
 protected function _createScreenshot($referenceImageName, RemoteWebElement $element)
 {
     // Try scrolling the element into the view port
     $element->getLocationOnScreenOnceScrolledIntoView();
     $tempImagePath = $this->moduleFileSystemUtil->getTempImagePath($referenceImageName);
     $this->webDriver->webDriver->takeScreenshot($tempImagePath);
     $image = new \Imagick($tempImagePath);
     $image->cropImage($element->getSize()->getWidth(), $element->getSize()->getHeight(), $element->getCoordinates()->onPage()->getX(), $element->getCoordinates()->onPage()->getY());
     $image->setImageFormat('png');
     $image->writeImage($tempImagePath);
     return $image;
 }