Commit d77c9b45 authored by effulgentsia's avatar effulgentsia
Browse files

Issue #3183420 by alexpott, catch: Override...

Issue #3183420 by alexpott, catch: Override \Behat\Mink\Driver\Selenium2Driver::uploadFile() in DrupalSelenium2Driver
parent e2c0ffb4
......@@ -43,6 +43,32 @@ public function setCookie($name, $value = NULL) {
* {@inheritdoc}
public function attachFile($xpath, $path) {
$element = $this->getWebDriverSession()->element('xpath', $xpath);
if ('input' !== strtolower($element->name()) || 'file' !== 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, 'attach a file on', $xpath, 'file'));
// 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->uploadFileAndGetRemoteFilePath($path);
catch (\Exception $e) {
// File could not be uploaded to remote instance. Use the local path.
$remotePath = $path;
$element->postValue(['value' => [$remotePath]]);
* Uploads a file to the Selenium instance and returns the remote path.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment