public function attachFile($xpath, $path) {
    if (!file_exists($path)) {
      throw new DriverException("Wow there the file does not exist, you can not upload it");
    }

    if (($realPath = realpath($path)) === false) {
      throw new DriverException("Wow there the file does not exist, you can not upload it");
    }

    $element = $this->findElement($xpath, 1);
    $tagName = $this->getTagName($xpath);
    if ($tagName != "input") {
      throw new DriverException("The element is not an input element, you can not attach a file to it");
    }

    $attributes = $this->getBrowser()->attributes($element["page_id"], $element["ids"][0]);
    if (!isset($attributes["type"]) || $attributes["type"] != "file") {
      throw new DriverException("The element is not an input file type element, you can not attach a file to it");
    }

    $this->browser->selectFile($element["page_id"], $element["ids"][0], $realPath);
  }
public function attachFile($xpath, $path) {
    if (!file_exists($path)) {
      throw new DriverException("Wow there the file does not exist, you can not upload it");
    }

    if (($realPath = realpath($path)) === false) {
      throw new DriverException("Wow there the file does not exist, you can not upload it");
    }

    $element = $this->findElement($xpath, 1);
    $tagName = $this->getTagName($xpath);
    if ($tagName != "input") {
      throw new DriverException("The element is not an input element, you can not attach a file to it");
    }

    $attributes = $this->getBrowser()->attributes($element["page_id"], $element["ids"][0]);
    if (!isset($attributes["type"]) || $attributes["type"] != "file") {
      throw new DriverException("The element is not an input file type element, you can not attach a file to it");
    }

    $this->browser->selectFile($element["page_id"], $element["ids"][0], $realPath);
  }
public function attachFile ( $ xpath , $ path ) { if ( ! file_exists ( $ path ) ) { throw new DriverException ( "Wow there the file does not exist, you can not upload it" ) ; } if ( ( $ realPath = realpath ( $ path ) ) === false ) { throw new DriverException ( "Wow there the file does not exist, you can not upload it" ) ; } $ element = $ this -> findElement ( $ xpath , 1 ) ; $ tagName = $ this -> getTagName ( $ xpath ) ; if ( $ tagName != "input" ) { throw new DriverException ( "The element is not an input element, you can not attach a file to it" ) ; } $ attributes = $ this -> getBrowser ( ) -> attributes ( $ element [ "page_id" ] , $ element [ "ids" ] [ 0 ] ) ; if ( ! isset ( $ attributes [ "type" ] ) || $ attributes [ "type" ] != "file" ) { throw new DriverException ( "The element is not an input file type element, you can not attach a file to it" ) ; } $ this -> browser -> selectFile ( $ element [ "page_id" ] , $ element [ "ids" ] [ 0 ] , $ realPath ) ; }
Upload a file to the browser
@param string $xpath
@param string $path
@throws DriverException
Upload a file to the browser