diff --git a/core/tests/Drupal/FunctionalJavascriptTests/DrupalSelenium2Driver.php b/core/tests/Drupal/FunctionalJavascriptTests/DrupalSelenium2Driver.php
index 5f243af670..b1060ccf90 100644
--- a/core/tests/Drupal/FunctionalJavascriptTests/DrupalSelenium2Driver.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/DrupalSelenium2Driver.php
@@ -3,6 +3,8 @@
 namespace Drupal\FunctionalJavascriptTests;
 
 use Behat\Mink\Driver\Selenium2Driver;
+use Behat\Mink\Exception\DriverException;
+use WebDriver\Exception\UnknownError;
 
 /**
  * Provides a driver for Selenium testing.
@@ -32,4 +34,73 @@ public function setCookie($name, $value = NULL) {
     $this->getWebDriverSession()->setCookie($cookieArray);
   }
 
+  /**
+   * Uploads a file to the Selenium instance and gets remote path.
+   *
+   * Copied from \Behat\Mink\Driver\Selenium2Driver::uploadFile().
+   *
+   * @param string $path
+   *   The path to the file to upload.
+   *
+   * @return string
+   *   The remote path.
+   *
+   * @throws DriverException
+   *   When PHP is compiled without zip support, or the file doesn't exist.
+   * @throws UnknownError
+   *   When an unknown error occurred during file upload.
+   * @throws \Exception
+   *   When a known error occurred during file upload.
+   */
+  public function getRemoteFilePath($path) {
+    if (!is_file($path)) {
+      throw new DriverException('File does not exist locally and cannot be uploaded to the remote instance.');
+    }
+
+    if (!class_exists('ZipArchive')) {
+      throw new DriverException('Could not compress file, PHP is compiled without zip support.');
+    }
+
+    // Selenium only accepts uploads that are compressed as a Zip archive.
+    $tempFilename = tempnam('', 'WebDriverZip');
+
+    $archive = new \ZipArchive();
+    $result = $archive->open($tempFilename, \ZipArchive::CREATE);
+    if (!$result) {
+      throw new DriverException('Zip archive could not be created. Error ' . $result);
+    }
+    $result = $archive->addFile($path, basename($path));
+    if (!$result) {
+      throw new DriverException('File could not be added to zip archive.');
+    }
+    $result = $archive->close();
+    if (!$result) {
+      throw new DriverException('Zip archive could not be closed.');
+    }
+
+    try {
+      $remotePath = $this->getWebDriverSession()->file(array('file' => base64_encode(file_get_contents($tempFilename))));
+
+      // If no path is returned the file upload failed silently. In this
+      // case it is possible Selenium was not used but another web driver
+      // such as PhantomJS.
+      // @todo Support other drivers when (if) they get remote file transfer
+      // capability.
+      if (empty($remotePath)) {
+        throw new UnknownError();
+      }
+    }
+    catch (\Exception $e) {
+      // Catch any error so we can still clean up the temporary archive.
+    }
+
+    unlink($tempFilename);
+
+    if (isset($e)) {
+      throw $e;
+    }
+
+    return $remotePath;
+  }
+
 }
diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Tests/DrupalSelenium2DriverTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Tests/DrupalSelenium2DriverTest.php
new file mode 100644
index 0000000000..97380c657a
--- /dev/null
+++ b/core/tests/Drupal/FunctionalJavascriptTests/Tests/DrupalSelenium2DriverTest.php
@@ -0,0 +1,102 @@
+<?php
+
+namespace Drupal\FunctionalJavascriptTests\Tests;
+
+use Drupal\Core\Field\FieldStorageDefinitionInterface;
+use Drupal\FunctionalJavascriptTests\DrupalSelenium2Driver;
+use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\node\Entity\Node;
+use Drupal\Tests\image\Kernel\ImageFieldCreationTrait;
+use Drupal\Tests\TestFileCreationTrait;
+
+/**
+ * Tests the DrupalSelenium2Driver methods.
+ *
+ * @coversDefaultClass \Drupal\FunctionalJavascriptTests\DrupalSelenium2Driver
+ * @group javascript
+ */
+class DrupalSelenium2DriverTest extends JavascriptTestBase {
+
+  use ImageFieldCreationTrait;
+  use TestFileCreationTrait;
+
+  /**
+   * {@inheritdoc}
+   */
+  protected $minkDefaultDriverClass = DrupalSelenium2Driver::class;
+
+  /**
+   * {@inheritdoc}
+   */
+  protected static $modules = ['node', 'image', 'field_ui'];
+
+  /**
+   * WebDriver.
+   *
+   * @var \Drupal\FunctionalJavascriptTests\DrupalSelenium2Driver
+   */
+  protected $webDriver;
+
+  /**
+   * The file system service.
+   *
+   * @var \Drupal\Core\File\FileSystem
+   */
+  protected $fileSystem;
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+    $this->webDriver = $this->getSession()->getDriver();
+    $this->fileSystem = \Drupal::service('file_system');
+
+    $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
+    $storage_settings = ['cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED];
+    $field_settings = ['alt_field_required' => 0];
+    $this->createImageField('images', 'article', $storage_settings, $field_settings);
+    $this->drupalLogin($this->drupalCreateUser(['access content', 'create article content']));
+  }
+
+  /**
+   * Tests upload remote files.
+   *
+   * @covers ::getRemoteFilePath
+   */
+  public function testGetRemoteFilePath() {
+
+    $this->drupalGet('node/add/article');
+    $this->xpath('//input[@name="title[0][value]"]')[0]->setValue('Test');
+    $multiple_field = $this->xpath('//input[@multiple]')[0];
+
+    $images = array_slice($this->getTestFiles('image'), 0, 3);
+
+    $real_paths = [];
+    foreach ($images as $image) {
+      $real_paths[] = $this->fileSystem->realpath($image->uri);
+    }
+
+    $remote_paths = [];
+    foreach ($real_paths as $path) {
+      $remote_paths[] = $this->webDriver->getRemoteFilePath($path);
+    }
+    $multiple_field->setValue(implode("\n", $remote_paths));
+    $this->getSession()->getPage()->findButton('Save')->click();
+    $node = Node::load(1);
+    $this->assertNotEmpty($node->images);
+
+    // Tests that upload remote files not works without getRemoteFilePath().
+    $this->drupalGet('node/add/article');
+    $this->xpath('//input[@name="title[0][value]"]')[0]->setValue('Test');
+    $multiple_field = $this->xpath('//input[@multiple]')[0];
+    try {
+      $multiple_field->setValue(implode("\n", $real_paths));
+      $this->fail('setValue() works with real path without problem! Can we remove our workaround with getRemoteFilePath() method?');
+    }
+    catch (\Exception $e) {
+      $this->assertContains('File not found', $e->getMessage());
+    }
+  }
+
+}
