function Selenium2Driver::attachFile
Overrides CoreDriver::attachFile
File
-
vendor/
lullabot/ mink-selenium2-driver/ src/ Selenium2Driver.php, line 920
Class
- Selenium2Driver
- Selenium2 driver.
Namespace
Behat\Mink\DriverCode
public function attachFile(string $xpath, string $path) {
$element = $this->findElement($xpath);
$this->ensureInputType($element, $xpath, 'file', 'attach a file on');
// Upload the file to Selenium and use the remote path. This will
// ensure that Selenium always has access to the file, even if it runs
// as a remote instance.
try {
$remotePath = $this->uploadFile($path);
} catch (\Exception $e) {
// File could not be uploaded to remote instance. Use the local path.
$remotePath = $path;
}
if ($this->isW3C()) {
$element->postValue(array(
'text' => $remotePath,
));
}
else {
$element->postValue(array(
'value' => array(
$remotePath,
),
));
}
}