예제 #1
0
파일: Div.php 프로젝트: aoemedia/menta
 /**
  * Retrieve element coordinates
  *
  * @param \WebDriver\Element $element
  * @return array
  */
 public static function getElementCoordinates(\WebDriver\Element $element)
 {
     $location = $element->location();
     $size = $element->size();
     return array('x1' => $location['x'], 'y1' => $location['y'], 'x2' => $size['width'] + $location['x'], 'y2' => $size['height'] + $location['y']);
 }
 /**
  * Ensures the element is a checkbox
  *
  * @param Element $element
  * @param string  $xpath
  * @param string  $type
  * @param string  $action
  *
  * @throws DriverException
  */
 private function ensureInputType(Element $element, $xpath, $type, $action)
 {
     if ('input' !== strtolower($element->name()) || $type !== strtolower($element->attribute('type'))) {
         $message = 'Impossible to %s the element with XPath "%s" as it is not a %s input';
         throw new DriverException(sprintf($message, $action, $xpath, $type));
     }
 }
예제 #3
0
 /**
  * @return boolean
  */
 public function equals(Element $element)
 {
     return $this->requestValue('equals/' . $element->getId());
 }
예제 #4
0
 /**
  * Method to select an element, using a selector (css, xpath, etc.).
  *
  * @param By $by Indicates how to search for the element
  *
  * @return Element
  *
  * @see By
  */
 public function element(By $by, Element $from = null)
 {
     if (null === $from) {
         $uri = 'element';
     } else {
         $uri = 'element/' . $from->getId() . '/element';
     }
     $response = $this->request('POST', $uri, json_encode($by->toArray()));
     $data = json_decode($response->getContent(), true);
     if (!isset($data['value']['ELEMENT'])) {
         throw new LibraryException('Missing key value.ELEMENT');
     }
     $id = $data['value']['ELEMENT'];
     return new Element($this, $id);
 }