public function PhantomJSDriver::attachFile in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/jcalderonzumba/mink-phantomjs-driver/src/PhantomJSDriver.php \Zumba\Mink\Driver\PhantomJSDriver::attachFile()
Upload a file to the browser
Parameters
string $xpath:
string $path:
Throws
Overrides CoreDriver::attachFile
File
- vendor/
jcalderonzumba/ mink-phantomjs-driver/ src/ PhantomJSDriver.php, line 86
Class
- PhantomJSDriver
- Class PhantomJSDriver @package Behat\Mink\Driver
Namespace
Zumba\Mink\DriverCode
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);
}