You are here

public function BrowserKitDriver::attachFile in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/behat/mink-browserkit-driver/src/BrowserKitDriver.php \Behat\Mink\Driver\BrowserKitDriver::attachFile()

Attaches file path to file field located by it's XPath query.

Parameters

string $xpath:

string $path:

Throws

UnsupportedDriverActionException When operation not supported by the driver

DriverException When the operation cannot be done

Overrides CoreDriver::attachFile

See also

\Behat\Mink\Element\NodeElement::attachFile

File

vendor/behat/mink-browserkit-driver/src/BrowserKitDriver.php, line 513

Class

BrowserKitDriver
Symfony2 BrowserKit driver.

Namespace

Behat\Mink\Driver

Code

public function attachFile($xpath, $path) {
  $field = $this
    ->getFormField($xpath);
  if (!$field instanceof FileFormField) {
    throw new DriverException(sprintf('Impossible to attach a file on the element with XPath "%s" as it is not a file input', $xpath));
  }
  $field
    ->upload($path);
}