diff --git a/core/drupalci.yml b/core/drupalci.yml
index b658e475b8..b539d562af 100644
--- a/core/drupalci.yml
+++ b/core/drupalci.yml
@@ -47,7 +47,7 @@ build:
       # Functional JavaScript tests require a concurrency of 1 because there is
       # only one instance of PhantomJS on the testbot machine.
       run_tests.javascript:
-        concurrency: 1
+        concurrency: 15
         types: 'PHPUnit-FunctionalJavascript'
         testgroups: '--all'
         suppress-deprecations: false
diff --git a/core/modules/action/tests/src/FunctionalJavascript/ActionFormAjaxTest.php b/core/modules/action/tests/src/FunctionalJavascript/ActionFormAjaxTest.php
index bc314a573d..f4c85fc755 100644
--- a/core/modules/action/tests/src/FunctionalJavascript/ActionFormAjaxTest.php
+++ b/core/modules/action/tests/src/FunctionalJavascript/ActionFormAjaxTest.php
@@ -3,7 +3,7 @@
 namespace Drupal\Tests\action\FunctionalJavascript;
 
 use Drupal\Core\Url;
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 use Drupal\system\Entity\Action;
 
 /**
@@ -11,7 +11,7 @@
  *
  * @group action
  */
-class ActionFormAjaxTest extends JavascriptTestBase {
+class ActionFormAjaxTest extends WebDriverTestBase {
 
   /**
    * {@inheritdoc}
@@ -33,16 +33,15 @@ protected function setUp() {
   public function testActionConfigurationWithAjax() {
     $url = Url::fromRoute('action.admin_add', ['action_id' => 'action_form_ajax_test']);
     $this->drupalGet($url);
-    $this->assertSession()->statusCodeEquals(200);
     $page = $this->getSession()->getPage();
 
     $id = 'test_plugin';
-    $page->find('css', '[name="id"]')
-      ->setValue($id);
+    $this->assertSession()->waitForElementVisible('named', ['button', 'Edit'])->press();
+    $this->assertSession()->waitForElementVisible('css', '[name="id"]')->setValue($id);
 
     $page->find('css', '[name="having_a_party"]')
       ->check();
-    $this->assertSession()->waitForElement('css', '[name="party_time"]');
+    $this->assertSession()->waitForElementVisible('css', '[name="party_time"]');
 
     $party_time = 'Evening';
     $page->find('css', '[name="party_time"]')
@@ -54,7 +53,6 @@ public function testActionConfigurationWithAjax() {
     $url = Url::fromRoute('entity.action.collection');
     $this->assertSession()->pageTextContains('The action has been successfully saved.');
     $this->assertSession()->addressEquals($url);
-    $this->assertSession()->statusCodeEquals(200);
 
     // Check storage.
     $instance = Action::load($id);
diff --git a/core/modules/big_pipe/tests/src/FunctionalJavascript/BigPipeRegressionTest.php b/core/modules/big_pipe/tests/src/FunctionalJavascript/BigPipeRegressionTest.php
index b4da7b0a9b..f4cd5108bf 100644
--- a/core/modules/big_pipe/tests/src/FunctionalJavascript/BigPipeRegressionTest.php
+++ b/core/modules/big_pipe/tests/src/FunctionalJavascript/BigPipeRegressionTest.php
@@ -11,7 +11,7 @@
 use Drupal\Core\Url;
 use Drupal\editor\Entity\Editor;
 use Drupal\filter\Entity\FilterFormat;
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 use Drupal\simpletest\ContentTypeCreationTrait;
 use Drupal\simpletest\NodeCreationTrait;
 
@@ -20,7 +20,7 @@
  *
  * @group big_pipe
  */
-class BigPipeRegressionTest extends JavascriptTestBase {
+class BigPipeRegressionTest extends WebDriverTestBase {
 
   use CommentTestTrait;
   use ContentTypeCreationTrait;
diff --git a/core/modules/block/tests/src/FunctionalJavascript/BlockFilterTest.php b/core/modules/block/tests/src/FunctionalJavascript/BlockFilterTest.php
index b64f7c1ba2..e9ecc06526 100644
--- a/core/modules/block/tests/src/FunctionalJavascript/BlockFilterTest.php
+++ b/core/modules/block/tests/src/FunctionalJavascript/BlockFilterTest.php
@@ -3,14 +3,14 @@
 namespace Drupal\Tests\block\FunctionalJavascript;
 
 use Behat\Mink\Element\NodeElement;
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 
 /**
  * Tests the JavaScript functionality of the block add filter.
  *
  * @group block
  */
-class BlockFilterTest extends JavascriptTestBase {
+class BlockFilterTest extends WebDriverTestBase {
 
   /**
    * {@inheritdoc}
diff --git a/core/modules/book/tests/src/FunctionalJavascript/BookJavascriptTest.php b/core/modules/book/tests/src/FunctionalJavascript/BookJavascriptTest.php
index d8d406b440..dc9b8125cc 100644
--- a/core/modules/book/tests/src/FunctionalJavascript/BookJavascriptTest.php
+++ b/core/modules/book/tests/src/FunctionalJavascript/BookJavascriptTest.php
@@ -4,7 +4,7 @@
 
 use Behat\Mink\Exception\ExpectationException;
 use Drupal\Component\Render\FormattableMarkup;
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 use Drupal\node\Entity\Node;
 
 /**
@@ -12,7 +12,7 @@
  *
  * @group book
  */
-class BookJavascriptTest extends JavascriptTestBase {
+class BookJavascriptTest extends WebDriverTestBase {
 
   /**
    * {@inheritdoc}
diff --git a/core/modules/ckeditor/tests/src/FunctionalJavascript/AjaxCssTest.php b/core/modules/ckeditor/tests/src/FunctionalJavascript/AjaxCssTest.php
index b15433d4f7..ddb53d8303 100644
--- a/core/modules/ckeditor/tests/src/FunctionalJavascript/AjaxCssTest.php
+++ b/core/modules/ckeditor/tests/src/FunctionalJavascript/AjaxCssTest.php
@@ -4,14 +4,14 @@
 
 use Drupal\editor\Entity\Editor;
 use Drupal\filter\Entity\FilterFormat;
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 
 /**
  * Tests delivery of CSS to CKEditor via AJAX.
  *
  * @group ckeditor
  */
-class AjaxCssTest extends JavascriptTestBase {
+class AjaxCssTest extends WebDriverTestBase {
 
   /**
    * {@inheritdoc}
diff --git a/core/modules/ckeditor/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php b/core/modules/ckeditor/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php
index 80de46d6bc..a9ee69719b 100644
--- a/core/modules/ckeditor/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php
+++ b/core/modules/ckeditor/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php
@@ -7,7 +7,7 @@
 use Drupal\field\Entity\FieldConfig;
 use Drupal\field\Entity\FieldStorageConfig;
 use Drupal\filter\Entity\FilterFormat;
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 use Drupal\node\Entity\NodeType;
 
 /**
@@ -15,7 +15,7 @@
  *
  * @group ckeditor
  */
-class CKEditorIntegrationTest extends JavascriptTestBase {
+class CKEditorIntegrationTest extends WebDriverTestBase {
 
   /**
    * The account.
@@ -92,9 +92,10 @@ public function testFragmentLink() {
     $session->getPage();
 
     // Add a bottom margin to the title field to be sure the body field is not
-    // visible. PhantomJS runs with a resolution of 1024x768px.
-    $session->executeScript("document.getElementById('edit-title-0-value').style.marginBottom = '800px';");
+    // visible.
+    $session->executeScript("document.getElementById('edit-title-0-value').style.marginBottom = window.innerHeight*2 +'px';");
 
+    $this->assertSession()->waitForElementVisible('css', $ckeditor_id);
     // Check that the CKEditor-enabled body field is currently not visible in
     // the viewport.
     $web_assert->assertNotVisibleInViewport('css', $ckeditor_id, 'topLeft', 'CKEditor-enabled body field is visible.');
diff --git a/core/modules/config/tests/src/FunctionalJavascript/ConfigEntityTest.php b/core/modules/config/tests/src/FunctionalJavascript/ConfigEntityTest.php
index 110c9f894e..f7e6dc8ff5 100644
--- a/core/modules/config/tests/src/FunctionalJavascript/ConfigEntityTest.php
+++ b/core/modules/config/tests/src/FunctionalJavascript/ConfigEntityTest.php
@@ -2,14 +2,14 @@
 
 namespace Drupal\Tests\config\FunctionalJavascript;
 
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 
 /**
  * Tests the Config operations through the UI.
  *
  * @group config
  */
-class ConfigEntityTest extends JavascriptTestBase {
+class ConfigEntityTest extends WebDriverTestBase {
 
   /**
    * {@inheritdoc}
diff --git a/core/modules/config_translation/tests/src/FunctionalJavascript/ConfigTranslationUiTest.php b/core/modules/config_translation/tests/src/FunctionalJavascript/ConfigTranslationUiTest.php
index 13e1b545c2..585d2d1d38 100644
--- a/core/modules/config_translation/tests/src/FunctionalJavascript/ConfigTranslationUiTest.php
+++ b/core/modules/config_translation/tests/src/FunctionalJavascript/ConfigTranslationUiTest.php
@@ -2,14 +2,14 @@
 
 namespace Drupal\Tests\config_translation\FunctionalJavascript;
 
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 
 /**
  * Translate settings and entities to various languages.
  *
  * @group config_translation
  */
-class ConfigTranslationUiTest extends JavascriptTestBase {
+class ConfigTranslationUiTest extends WebDriverTestBase {
 
   /**
    * {@inheritdoc}
diff --git a/core/modules/content_translation/tests/src/FunctionalJavascript/ContentTranslationContextualLinksTest.php b/core/modules/content_translation/tests/src/FunctionalJavascript/ContentTranslationContextualLinksTest.php
index b095399195..156b10d97f 100644
--- a/core/modules/content_translation/tests/src/FunctionalJavascript/ContentTranslationContextualLinksTest.php
+++ b/core/modules/content_translation/tests/src/FunctionalJavascript/ContentTranslationContextualLinksTest.php
@@ -2,7 +2,7 @@
 
 namespace Drupal\Tests\content_translation\FunctionalJavascript;
 
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 use Drupal\language\Entity\ConfigurableLanguage;
 
 /**
@@ -10,7 +10,7 @@
  *
  * @group content_translation
  */
-class ContentTranslationContextualLinksTest extends JavascriptTestBase {
+class ContentTranslationContextualLinksTest extends WebDriverTestBase {
 
   /**
    * The 'translator' user to use during testing.
diff --git a/core/modules/contextual/tests/src/FunctionalJavascript/ContextualLinksTest.php b/core/modules/contextual/tests/src/FunctionalJavascript/ContextualLinksTest.php
index de83692411..7435dada23 100644
--- a/core/modules/contextual/tests/src/FunctionalJavascript/ContextualLinksTest.php
+++ b/core/modules/contextual/tests/src/FunctionalJavascript/ContextualLinksTest.php
@@ -2,7 +2,7 @@
 
 namespace Drupal\Tests\contextual\FunctionalJavascript;
 
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 use Drupal\user\Entity\Role;
 
 /**
@@ -10,7 +10,7 @@
  *
  * @group contextual
  */
-class ContextualLinksTest extends JavascriptTestBase {
+class ContextualLinksTest extends WebDriverTestBase {
 
   use ContextualLinkClickTrait;
 
diff --git a/core/modules/contextual/tests/src/FunctionalJavascript/EditModeTest.php b/core/modules/contextual/tests/src/FunctionalJavascript/EditModeTest.php
index a61ea8a3d7..4a00a7efc4 100644
--- a/core/modules/contextual/tests/src/FunctionalJavascript/EditModeTest.php
+++ b/core/modules/contextual/tests/src/FunctionalJavascript/EditModeTest.php
@@ -2,14 +2,14 @@
 
 namespace Drupal\Tests\contextual\FunctionalJavascript;
 
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 
 /**
  * Tests edit mode.
  *
  * @group contextual
  */
-class EditModeTest extends JavascriptTestBase {
+class EditModeTest extends WebDriverTestBase {
 
   /**
    * CSS selector for Drupal's announce element.
diff --git a/core/modules/field/tests/src/FunctionalJavascript/FormJSAddMoreTest.php b/core/modules/field/tests/src/FunctionalJavascript/FormJSAddMoreTest.php
index 64ee24d469..0561d73711 100644
--- a/core/modules/field/tests/src/FunctionalJavascript/FormJSAddMoreTest.php
+++ b/core/modules/field/tests/src/FunctionalJavascript/FormJSAddMoreTest.php
@@ -6,14 +6,14 @@
 use Drupal\Core\Field\FieldStorageDefinitionInterface;
 use Drupal\field\Entity\FieldConfig;
 use Drupal\field\Entity\FieldStorageConfig;
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 
 /**
  * Tests add more behavior for a multiple value field.
  *
  * @group field
  */
-class FormJSAddMoreTest extends JavascriptTestBase {
+class FormJSAddMoreTest extends WebDriverTestBase {
 
   /**
    * {@inheritdoc}
diff --git a/core/modules/field_layout/tests/src/FunctionalJavascript/FieldLayoutTest.php b/core/modules/field_layout/tests/src/FunctionalJavascript/FieldLayoutTest.php
index 162d22329c..9e65b270be 100644
--- a/core/modules/field_layout/tests/src/FunctionalJavascript/FieldLayoutTest.php
+++ b/core/modules/field_layout/tests/src/FunctionalJavascript/FieldLayoutTest.php
@@ -3,14 +3,14 @@
 namespace Drupal\Tests\field_layout\FunctionalJavascript;
 
 use Drupal\entity_test\Entity\EntityTest;
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 
 /**
  * Tests using field layout for entity displays.
  *
  * @group field_layout
  */
-class FieldLayoutTest extends JavascriptTestBase {
+class FieldLayoutTest extends WebDriverTestBase {
 
   /**
    * {@inheritdoc}
@@ -100,12 +100,15 @@ public function testEntityForm() {
     // After a refresh the new regions are still there.
     $this->drupalGet('entity_test/structure/entity_test/form-display');
     $this->assertEquals(['Top', 'First', 'Second', 'Bottom', 'Disabled'], $this->getRegionTitles());
+    $this->assertSession()->waitForElement('css', '.tabledrag-handle');
+    $id = $this->getSession()->getPage()->find('css', '[name="form_build_id"]')->getValue();
 
     // Drag the field to the second region.
     $field_test_text_row = $this->getSession()->getPage()->find('css', '#field-test-text');
     $second_region_row = $this->getSession()->getPage()->find('css', '.region-second-message');
     $field_test_text_row->find('css', '.handle')->dragTo($second_region_row);
     $this->assertSession()->assertWaitOnAjaxRequest();
+    $this->assertSession()->waitForElement('css', "[name='form_build_id']:not([value='$id'])");
     $this->submitForm([], 'Save');
     $this->assertSession()->pageTextContains('Your settings have been saved.');
 
@@ -158,6 +161,8 @@ public function testEntityView() {
     // After a refresh the new regions are still there.
     $this->drupalGet('entity_test/structure/entity_test/display');
     $this->assertEquals(['Top', 'First', 'Second', 'Bottom', 'Disabled'], $this->getRegionTitles());
+    $this->assertSession()->waitForElement('css', '.tabledrag-handle');
+    $id = $this->getSession()->getPage()->find('css', '[name="form_build_id"]')->getValue();
 
     // Drag the field to the first region.
     $this->assertTrue($this->assertSession()->optionExists('fields[field_test_text][region]', 'hidden')->isSelected());
@@ -166,6 +171,7 @@ public function testEntityView() {
     $field_test_text_row->find('css', '.handle')->dragTo($first_region_row);
     $this->assertSession()->assertWaitOnAjaxRequest();
     $this->assertFalse($this->assertSession()->optionExists('fields[field_test_text][region]', 'hidden')->isSelected());
+    $this->assertSession()->waitForElement('css', "[name='form_build_id']:not([value='$id'])");
     $this->submitForm([], 'Save');
     $this->assertSession()->pageTextContains('Your settings have been saved.');
 
diff --git a/core/modules/field_ui/tests/src/FunctionalJavascript/EntityDisplayTest.php b/core/modules/field_ui/tests/src/FunctionalJavascript/EntityDisplayTest.php
index ae2c56c954..7909f0f006 100644
--- a/core/modules/field_ui/tests/src/FunctionalJavascript/EntityDisplayTest.php
+++ b/core/modules/field_ui/tests/src/FunctionalJavascript/EntityDisplayTest.php
@@ -3,14 +3,14 @@
 namespace Drupal\Tests\field_ui\FunctionalJavascript;
 
 use Drupal\entity_test\Entity\EntityTest;
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 
 /**
  * Tests the UI for entity displays.
  *
  * @group field_ui
  */
-class EntityDisplayTest extends JavascriptTestBase {
+class EntityDisplayTest extends WebDriverTestBase {
 
   /**
    * {@inheritdoc}
@@ -50,7 +50,8 @@ public function testEntityForm() {
 
     $this->drupalGet('entity_test/structure/entity_test/form-display');
     $this->assertTrue($this->assertSession()->optionExists('fields[field_test_text][region]', 'content')->isSelected());
-
+    $this->getSession()->getPage()->pressButton('Show row weights');
+    $this->assertSession()->waitForElementVisible('css', '[name="fields[field_test_text][region]"]');
     $this->getSession()->getPage()->selectFieldOption('fields[field_test_text][region]', 'hidden');
     $this->assertSession()->assertWaitOnAjaxRequest();
     $this->assertTrue($this->assertSession()->optionExists('fields[field_test_text][region]', 'hidden')->isSelected());
@@ -72,6 +73,8 @@ public function testEntityView() {
 
     $this->drupalGet('entity_test/structure/entity_test/display');
     $this->assertSession()->elementExists('css', '.region-content-message.region-empty');
+    $this->getSession()->getPage()->pressButton('Show row weights');
+    $this->assertSession()->waitForElementVisible('css', '[name="fields[field_test_text][region]"]');
     $this->assertTrue($this->assertSession()->optionExists('fields[field_test_text][region]', 'hidden')->isSelected());
 
     $this->getSession()->getPage()->selectFieldOption('fields[field_test_text][region]', 'content');
@@ -92,12 +95,16 @@ public function testEntityView() {
   public function testExtraFields() {
     entity_test_create_bundle('bundle_with_extra_fields');
     $this->drupalGet('entity_test/structure/bundle_with_extra_fields/display');
+    $this->assertSession()->waitForElement('css', '.tabledrag-handle');
+    $id = $this->getSession()->getPage()->find('css', '[name="form_build_id"]')->getValue();
 
     $extra_field_row = $this->getSession()->getPage()->find('css', '#display-extra-field');
     $disabled_region_row = $this->getSession()->getPage()->find('css', '.region-hidden-title');
 
     $extra_field_row->find('css', '.handle')->dragTo($disabled_region_row);
     $this->assertSession()->assertWaitOnAjaxRequest();
+    $this->assertSession()
+      ->waitForElement('css', "[name='form_build_id']:not([value='$id'])");
 
     $this->submitForm([], 'Save');
     $this->assertSession()->pageTextContains('Your settings have been saved.');
diff --git a/core/modules/file/tests/src/FunctionalJavascript/MaximumFileSizeExceededUploadTest.php b/core/modules/file/tests/src/FunctionalJavascript/MaximumFileSizeExceededUploadTest.php
index 7ccd2b2187..45c8bf5eec 100644
--- a/core/modules/file/tests/src/FunctionalJavascript/MaximumFileSizeExceededUploadTest.php
+++ b/core/modules/file/tests/src/FunctionalJavascript/MaximumFileSizeExceededUploadTest.php
@@ -3,7 +3,7 @@
 namespace Drupal\Tests\file\FunctionalJavascript;
 
 use Drupal\Component\Utility\Bytes;
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 use Drupal\Tests\TestFileCreationTrait;
 use Drupal\Tests\file\Functional\FileFieldCreationTrait;
 
@@ -12,7 +12,7 @@
  *
  * @group file
  */
-class MaximumFileSizeExceededUploadTest extends JavascriptTestBase {
+class MaximumFileSizeExceededUploadTest extends WebDriverTestBase {
 
   use FileFieldCreationTrait;
   use TestFileCreationTrait;
diff --git a/core/modules/image/tests/src/FunctionalJavascript/ImageFieldTestBase.php b/core/modules/image/tests/src/FunctionalJavascript/ImageFieldTestBase.php
index a4af78b9a3..4e21f6aca7 100644
--- a/core/modules/image/tests/src/FunctionalJavascript/ImageFieldTestBase.php
+++ b/core/modules/image/tests/src/FunctionalJavascript/ImageFieldTestBase.php
@@ -2,15 +2,14 @@
 
 namespace Drupal\Tests\image\FunctionalJavascript;
 
-use Drupal\FunctionalJavascriptTests\DrupalSelenium2Driver;
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 use Drupal\Tests\image\Kernel\ImageFieldCreationTrait;
 use Drupal\Tests\TestFileCreationTrait;
 
 /**
  * This class provides methods specifically for testing Image's field handling.
  */
-abstract class ImageFieldTestBase extends JavascriptTestBase {
+abstract class ImageFieldTestBase extends WebDriverTestBase {
 
   use ImageFieldCreationTrait;
   use TestFileCreationTrait {
@@ -29,11 +28,6 @@
     'image_module_test',
   ];
 
-  /**
-   * {@inheritdoc}
-   */
-  protected $minkDefaultDriverClass = DrupalSelenium2Driver::class;
-
   /**
    * An user with permissions to administer content types and image styles.
    *
diff --git a/core/modules/inline_form_errors/tests/src/FunctionalJavascript/FormErrorHandlerCKEditorTest.php b/core/modules/inline_form_errors/tests/src/FunctionalJavascript/FormErrorHandlerCKEditorTest.php
index 2007e1e266..7c9a74ab50 100644
--- a/core/modules/inline_form_errors/tests/src/FunctionalJavascript/FormErrorHandlerCKEditorTest.php
+++ b/core/modules/inline_form_errors/tests/src/FunctionalJavascript/FormErrorHandlerCKEditorTest.php
@@ -7,7 +7,7 @@
 use Drupal\field\Entity\FieldConfig;
 use Drupal\field\Entity\FieldStorageConfig;
 use Drupal\filter\Entity\FilterFormat;
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 use Drupal\node\Entity\NodeType;
 
 /**
@@ -15,7 +15,7 @@
  *
  * @group ckeditor
  */
-class FormErrorHandlerCKEditorTest extends JavascriptTestBase {
+class FormErrorHandlerCKEditorTest extends WebDriverTestBase {
 
   /**
    * {@inheritdoc}
@@ -87,9 +87,10 @@ public function testFragmentLink() {
 
     $this->submitForm($edit, 'Save');
 
+    $this->assertSession()->waitForElement('css', '#cke_edit-body-0-value');
     // Add a bottom margin to the title field to be sure the body field is not
-    // visible. PhantomJS runs with a resolution of 1024x768px.
-    $session->executeScript("document.getElementById('edit-title-0-value').style.marginBottom = '800px';");
+    // visible.
+    $session->executeScript("document.getElementById('edit-title-0-value').style.marginBottom = window.innerHeight*2 + 'px';");
 
     // Check that the CKEditor-enabled body field is currently not visible in
     // the viewport.
diff --git a/core/modules/inline_form_errors/tests/src/FunctionalJavascript/FormErrorHandlerQuickEditTest.php b/core/modules/inline_form_errors/tests/src/FunctionalJavascript/FormErrorHandlerQuickEditTest.php
index b956cccbd0..00dc3d3f62 100644
--- a/core/modules/inline_form_errors/tests/src/FunctionalJavascript/FormErrorHandlerQuickEditTest.php
+++ b/core/modules/inline_form_errors/tests/src/FunctionalJavascript/FormErrorHandlerQuickEditTest.php
@@ -2,7 +2,7 @@
 
 namespace Drupal\Tests\inline_form_errors\FunctionalJavascript;
 
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 use Drupal\node\Entity\NodeType;
 
 /**
@@ -10,7 +10,7 @@
  *
  * @group inline_form_errors
  */
-class FormErrorHandlerQuickEditTest extends JavascriptTestBase {
+class FormErrorHandlerQuickEditTest extends WebDriverTestBase {
 
   /**
    * Modules to enable.
diff --git a/core/modules/layout_builder/tests/src/FunctionalJavascript/FieldBlockTest.php b/core/modules/layout_builder/tests/src/FunctionalJavascript/FieldBlockTest.php
index 4f086d6a96..f2ecd52b3b 100644
--- a/core/modules/layout_builder/tests/src/FunctionalJavascript/FieldBlockTest.php
+++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/FieldBlockTest.php
@@ -4,14 +4,14 @@
 
 use Drupal\field\Entity\FieldConfig;
 use Drupal\field\Entity\FieldStorageConfig;
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 
 /**
  * @coversDefaultClass \Drupal\layout_builder\Plugin\Block\FieldBlock
  *
  * @group field
  */
-class FieldBlockTest extends JavascriptTestBase {
+class FieldBlockTest extends WebDriverTestBase {
 
   /**
    * {@inheritdoc}
diff --git a/core/modules/media/tests/src/FunctionalJavascript/MediaDisplayTest.php b/core/modules/media/tests/src/FunctionalJavascript/MediaDisplayTest.php
index 0549d2d16c..2b5ae1722d 100644
--- a/core/modules/media/tests/src/FunctionalJavascript/MediaDisplayTest.php
+++ b/core/modules/media/tests/src/FunctionalJavascript/MediaDisplayTest.php
@@ -55,6 +55,7 @@ public function testMediaDisplay() {
     // Enable the field on the display and verify it becomes visible on the UI.
     $this->drupalGet("/admin/structure/media/manage/{$media_type->id()}/display");
     $assert_session->buttonExists('Show row weights')->press();
+    $this->assertSession()->waitForElementVisible('css', '[name="fields[name][region]"]');
     $page->selectFieldOption('fields[name][region]', 'content');
     $assert_session->waitForElementVisible('css', '#edit-fields-name-settings-edit');
     $page->pressButton('Save');
diff --git a/core/modules/media/tests/src/FunctionalJavascript/MediaJavascriptTestBase.php b/core/modules/media/tests/src/FunctionalJavascript/MediaJavascriptTestBase.php
index 7fc26ec96e..fbc9998190 100644
--- a/core/modules/media/tests/src/FunctionalJavascript/MediaJavascriptTestBase.php
+++ b/core/modules/media/tests/src/FunctionalJavascript/MediaJavascriptTestBase.php
@@ -2,14 +2,14 @@
 
 namespace Drupal\Tests\media\FunctionalJavascript;
 
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 use Drupal\Tests\media\Functional\MediaFunctionalTestCreateMediaTypeTrait;
 use Drupal\Tests\media\Functional\MediaFunctionalTestTrait;
 
 /**
  * Base class for Media functional JavaScript tests.
  */
-abstract class MediaJavascriptTestBase extends JavascriptTestBase {
+abstract class MediaJavascriptTestBase extends WebDriverTestBase {
 
   use MediaFunctionalTestTrait;
   use MediaFunctionalTestCreateMediaTypeTrait;
diff --git a/core/modules/menu_ui/tests/src/FunctionalJavascript/MenuUiJavascriptTest.php b/core/modules/menu_ui/tests/src/FunctionalJavascript/MenuUiJavascriptTest.php
index 6ce4ccc713..22959326dc 100644
--- a/core/modules/menu_ui/tests/src/FunctionalJavascript/MenuUiJavascriptTest.php
+++ b/core/modules/menu_ui/tests/src/FunctionalJavascript/MenuUiJavascriptTest.php
@@ -2,7 +2,7 @@
 
 namespace Drupal\Tests\menu_ui\FunctionalJavascript;
 
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 use Drupal\system\Entity\Menu;
 use Drupal\Tests\contextual\FunctionalJavascript\ContextualLinkClickTrait;
 use Drupal\Tests\menu_ui\Traits\MenuUiTrait;
@@ -12,7 +12,7 @@
  *
  * @group menu_ui
  */
-class MenuUiJavascriptTest extends JavascriptTestBase {
+class MenuUiJavascriptTest extends WebDriverTestBase {
 
   use ContextualLinkClickTrait;
   use MenuUiTrait;
@@ -123,7 +123,6 @@ protected function addCustomMenu() {
   protected function addMenuLink($parent = '', $path = '/', $menu_id = 'tools', $expanded = FALSE, $weight = '0') {
     // View add menu link page.
     $this->drupalGet("admin/structure/menu/manage/$menu_id/add");
-    $this->assertSession()->statusCodeEquals(200);
 
     $title = '!link_' . $this->randomMachineName(16);
     $edit = [
@@ -138,7 +137,6 @@ protected function addMenuLink($parent = '', $path = '/', $menu_id = 'tools', $e
 
     // Add menu link.
     $this->drupalPostForm(NULL, $edit, 'Save');
-    $this->assertSession()->statusCodeEquals(200);
     $this->assertSession()->pageTextContains('The menu link has been saved.');
 
     $storage = $this->container->get('entity_type.manager')->getStorage('menu_link_content');
diff --git a/core/modules/node/tests/src/FunctionalJavascript/NodePreviewLinkTest.php b/core/modules/node/tests/src/FunctionalJavascript/NodePreviewLinkTest.php
index 8eb7a268d0..e1c185000f 100644
--- a/core/modules/node/tests/src/FunctionalJavascript/NodePreviewLinkTest.php
+++ b/core/modules/node/tests/src/FunctionalJavascript/NodePreviewLinkTest.php
@@ -3,14 +3,14 @@
 namespace Drupal\Tests\node\FunctionalJavascript;
 
 use Drupal\filter\Entity\FilterFormat;
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 
 /**
  * Tests the JavaScript prevention of navigation away from node previews.
  *
  * @group node
  */
-class NodePreviewLinkTest extends JavascriptTestBase {
+class NodePreviewLinkTest extends WebDriverTestBase {
 
   /**
    * {@inheritdoc}
diff --git a/core/modules/node/tests/src/FunctionalJavascript/TestSettingSummariesContentType.php b/core/modules/node/tests/src/FunctionalJavascript/TestSettingSummariesContentType.php
index 4760ee6509..aef0c1e27d 100644
--- a/core/modules/node/tests/src/FunctionalJavascript/TestSettingSummariesContentType.php
+++ b/core/modules/node/tests/src/FunctionalJavascript/TestSettingSummariesContentType.php
@@ -2,14 +2,14 @@
 
 namespace Drupal\Tests\node\FunctionalJavascript;
 
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 
 /**
  * Tests the JavaScript updating of summaries on content type form.
  *
  * @group node
  */
-class TestSettingSummariesContentType extends JavascriptTestBase {
+class TestSettingSummariesContentType extends WebDriverTestBase {
 
   /**
    * {@inheritdoc}
@@ -33,6 +33,8 @@ public function setUp() {
   public function testWorkflowSummary() {
     $this->drupalGet('admin/structure/types/manage/test');
     $page = $this->getSession()->getPage();
+    $page->find('css', 'a[href="#edit-workflow"]')->click();
+    $this->assertSession()->waitForElementVisible('css', '[name="options[status]"]');
     $page->findField('options[status]')->uncheck();
     $page->findField('options[sticky]')->check();
     $page->findField('options[promote]')->check();
diff --git a/core/modules/quickedit/tests/src/FunctionalJavascript/FieldTest.php b/core/modules/quickedit/tests/src/FunctionalJavascript/FieldTest.php
index 3e604700df..7555220acf 100644
--- a/core/modules/quickedit/tests/src/FunctionalJavascript/FieldTest.php
+++ b/core/modules/quickedit/tests/src/FunctionalJavascript/FieldTest.php
@@ -4,7 +4,7 @@
 
 use Drupal\editor\Entity\Editor;
 use Drupal\filter\Entity\FilterFormat;
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 use Drupal\node\Entity\Node;
 use Drupal\node\Entity\NodeType;
 use Drupal\Tests\contextual\FunctionalJavascript\ContextualLinkClickTrait;
@@ -14,7 +14,7 @@
  *
  * @group quickedit
  */
-class FieldTest extends JavascriptTestBase {
+class FieldTest extends WebDriverTestBase {
 
   use ContextualLinkClickTrait;
 
diff --git a/core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditJavascriptTestBase.php b/core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditJavascriptTestBase.php
index cb40a83cec..8c939b3264 100644
--- a/core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditJavascriptTestBase.php
+++ b/core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditJavascriptTestBase.php
@@ -2,21 +2,13 @@
 
 namespace Drupal\Tests\quickedit\FunctionalJavascript;
 
-use Drupal\FunctionalJavascriptTests\DrupalSelenium2Driver;
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 use WebDriver\Key;
 
 /**
  * Base class for testing the QuickEdit.
  */
-class QuickEditJavascriptTestBase extends JavascriptTestBase {
-
-  /**
-   * {@inheritdoc}
-   *
-   * @todo: Remove after https://www.drupal.org/project/drupal/issues/2942900
-   */
-  protected $minkDefaultDriverClass = DrupalSelenium2Driver::class;
+class QuickEditJavascriptTestBase extends WebDriverTestBase {
 
   /**
    * {@inheritdoc}
diff --git a/core/modules/settings_tray/tests/src/FunctionalJavascript/ConfigAccessTest.php b/core/modules/settings_tray/tests/src/FunctionalJavascript/ConfigAccessTest.php
index 8646b93ec3..6b15be9425 100644
--- a/core/modules/settings_tray/tests/src/FunctionalJavascript/ConfigAccessTest.php
+++ b/core/modules/settings_tray/tests/src/FunctionalJavascript/ConfigAccessTest.php
@@ -51,6 +51,7 @@ public function testBlockConfigAccess() {
     // permission.
     $web_assert->fieldNotExists('settings[site_information][site_name]');
     $page->pressButton('Save Site branding');
+    $this->waitForOffCanvasToClose();
     $this->assertElementVisibleAfterWait('css', 'div:contains(The block configuration has been saved)');
     $web_assert->assertWaitOnAjaxRequest();
     // Confirm we did not save changes to the configuration.
diff --git a/core/modules/settings_tray/tests/src/FunctionalJavascript/QuickEditIntegrationTest.php b/core/modules/settings_tray/tests/src/FunctionalJavascript/QuickEditIntegrationTest.php
index d30562f71d..6f623cb1bc 100644
--- a/core/modules/settings_tray/tests/src/FunctionalJavascript/QuickEditIntegrationTest.php
+++ b/core/modules/settings_tray/tests/src/FunctionalJavascript/QuickEditIntegrationTest.php
@@ -134,6 +134,8 @@ public function testCustomBlockLinks() {
     $this->placeBlock('block_content:' . $block_content->uuid(), ['id' => 'custom']);
     $this->drupalGet('user');
     $page = $this->getSession()->getPage();
+    $this->toggleContextualTriggerVisibility('#block-custom');
+    $page->find('css', '#block-custom .contextual button')->press();
     $links = $page->findAll('css', "#block-custom .contextual-links li a");
     $link_labels = [];
     /** @var \Behat\Mink\Element\NodeElement $link */
diff --git a/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php b/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php
index 106dae43e1..0e6b9d6251 100644
--- a/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php
+++ b/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayBlockFormTest.php
@@ -67,8 +67,8 @@ protected function doTestBlocks($theme, $block_plugin, $new_page_text, $element_
     $block_id = $block->id();
     $this->drupalGet('user');
 
-    $link = $page->find('css', "$block_selector .contextual-links li a");
-    $this->assertEquals('Quick edit', $link->getText(), "'Quick edit' is the first contextual link for the block.");
+    $link = $web_assert->waitForElement('css', "$block_selector .contextual-links li a");
+    $this->assertEquals('Quick edit', $link->getHtml(), "'Quick edit' is the first contextual link for the block.");
     $this->assertContains("/admin/structure/block/manage/$block_id/settings-tray?destination=user/2", $link->getAttribute('href'));
 
     if (isset($toolbar_item)) {
@@ -138,9 +138,11 @@ protected function doTestBlocks($theme, $block_plugin, $new_page_text, $element_
     $this->getSession()->executeScript('jQuery("body").trigger(jQuery.Event("keyup", { keyCode: 27 }));');
     $this->waitForOffCanvasToClose();
     $this->getSession()->wait(100);
+    $this->getSession()->executeScript("jQuery('[data-quickedit-entity-id]').trigger('mouseleave')");
+    $this->getSession()->getPage()->find('css', static::TOOLBAR_EDIT_LINK_SELECTOR)->mouseOver();
     $this->assertEditModeDisabled();
-    $web_assert->elementTextContains('css', '#drupal-live-announce', 'Exited edit mode.');
-    $web_assert->elementTextNotContains('css', '.contextual-toolbar-tab button', 'Editing');
+    $this->assertNotEmpty($web_assert->waitForElement('css', '#drupal-live-announce:contains(Exited edit mode)'));
+    $this->waitForNoElement('.contextual-toolbar-tab button:contains(Editing)');
     $web_assert->elementAttributeNotContains('css', '.dialog-off-canvas-main-canvas', 'class', 'js-settings-tray-edit-mode');
 
     // Clean up test data so each test does not impact the next.
diff --git a/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayTestBase.php b/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayTestBase.php
index 448fd21836..2017accd88 100644
--- a/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayTestBase.php
+++ b/core/modules/settings_tray/tests/src/FunctionalJavascript/SettingsTrayTestBase.php
@@ -49,7 +49,9 @@ protected function openBlockForm($block_selector, $contextual_link_container = '
     $this->assertElementVisibleAfterWait('css', '.dialog-off-canvas-main-canvas.js-settings-tray-edit-mode');
     // Ensure that all other Ajax activity is completed.
     $this->assertSession()->assertWaitOnAjaxRequest();
-    $this->click($block_selector);
+    $block = $this->getSession()->getPage()->find('css', $block_selector);
+    $block->mouseOver();
+    $block->click();
     $this->waitForOffCanvasToOpen();
     $this->assertOffCanvasBlockFormIsValid();
   }
@@ -79,6 +81,8 @@ protected function pressToolbarEditButton() {
     $edit_button = $this->getSession()
       ->getPage()
       ->find('css', static::TOOLBAR_EDIT_LINK_SELECTOR);
+    $this->getSession()->executeScript("jQuery('[data-quickedit-entity-id]').trigger('mouseleave')");
+    $edit_button->mouseOver();
     $edit_button->press();
   }
 
@@ -87,6 +91,12 @@ protected function pressToolbarEditButton() {
    */
   protected function assertEditModeDisabled() {
     $web_assert = $this->assertSession();
+    $page = $this->getSession()->getPage();
+    $this->getSession()->executeScript("jQuery('[data-quickedit-entity-id]').trigger('mouseleave')");
+    $page->find('css', static::TOOLBAR_EDIT_LINK_SELECTOR)->mouseOver();
+    $this->assertTrue($page->waitFor(10, function ($page) {
+      return !$page->find('css', '.contextual .trigger:not(.visually-hidden)');
+    }));
     // Contextual triggers should be hidden.
     $web_assert->elementExists('css', '.contextual .trigger.visually-hidden');
     // No contextual triggers should be not hidden.
@@ -103,6 +113,13 @@ protected function assertEditModeDisabled() {
    */
   protected function assertEditModeEnabled() {
     $web_assert = $this->assertSession();
+    $page = $this->getSession()->getPage();
+    // Move the mouse over the toolbar button so that isn't over a contextual
+    // links area which cause the contextual link to be shown.
+    $page->find('css', static::TOOLBAR_EDIT_LINK_SELECTOR)->mouseOver();
+    $this->assertTrue($page->waitFor(10, function ($page) {
+      return !$page->find('css', '.contextual .trigger.visually-hidden');
+    }));
     // No contextual triggers should be hidden.
     $web_assert->elementNotExists('css', '.contextual .trigger.visually-hidden');
     // The toolbar edit button should read "Editing".
diff --git a/core/modules/simpletest/tests/src/FunctionalJavascript/BrowserWithJavascriptTest.php b/core/modules/simpletest/tests/src/FunctionalJavascript/BrowserWithJavascriptTest.php
index 24397990e0..945afe95f8 100644
--- a/core/modules/simpletest/tests/src/FunctionalJavascript/BrowserWithJavascriptTest.php
+++ b/core/modules/simpletest/tests/src/FunctionalJavascript/BrowserWithJavascriptTest.php
@@ -2,14 +2,14 @@
 
 namespace Drupal\Tests\simpletest\FunctionalJavascript;
 
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 
 /**
  * Tests if we can execute JavaScript in the browser.
  *
  * @group javascript
  */
-class BrowserWithJavascriptTest extends JavascriptTestBase {
+class BrowserWithJavascriptTest extends WebDriverTestBase {
 
   public function testJavascript() {
     $this->drupalGet('<front>');
diff --git a/core/modules/simpletest/tests/src/FunctionalJavascript/JavascriptGetDrupalSettingsTest.php b/core/modules/simpletest/tests/src/FunctionalJavascript/JavascriptGetDrupalSettingsTest.php
index 0048159bfa..fbe9b73792 100644
--- a/core/modules/simpletest/tests/src/FunctionalJavascript/JavascriptGetDrupalSettingsTest.php
+++ b/core/modules/simpletest/tests/src/FunctionalJavascript/JavascriptGetDrupalSettingsTest.php
@@ -2,14 +2,14 @@
 
 namespace Drupal\Tests\simpletest\FunctionalJavascript;
 
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 
 /**
  * Tests Drupal settings retrieval in JavascriptTestBase tests.
  *
  * @group javascript
  */
-class JavascriptGetDrupalSettingsTest extends JavascriptTestBase {
+class JavascriptGetDrupalSettingsTest extends WebDriverTestBase {
 
   /**
    * {@inheritdoc}
@@ -19,7 +19,7 @@ class JavascriptGetDrupalSettingsTest extends JavascriptTestBase {
   /**
    * Tests retrieval of Drupal settings.
    *
-   * @see \Drupal\FunctionalJavascriptTests\JavascriptTestBase::getDrupalSettings()
+   * @see \Drupal\FunctionalJavascriptTests\WebDriverTestBase::getDrupalSettings()
    */
   public function testGetDrupalSettings() {
     $this->drupalLogin($this->drupalCreateUser());
diff --git a/core/modules/statistics/tests/src/FunctionalJavascript/StatisticsLoggingTest.php b/core/modules/statistics/tests/src/FunctionalJavascript/StatisticsLoggingTest.php
index b00f0ed47d..acd103e9f6 100644
--- a/core/modules/statistics/tests/src/FunctionalJavascript/StatisticsLoggingTest.php
+++ b/core/modules/statistics/tests/src/FunctionalJavascript/StatisticsLoggingTest.php
@@ -3,7 +3,7 @@
 namespace Drupal\Tests\statistics\FunctionalJavascript;
 
 use Drupal\Core\Session\AccountInterface;
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 use Drupal\language\Entity\ConfigurableLanguage;
 use Drupal\user\Entity\Role;
 
@@ -12,7 +12,7 @@
  *
  * @group system
  */
-class StatisticsLoggingTest extends JavascriptTestBase {
+class StatisticsLoggingTest extends WebDriverTestBase {
 
   /**
    * {@inheritdoc}
diff --git a/core/modules/system/tests/src/FunctionalJavascript/ModalRendererTest.php b/core/modules/system/tests/src/FunctionalJavascript/ModalRendererTest.php
index 7c0aec022c..3597ba46dd 100644
--- a/core/modules/system/tests/src/FunctionalJavascript/ModalRendererTest.php
+++ b/core/modules/system/tests/src/FunctionalJavascript/ModalRendererTest.php
@@ -2,14 +2,14 @@
 
 namespace Drupal\Tests\system\FunctionalJavascript;
 
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 
 /**
  * Tests that dialog links use different renderer services.
  *
  * @group system
  */
-class ModalRendererTest extends JavascriptTestBase {
+class ModalRendererTest extends WebDriverTestBase {
 
   /**
    * {@inheritdoc}
diff --git a/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTest.php b/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTest.php
index 7719634118..c42d777c13 100644
--- a/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTest.php
+++ b/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTest.php
@@ -50,7 +50,7 @@ public function testOffCanvasLinks($theme) {
       if ($link_index == '2') {
         // Check no title behavior.
         $web_assert->elementExists('css', '.ui-dialog-empty-title');
-        $this->assertEquals("\xc2\xa0", $header_text);
+        $this->assertEquals(' ', $header_text);
 
         $style = $page->find('css', '.ui-dialog-off-canvas')->getAttribute('style');
         $this->assertTrue(strstr($style, 'width: 555px;') !== FALSE, 'Dialog width respected.');
@@ -127,6 +127,9 @@ public function testNarrowWidth() {
       $this->waitForOffCanvasToOpen();
       // Check that the main canvas is padded when page is not narrow width and
       // tray is open.
+      $page->waitFor(10, function ($page) {
+        return $page->find('css', '.dialog-off-canvas-main-canvas')->hasAttribute('style');
+      });
       $web_assert->elementAttributeContains('css', '.dialog-off-canvas-main-canvas', 'style', 'padding-right');
 
       // Testing at the narrower width.
diff --git a/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTestBase.php b/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTestBase.php
index 293d9f70a0..b2e6c2b65d 100644
--- a/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTestBase.php
+++ b/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTestBase.php
@@ -2,12 +2,12 @@
 
 namespace Drupal\Tests\system\FunctionalJavascript;
 
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 
 /**
  * Base class contains common test functionality for the Off-canvas dialog.
  */
-abstract class OffCanvasTestBase extends JavascriptTestBase {
+abstract class OffCanvasTestBase extends WebDriverTestBase {
 
   /**
    * {@inheritdoc}
@@ -106,8 +106,22 @@ protected function getOffCanvasDialog() {
    * @todo Remove in https://www.drupal.org/node/2892440.
    */
   protected function waitForNoElement($selector, $timeout = 10000) {
-    $condition = "(typeof jQuery !== 'undefined' && jQuery('$selector').length === 0)";
-    $this->assertJsCondition($condition, $timeout);
+
+    $start = microtime(TRUE);
+    $end = $start + ($timeout / 1000);
+    $page = $this->getSession()->getPage();
+
+    do {
+      $result = $page->find('css', $selector);
+
+      if (empty($result)) {
+        return;
+      }
+
+      usleep(100000);
+    } while (microtime(TRUE) < $end);
+
+    $this->assertEmpty($result, 'Element was not on the page after wait.');
   }
 
   /**
@@ -132,6 +146,7 @@ protected function getTestThemes() {
    *   (Optional) Timeout in milliseconds, defaults to 10000.
    */
   protected function assertElementVisibleAfterWait($selector, $locator, $timeout = 10000) {
+    $this->assertSession()->assertWaitOnAjaxRequest();
     $this->assertNotEmpty($this->assertSession()->waitForElementVisible($selector, $locator, $timeout));
   }
 
diff --git a/core/modules/system/tests/src/FunctionalJavascript/ThemeFormSettingsTest.php b/core/modules/system/tests/src/FunctionalJavascript/ThemeFormSettingsTest.php
index 8e4729fe33..4f3e9f1d49 100644
--- a/core/modules/system/tests/src/FunctionalJavascript/ThemeFormSettingsTest.php
+++ b/core/modules/system/tests/src/FunctionalJavascript/ThemeFormSettingsTest.php
@@ -3,7 +3,7 @@
 namespace Drupal\Tests\system\FunctionalJavascript;
 
 use Drupal\file\Entity\File;
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 use Drupal\Tests\TestFileCreationTrait;
 
 /**
@@ -11,7 +11,7 @@
  *
  * @group system
  */
-class ThemeFormSettingsTest extends JavascriptTestBase {
+class ThemeFormSettingsTest extends WebDriverTestBase {
 
   use TestFileCreationTrait;
 
diff --git a/core/modules/text/tests/src/FunctionalJavascript/TextareaWithSummaryTest.php b/core/modules/text/tests/src/FunctionalJavascript/TextareaWithSummaryTest.php
index 76fbcc77d7..88153abce5 100644
--- a/core/modules/text/tests/src/FunctionalJavascript/TextareaWithSummaryTest.php
+++ b/core/modules/text/tests/src/FunctionalJavascript/TextareaWithSummaryTest.php
@@ -3,14 +3,14 @@
 namespace Drupal\Tests\text\FunctionalJavascript;
 
 use Drupal\field\Entity\FieldConfig;
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 
 /**
  * Tests the JavaScript functionality of the text_textarea_with_summary widget.
  *
  * @group text
  */
-class TextareaWithSummaryTest extends JavascriptTestBase {
+class TextareaWithSummaryTest extends WebDriverTestBase {
 
   /**
    * {@inheritdoc}
diff --git a/core/modules/toolbar/tests/src/FunctionalJavascript/ToolbarIntegrationTest.php b/core/modules/toolbar/tests/src/FunctionalJavascript/ToolbarIntegrationTest.php
index c3b3d9abc6..fd163985e7 100644
--- a/core/modules/toolbar/tests/src/FunctionalJavascript/ToolbarIntegrationTest.php
+++ b/core/modules/toolbar/tests/src/FunctionalJavascript/ToolbarIntegrationTest.php
@@ -2,14 +2,14 @@
 
 namespace Drupal\Tests\toolbar\FunctionalJavascript;
 
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 
 /**
  * Tests the JavaScript functionality of the toolbar.
  *
  * @group toolbar
  */
-class ToolbarIntegrationTest extends JavascriptTestBase {
+class ToolbarIntegrationTest extends WebDriverTestBase {
 
   /**
    * {@inheritdoc}
@@ -27,7 +27,12 @@ public function testToolbarToggling() {
     ]);
     $this->drupalLogin($admin_user);
 
+    // Set size for horizontal toolbar.
+    $this->getSession()->resizeWindow(1200, 600);
     $this->drupalGet('<front>');
+    $this->assertNotEmpty($this->assertSession()->waitForElement('css', 'body.toolbar-horizontal'));
+    $this->assertNotEmpty($this->assertSession()->waitForElementVisible('css', '.toolbar-tray'));
+
     $page = $this->getSession()->getPage();
 
     // Test that it is possible to toggle the toolbar tray.
diff --git a/core/modules/views/tests/src/FunctionalJavascript/ClickSortingAJAXTest.php b/core/modules/views/tests/src/FunctionalJavascript/ClickSortingAJAXTest.php
index 0e5095d81a..085fd821d5 100644
--- a/core/modules/views/tests/src/FunctionalJavascript/ClickSortingAJAXTest.php
+++ b/core/modules/views/tests/src/FunctionalJavascript/ClickSortingAJAXTest.php
@@ -2,7 +2,7 @@
 
 namespace Drupal\Tests\views\FunctionalJavascript;
 
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 use Drupal\simpletest\ContentTypeCreationTrait;
 use Drupal\simpletest\NodeCreationTrait;
 use Drupal\views\Tests\ViewTestData;
@@ -12,7 +12,7 @@
  *
  * @group views
  */
-class ClickSortingAJAXTest extends JavascriptTestBase {
+class ClickSortingAJAXTest extends WebDriverTestBase {
 
   use ContentTypeCreationTrait;
   use NodeCreationTrait;
diff --git a/core/modules/views/tests/src/FunctionalJavascript/ExposedFilterAJAXTest.php b/core/modules/views/tests/src/FunctionalJavascript/ExposedFilterAJAXTest.php
index 974aa2da42..9262ca2a58 100644
--- a/core/modules/views/tests/src/FunctionalJavascript/ExposedFilterAJAXTest.php
+++ b/core/modules/views/tests/src/FunctionalJavascript/ExposedFilterAJAXTest.php
@@ -2,7 +2,7 @@
 
 namespace Drupal\Tests\views\FunctionalJavascript;
 
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 use Drupal\simpletest\ContentTypeCreationTrait;
 use Drupal\simpletest\NodeCreationTrait;
 
@@ -11,7 +11,7 @@
  *
  * @group views
  */
-class ExposedFilterAJAXTest extends JavascriptTestBase {
+class ExposedFilterAJAXTest extends WebDriverTestBase {
 
   use ContentTypeCreationTrait;
   use NodeCreationTrait;
diff --git a/core/modules/views/tests/src/FunctionalJavascript/GlossaryViewTest.php b/core/modules/views/tests/src/FunctionalJavascript/GlossaryViewTest.php
index 594d6f764b..d4760e59b4 100644
--- a/core/modules/views/tests/src/FunctionalJavascript/GlossaryViewTest.php
+++ b/core/modules/views/tests/src/FunctionalJavascript/GlossaryViewTest.php
@@ -3,7 +3,7 @@
 namespace Drupal\Tests\views\FunctionalJavascript;
 
 use Drupal\Core\Url;
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 use Drupal\language\Entity\ConfigurableLanguage;
 use Drupal\simpletest\ContentTypeCreationTrait;
 use Drupal\simpletest\NodeCreationTrait;
@@ -14,7 +14,7 @@
  *
  * @group node
  */
-class GlossaryViewTest extends JavascriptTestBase {
+class GlossaryViewTest extends WebDriverTestBase {
 
   use ContentTypeCreationTrait;
   use NodeCreationTrait;
diff --git a/core/modules/views/tests/src/FunctionalJavascript/PaginationAJAXTest.php b/core/modules/views/tests/src/FunctionalJavascript/PaginationAJAXTest.php
index b4372c6d61..de4efd24ab 100644
--- a/core/modules/views/tests/src/FunctionalJavascript/PaginationAJAXTest.php
+++ b/core/modules/views/tests/src/FunctionalJavascript/PaginationAJAXTest.php
@@ -2,7 +2,7 @@
 
 namespace Drupal\Tests\views\FunctionalJavascript;
 
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 use Drupal\simpletest\ContentTypeCreationTrait;
 use Drupal\simpletest\NodeCreationTrait;
 use Drupal\views\Tests\ViewTestData;
@@ -12,7 +12,7 @@
  *
  * @group views
  */
-class PaginationAJAXTest extends JavascriptTestBase {
+class PaginationAJAXTest extends WebDriverTestBase {
 
   use ContentTypeCreationTrait;
   use NodeCreationTrait;
diff --git a/core/modules/views/tests/src/FunctionalJavascript/Plugin/views/Handler/ContextualFilterTest.php b/core/modules/views/tests/src/FunctionalJavascript/Plugin/views/Handler/ContextualFilterTest.php
index dd1d1ae264..f0ac608548 100644
--- a/core/modules/views/tests/src/FunctionalJavascript/Plugin/views/Handler/ContextualFilterTest.php
+++ b/core/modules/views/tests/src/FunctionalJavascript/Plugin/views/Handler/ContextualFilterTest.php
@@ -2,7 +2,7 @@
 
 namespace Drupal\Tests\views\FunctionalJavascript\Plugin\views\Handler;
 
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 use Drupal\views\Tests\ViewTestData;
 
 /**
@@ -10,7 +10,7 @@
  *
  * @group views
  */
-class ContextualFilterTest extends JavascriptTestBase {
+class ContextualFilterTest extends WebDriverTestBase {
 
   /**
    * {@inheritdoc}
diff --git a/core/modules/views/tests/src/FunctionalJavascript/Plugin/views/Handler/FieldTest.php b/core/modules/views/tests/src/FunctionalJavascript/Plugin/views/Handler/FieldTest.php
index 76f0ff1e21..079fe99ee4 100644
--- a/core/modules/views/tests/src/FunctionalJavascript/Plugin/views/Handler/FieldTest.php
+++ b/core/modules/views/tests/src/FunctionalJavascript/Plugin/views/Handler/FieldTest.php
@@ -4,7 +4,7 @@
 
 use Drupal\Tests\SchemaCheckTestTrait;
 use Drupal\field\Entity\FieldConfig;
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 use Drupal\node\Entity\NodeType;
 use Drupal\views\Tests\ViewTestData;
 
@@ -13,7 +13,7 @@
  *
  * @group views
  */
-class FieldTest extends JavascriptTestBase {
+class FieldTest extends WebDriverTestBase {
   use SchemaCheckTestTrait;
 
   /**
diff --git a/core/modules/views/tests/src/FunctionalJavascript/Plugin/views/Handler/GroupedExposedFilterTest.php b/core/modules/views/tests/src/FunctionalJavascript/Plugin/views/Handler/GroupedExposedFilterTest.php
index 9a9b2da4a8..1bc8a486d3 100644
--- a/core/modules/views/tests/src/FunctionalJavascript/Plugin/views/Handler/GroupedExposedFilterTest.php
+++ b/core/modules/views/tests/src/FunctionalJavascript/Plugin/views/Handler/GroupedExposedFilterTest.php
@@ -3,7 +3,7 @@
 namespace Drupal\Tests\views\FunctionalJavascript\Plugin\views\Handler;
 
 use Drupal\field\Entity\FieldConfig;
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 use Drupal\node\Entity\NodeType;
 use Drupal\views\Tests\ViewTestData;
 
@@ -12,7 +12,7 @@
  *
  * @group views
  */
-class GroupedExposedFilterTest extends JavascriptTestBase {
+class GroupedExposedFilterTest extends WebDriverTestBase {
 
   /**
    * {@inheritdoc}
diff --git a/core/modules/views_ui/tests/src/FunctionalJavascript/DisplayTest.php b/core/modules/views_ui/tests/src/FunctionalJavascript/DisplayTest.php
index c8d37f21c3..7dcaccdd24 100644
--- a/core/modules/views_ui/tests/src/FunctionalJavascript/DisplayTest.php
+++ b/core/modules/views_ui/tests/src/FunctionalJavascript/DisplayTest.php
@@ -2,7 +2,7 @@
 
 namespace Drupal\Tests\views_ui\FunctionalJavascript;
 
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 use Drupal\simpletest\NodeCreationTrait;
 use Drupal\views\Entity\View;
 use Drupal\views\Tests\ViewTestData;
@@ -12,7 +12,7 @@
  *
  * @group views_ui
  */
-class DisplayTest extends JavascriptTestBase {
+class DisplayTest extends WebDriverTestBase {
 
   use NodeCreationTrait;
 
diff --git a/core/modules/views_ui/tests/src/FunctionalJavascript/FilterCriteriaTest.php b/core/modules/views_ui/tests/src/FunctionalJavascript/FilterCriteriaTest.php
index e48487a6ed..9e303dfb92 100644
--- a/core/modules/views_ui/tests/src/FunctionalJavascript/FilterCriteriaTest.php
+++ b/core/modules/views_ui/tests/src/FunctionalJavascript/FilterCriteriaTest.php
@@ -2,14 +2,14 @@
 
 namespace Drupal\Tests\views_ui\FunctionalJavascript;
 
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 
 /**
  * Tests the View UI filter criteria group dialog.
  *
  * @group views_ui
  */
-class FilterCriteriaTest extends JavascriptTestBase {
+class FilterCriteriaTest extends WebDriverTestBase {
 
   /**
    * {@inheritdoc}
diff --git a/core/modules/views_ui/tests/src/FunctionalJavascript/FilterOptionsTest.php b/core/modules/views_ui/tests/src/FunctionalJavascript/FilterOptionsTest.php
index 32b1a400cb..6f2f625968 100644
--- a/core/modules/views_ui/tests/src/FunctionalJavascript/FilterOptionsTest.php
+++ b/core/modules/views_ui/tests/src/FunctionalJavascript/FilterOptionsTest.php
@@ -2,14 +2,14 @@
 
 namespace Drupal\Tests\views_ui\FunctionalJavascript;
 
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 
 /**
  * Tests the JavaScript filtering of options in add handler form.
  *
  * @group views_ui
  */
-class FilterOptionsTest extends JavascriptTestBase {
+class FilterOptionsTest extends WebDriverTestBase {
 
   /**
    * {@inheritdoc}
diff --git a/core/modules/views_ui/tests/src/FunctionalJavascript/LibraryCachingTest.php b/core/modules/views_ui/tests/src/FunctionalJavascript/LibraryCachingTest.php
index 4cf51d57fa..b1b158ba6c 100644
--- a/core/modules/views_ui/tests/src/FunctionalJavascript/LibraryCachingTest.php
+++ b/core/modules/views_ui/tests/src/FunctionalJavascript/LibraryCachingTest.php
@@ -2,14 +2,14 @@
 
 namespace Drupal\Tests\views_ui\FunctionalJavascript;
 
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 
 /**
  * Tests the JavaScript library caching on consecutive requests.
  *
  * @group views_ui
  */
-class LibraryCachingTest extends JavascriptTestBase {
+class LibraryCachingTest extends WebDriverTestBase {
 
   /**
    * {@inheritdoc}
diff --git a/core/modules/views_ui/tests/src/FunctionalJavascript/ViewsListingTest.php b/core/modules/views_ui/tests/src/FunctionalJavascript/ViewsListingTest.php
index 86d3b6e5e7..fc696c03a8 100644
--- a/core/modules/views_ui/tests/src/FunctionalJavascript/ViewsListingTest.php
+++ b/core/modules/views_ui/tests/src/FunctionalJavascript/ViewsListingTest.php
@@ -2,7 +2,7 @@
 
 namespace Drupal\Tests\views_ui\FunctionalJavascript;
 
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 
 /**
  * Tests the JavaScript filtering on the Views listing page.
@@ -10,7 +10,7 @@
  * @see core/modules/views_ui/js/views_ui.listing.js
  * @group views_ui
  */
-class ViewsListingTest extends JavascriptTestBase {
+class ViewsListingTest extends WebDriverTestBase {
 
   /**
    * {@inheritdoc}
diff --git a/core/modules/views_ui/tests/src/FunctionalJavascript/ViewsWizardTest.php b/core/modules/views_ui/tests/src/FunctionalJavascript/ViewsWizardTest.php
index 3fb1167e1f..16369f12fe 100644
--- a/core/modules/views_ui/tests/src/FunctionalJavascript/ViewsWizardTest.php
+++ b/core/modules/views_ui/tests/src/FunctionalJavascript/ViewsWizardTest.php
@@ -2,7 +2,7 @@
 
 namespace Drupal\Tests\views_ui\FunctionalJavascript;
 
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 
 /**
  * Tests views creation wizard.
@@ -10,7 +10,7 @@
  * @see core/modules/views_ui/js/views-admin.js
  * @group views_ui
  */
-class ViewsWizardTest extends JavascriptTestBase {
+class ViewsWizardTest extends WebDriverTestBase {
 
   /**
    * {@inheritdoc}
diff --git a/core/profiles/standard/tests/src/FunctionalJavascript/StandardJavascriptTest.php b/core/profiles/standard/tests/src/FunctionalJavascript/StandardJavascriptTest.php
index c9c92f404f..13973e0c5d 100644
--- a/core/profiles/standard/tests/src/FunctionalJavascript/StandardJavascriptTest.php
+++ b/core/profiles/standard/tests/src/FunctionalJavascript/StandardJavascriptTest.php
@@ -2,7 +2,7 @@
 
 namespace Drupal\Tests\standard\FunctionalJavascript;
 
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 use Drupal\node\Entity\Node;
 
 /**
@@ -10,7 +10,7 @@
  *
  * @group standard
  */
-class StandardJavascriptTest extends JavascriptTestBase {
+class StandardJavascriptTest extends WebDriverTestBase {
 
   /**
    * {@inheritdoc}
diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxCallbacksTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxCallbacksTest.php
index e13ecfd56c..ffdbd98eb9 100644
--- a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxCallbacksTest.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxCallbacksTest.php
@@ -2,14 +2,14 @@
 
 namespace Drupal\FunctionalJavascriptTests\Ajax;
 
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 
 /**
  * Tests Ajax callbacks on FAPI elements.
  *
  * @group Ajax
  */
-class AjaxCallbacksTest extends JavascriptTestBase {
+class AjaxCallbacksTest extends WebDriverTestBase {
 
   /**
    * {@inheritdoc}
@@ -23,11 +23,9 @@ public function testDateAjaxCallback() {
 
     // Test Ajax callback when date changes.
     $this->drupalGet('ajax_forms_test_ajax_element_form');
-    $this->assertSession()->responseContains('No date yet selected');
-    $this->getSession()->getPage()->fillField('edit-date', '2016-01-01');
-    $this->assertSession()->assertWaitOnAjaxRequest();
-    $this->assertSession()->responseNotContains('No date yet selected');
-    $this->assertSession()->responseContains('2016-01-01');
+    $this->assertNotEmpty($this->getSession()->getPage()->find('xpath', '//div[@id="ajax_date_value"][text()="No date yet selected"]'));
+    $this->getSession()->executeScript('jQuery("[data-drupal-selector=edit-date]").val("2016-01-01").trigger("change");');
+    $this->assertNotEmpty($this->assertSession()->waitForElement('xpath', '//div[@id="ajax_date_value"]/div[text()="2016-01-01"]'));
   }
 
   /**
@@ -37,14 +35,10 @@ public function testDateTimeAjaxCallback() {
 
     // Test Ajax callback when datetime changes.
     $this->drupalGet('ajax_forms_test_ajax_element_form');
-    $this->assertSession()->responseContains('No datetime selected.');
-    $this->getSession()->getPage()->fillField('edit-datetime-date', '2016-01-01');
-    $this->assertSession()->assertWaitOnAjaxRequest();
-    $this->assertSession()->responseNotContains('No datetime selected.');
-    $this->assertSession()->responseContains('2016-01-01');
-    $this->getSession()->getPage()->fillField('edit-datetime-time', '12:00:00');
-    $this->assertSession()->assertWaitOnAjaxRequest();
-    $this->assertSession()->responseContains('2016-01-01 12:00:00');
+    $this->assertNotEmpty($this->getSession()->getPage()->find('xpath', '//div[@id="ajax_datetime_value"][text()="No datetime selected."]'));
+    $this->getSession()->executeScript('jQuery("[data-drupal-selector=edit-datetime-date]").val("2016-01-01");');
+    $this->getSession()->executeScript('jQuery("[data-drupal-selector=edit-datetime-time]").val("12:00:00").trigger("change");');
+    $this->assertNotEmpty($this->assertSession()->waitForElement('xpath', '//div[@id="ajax_datetime_value"]/div[text()="2016-01-01 12:00:00"]'));
   }
 
 }
diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxFormImageButtonTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxFormImageButtonTest.php
index 4811a350ac..bfd890a04f 100644
--- a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxFormImageButtonTest.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxFormImageButtonTest.php
@@ -2,14 +2,14 @@
 
 namespace Drupal\FunctionalJavascriptTests\Ajax;
 
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 
 /**
  * Tests the Ajax image buttons work with key press events.
  *
  * @group Ajax
  */
-class AjaxFormImageButtonTest extends JavascriptTestBase {
+class AjaxFormImageButtonTest extends WebDriverTestBase {
 
   /**
    * {@inheritdoc}
diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxFormPageCacheTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxFormPageCacheTest.php
index 3d174b04df..06b64af67b 100644
--- a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxFormPageCacheTest.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxFormPageCacheTest.php
@@ -2,14 +2,14 @@
 
 namespace Drupal\FunctionalJavascriptTests\Ajax;
 
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 
 /**
  * Performs tests on AJAX forms in cached pages.
  *
  * @group Ajax
  */
-class AjaxFormPageCacheTest extends JavascriptTestBase {
+class AjaxFormPageCacheTest extends WebDriverTestBase {
 
   /**
    * {@inheritdoc}
@@ -41,7 +41,6 @@ protected function getFormBuildId() {
    */
   public function testSimpleAJAXFormValue() {
     $this->drupalGet('ajax_forms_test_get_form');
-    $this->assertEquals($this->drupalGetHeader('X-Drupal-Cache'), 'MISS', 'Page was not cached.');
     $build_id_initial = $this->getFormBuildId();
 
     // Changing the value of a select input element, triggers a AJAX
@@ -77,7 +76,6 @@ public function testSimpleAJAXFormValue() {
     // Emulate a push of the reload button and then repeat the test sequence
     // this time with a page loaded from the cache.
     $session->reload();
-    $this->assertEquals($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', 'Page was cached.');
     $build_id_from_cache_initial = $this->getFormBuildId();
     $this->assertEquals($build_id_initial, $build_id_from_cache_initial, 'Build id is the same as on the first request');
 
@@ -115,7 +113,9 @@ public function testAjaxElementValidation() {
     $this->drupalGet('ajax_validation_test');
     // Changing the value of the textfield will trigger an AJAX
     // request/response.
-    $this->getSession()->getPage()->fillField('drivertext', 'some dumb text');
+    $field = $this->getSession()->getPage()->findField('drivertext');
+    $field->setValue('some dumb text');
+    $field->blur();
 
     // When the AJAX command updates the DOM a <ul> unsorted list
     // "message__list" structure will appear on the page echoing back the
diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php
index e05940537c..fa2a3e45c0 100644
--- a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php
@@ -2,14 +2,14 @@
 
 namespace Drupal\FunctionalJavascriptTests\Ajax;
 
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 
 /**
  * Tests AJAX responses.
  *
  * @group Ajax
  */
-class AjaxTest extends JavascriptTestBase {
+class AjaxTest extends WebDriverTestBase {
 
   /**
    * {@inheritdoc}
diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/BackwardCompatibilityTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/BackwardCompatibilityTest.php
index 077c3aa1ae..9a45583b7c 100644
--- a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/BackwardCompatibilityTest.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/BackwardCompatibilityTest.php
@@ -2,14 +2,14 @@
 
 namespace Drupal\FunctionalJavascriptTests\Ajax;
 
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 
 /**
  * Tests the compatibility of the ajax.es6.js file.
  *
  * @group Ajax
  */
-class BackwardCompatibilityTest extends JavascriptTestBase {
+class BackwardCompatibilityTest extends WebDriverTestBase {
 
   /**
    * {@inheritdoc}
diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/ThrobberTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/ThrobberTest.php
index e2ecaea7a4..56715e6dd1 100644
--- a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/ThrobberTest.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/ThrobberTest.php
@@ -2,20 +2,14 @@
 
 namespace Drupal\FunctionalJavascriptTests\Ajax;
 
-use Drupal\FunctionalJavascriptTests\DrupalSelenium2Driver;
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 
 /**
  * Tests the throbber.
  *
  * @group Ajax
  */
-class ThrobberTest extends JavascriptTestBase {
-
-  /**
-   * {@inheritdoc}
-   */
-  protected $minkDefaultDriverClass = DrupalSelenium2Driver::class;
+class ThrobberTest extends WebDriverTestBase {
 
   /**
    * {@inheritdoc}
diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Core/Form/FormGroupingElementsTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Core/Form/FormGroupingElementsTest.php
index 92b3a739f6..1c76c26ea3 100644
--- a/core/tests/Drupal/FunctionalJavascriptTests/Core/Form/FormGroupingElementsTest.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/Core/Form/FormGroupingElementsTest.php
@@ -2,14 +2,14 @@
 
 namespace Drupal\FunctionalJavascriptTests\Core\Form;
 
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 
 /**
  * Tests for form grouping elements.
  *
  * @group form
  */
-class FormGroupingElementsTest extends JavascriptTestBase {
+class FormGroupingElementsTest extends WebDriverTestBase {
 
   /**
    * Required modules.
diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Core/Installer/Form/SelectProfileFormTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Core/Installer/Form/SelectProfileFormTest.php
index efad210c6a..a6c59d1152 100644
--- a/core/tests/Drupal/FunctionalJavascriptTests/Core/Installer/Form/SelectProfileFormTest.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/Core/Installer/Form/SelectProfileFormTest.php
@@ -6,7 +6,7 @@
 use Drupal\Core\Language\Language;
 use Drupal\Core\Session\UserSession;
 use Drupal\Core\Test\HttpClientMiddleware\TestHttpClientMiddleware;
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 use GuzzleHttp\HandlerStack;
 use Symfony\Component\DependencyInjection\Reference;
 use Symfony\Component\HttpFoundation\Request;
@@ -17,7 +17,7 @@
  *
  * @group Installer
  */
-class SelectProfileFormTest extends JavascriptTestBase {
+class SelectProfileFormTest extends WebDriverTestBase {
 
   /**
    * {@inheritdoc}
diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Core/MachineNameTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Core/MachineNameTest.php
index bf2643da6a..71bdc982e6 100644
--- a/core/tests/Drupal/FunctionalJavascriptTests/Core/MachineNameTest.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/Core/MachineNameTest.php
@@ -2,14 +2,14 @@
 
 namespace Drupal\FunctionalJavascriptTests\Core;
 
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 
 /**
  * Tests for the machine name field.
  *
  * @group field
  */
-class MachineNameTest extends JavascriptTestBase {
+class MachineNameTest extends WebDriverTestBase {
 
   /**
    * Required modules.
diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Core/Session/SessionTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Core/Session/SessionTest.php
index fa2d541c8a..f4a1800382 100644
--- a/core/tests/Drupal/FunctionalJavascriptTests/Core/Session/SessionTest.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/Core/Session/SessionTest.php
@@ -2,7 +2,7 @@
 
 namespace Drupal\FunctionalJavascriptTests\Core\Session;
 
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 use Drupal\menu_link_content\Entity\MenuLinkContent;
 
 /**
@@ -10,7 +10,7 @@
  *
  * @group session
  */
-class SessionTest extends JavascriptTestBase {
+class SessionTest extends WebDriverTestBase {
 
   /**
    * {@inheritdoc}
diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Dialog/DialogPositionTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Dialog/DialogPositionTest.php
index 19cf5a4b35..4bfe3e0b3a 100644
--- a/core/tests/Drupal/FunctionalJavascriptTests/Dialog/DialogPositionTest.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/Dialog/DialogPositionTest.php
@@ -2,14 +2,14 @@
 
 namespace Drupal\FunctionalJavascriptTests\Dialog;
 
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 
 /**
  * Tests the JavaScript functionality of the dialog position.
  *
  * @group dialog
  */
-class DialogPositionTest extends JavascriptTestBase {
+class DialogPositionTest extends WebDriverTestBase {
 
   /**
    * {@inheritdoc}
diff --git a/core/tests/Drupal/FunctionalJavascriptTests/DrupalSelenium2Driver.php b/core/tests/Drupal/FunctionalJavascriptTests/DrupalSelenium2Driver.php
index 5f243af670..f67e738baf 100644
--- a/core/tests/Drupal/FunctionalJavascriptTests/DrupalSelenium2Driver.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/DrupalSelenium2Driver.php
@@ -3,12 +3,21 @@
 namespace Drupal\FunctionalJavascriptTests;
 
 use Behat\Mink\Driver\Selenium2Driver;
+use WebDriver\ServiceFactory;
 
 /**
  * Provides a driver for Selenium testing.
  */
 class DrupalSelenium2Driver extends Selenium2Driver {
 
+  /**
+   * {@inheritdoc}
+   */
+  public function __construct($browserName = 'firefox', $desiredCapabilities = NULL, $wdHost = 'http://localhost:4444/wd/hub') {
+    parent::__construct($browserName, $desiredCapabilities, $wdHost);
+    ServiceFactory::getInstance()->setServiceClass('service.curl', WebDriverCurlService::class);
+  }
+
   /**
    * {@inheritdoc}
    */
diff --git a/core/tests/Drupal/FunctionalJavascriptTests/EntityReference/EntityReferenceAutocompleteWidgetTest.php b/core/tests/Drupal/FunctionalJavascriptTests/EntityReference/EntityReferenceAutocompleteWidgetTest.php
index 511dee6e32..3d0b402a48 100644
--- a/core/tests/Drupal/FunctionalJavascriptTests/EntityReference/EntityReferenceAutocompleteWidgetTest.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/EntityReference/EntityReferenceAutocompleteWidgetTest.php
@@ -3,7 +3,7 @@
 namespace Drupal\FunctionalJavascriptTests\EntityReference;
 
 use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait;
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 use Drupal\simpletest\ContentTypeCreationTrait;
 use Drupal\simpletest\NodeCreationTrait;
 
@@ -12,7 +12,7 @@
  *
  * @group entity_reference
  */
-class EntityReferenceAutocompleteWidgetTest extends JavascriptTestBase {
+class EntityReferenceAutocompleteWidgetTest extends WebDriverTestBase {
 
   use ContentTypeCreationTrait;
   use EntityReferenceTestTrait;
@@ -63,7 +63,7 @@ public function testEntityReferenceAutocompleteWidget() {
     $page = $this->getSession()->getPage();
     $assert_session = $this->assertSession();
 
-    $autocomplete_field = $page->findField($field_name . '[0][target_id]');
+    $autocomplete_field = $assert_session->waitForElement('css', '[name="' . $field_name . '[0][target_id]"].ui-autocomplete-input');
     $autocomplete_field->setValue('Test');
     $this->getSession()->getDriver()->keyDown($autocomplete_field->getXpath(), ' ');
     $assert_session->waitOnAutocomplete();
@@ -87,7 +87,7 @@ public function testEntityReferenceAutocompleteWidget() {
     $this->drupalGet('node/add/page');
     $page = $this->getSession()->getPage();
 
-    $autocomplete_field = $page->findField($field_name . '[0][target_id]');
+    $autocomplete_field = $assert_session->waitForElement('css', '[name="' . $field_name . '[0][target_id]"].ui-autocomplete-input');
     $autocomplete_field->setValue('Test');
     $this->getSession()->getDriver()->keyDown($autocomplete_field->getXpath(), ' ');
     $assert_session->waitOnAutocomplete();
diff --git a/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php b/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php
index 44b83c1633..b545f71182 100644
--- a/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php
@@ -2,202 +2,33 @@
 
 namespace Drupal\FunctionalJavascriptTests;
 
-use Drupal\Tests\BrowserTestBase;
-use Zumba\GastonJS\Exception\DeadClient;
+@trigger_error('The ' . __NAMESPACE__ . '\JavascriptTestBase is deprecated in Drupal 8.5.x and will be removed before Drupal 9.0.0. Instead, use ' . __NAMESPACE__ . '\WebDriverTestBase. See https://www.drupal.org/node/2945059', E_USER_DEPRECATED);
+
 use Zumba\Mink\Driver\PhantomJSDriver;
 
 /**
- * Runs a browser test using a driver that supports Javascript.
+ * Runs a browser test using PhantomJS.
  *
  * Base class for testing browser interaction implemented in JavaScript.
+ *
+ * @deprecated in Drupal 8.6.x, will be removed before Drupal 9.0.0.
+ * Use \Drupal\FunctionalJavascriptTests\WebDriverTestBase instead
+ *
+ * @see https://www.drupal.org/node/2945059
  */
-abstract class JavascriptTestBase extends BrowserTestBase {
+abstract class JavascriptTestBase extends WebDriverTestBase {
 
   /**
    * {@inheritdoc}
-   *
-   * To use a webdriver based approach, please use DrupalSelenium2Driver::class.
-   * We will switch the default later.
    */
   protected $minkDefaultDriverClass = PhantomJSDriver::class;
 
-  /**
-   * {@inheritdoc}
-   */
-  protected function initMink() {
-    if ($this->minkDefaultDriverClass === DrupalSelenium2Driver::class) {
-      $this->minkDefaultDriverArgs = ['chrome', NULL, 'http://localhost:4444/'];
-    }
-    elseif ($this->minkDefaultDriverClass === PhantomJSDriver::class) {
-      // Set up the template cache used by the PhantomJS mink driver.
-      $path = $this->tempFilesDirectory . DIRECTORY_SEPARATOR . 'browsertestbase-templatecache';
-      $this->minkDefaultDriverArgs = [
-        'http://127.0.0.1:8510',
-        $path,
-      ];
-      if (!file_exists($path)) {
-        mkdir($path);
-      }
-    }
-
-    try {
-      return parent::initMink();
-    }
-    catch (DeadClient $e) {
-      $this->markTestSkipped('PhantomJS is either not installed or not running. Start it via phantomjs --ssl-protocol=any --ignore-ssl-errors=true vendor/jcalderonzumba/gastonjs/src/Client/main.js 8510 1024 768&');
-    }
-    catch (\Exception $e) {
-      $this->markTestSkipped('An unexpected error occurred while starting Mink: ' . $e->getMessage());
-    }
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  protected function tearDown() {
-    if ($this->mink) {
-      // Wait for all requests to finish. It is possible that an AJAX request is
-      // still on-going.
-      $result = $this->getSession()->wait(5000, '(typeof(jQuery)=="undefined" || (0 === jQuery.active && 0 === jQuery(\':animated\').length))');
-      if (!$result) {
-        // If the wait is unsuccessful, there may still be an AJAX request in
-        // progress. If we tear down now, then this AJAX request may fail with
-        // missing database tables, because tear down will have removed them.
-        // Rather than allow it to fail, throw an explicit exception now
-        // explaining what the problem is.
-        throw new \RuntimeException('Unfinished AJAX requests while tearing down a test');
-      }
-    }
-    parent::tearDown();
-  }
-
-  /**
-    * {@inheritdoc}
-    */
-  protected function getMinkDriverArgs() {
-    if ($this->minkDefaultDriverClass === DrupalSelenium2Driver::class) {
-      return getenv('MINK_DRIVER_ARGS_WEBDRIVER') ?: getenv('MINK_DRIVER_ARGS_PHANTOMJS') ?: parent::getMinkDriverArgs();
-    }
-    elseif ($this->minkDefaultDriverClass === PhantomJSDriver::class) {
-      return getenv('MINK_DRIVER_ARGS_PHANTOMJS') ?: parent::getMinkDriverArgs();
-    }
-    return parent::getMinkDriverArgs();
-  }
-
-  /**
-   * Asserts that the element with the given CSS selector is visible.
-   *
-   * @param string $css_selector
-   *   The CSS selector identifying the element to check.
-   * @param string $message
-   *   Optional message to show alongside the assertion.
-   *
-   * @deprecated in Drupal 8.1.0, will be removed before Drupal 9.0.0. Use
-   *   \Behat\Mink\Element\NodeElement::isVisible() instead.
-   */
-  protected function assertElementVisible($css_selector, $message = '') {
-    $this->assertTrue($this->getSession()->getDriver()->isVisible($this->cssSelectToXpath($css_selector)), $message);
-    @trigger_error('The ' . __METHOD__ . ' method is deprecated since version 8.1.0 and will be removed in 9.0.0. Use \Behat\Mink\Element\NodeElement::isVisible() instead.', E_USER_DEPRECATED);
-  }
-
-  /**
-   * Asserts that the element with the given CSS selector is not visible.
-   *
-   * @param string $css_selector
-   *   The CSS selector identifying the element to check.
-   * @param string $message
-   *   Optional message to show alongside the assertion.
-   *
-   * @deprecated in Drupal 8.1.0, will be removed before Drupal 9.0.0. Use
-   *   \Behat\Mink\Element\NodeElement::isVisible() instead.
-   */
-  protected function assertElementNotVisible($css_selector, $message = '') {
-    $this->assertFalse($this->getSession()->getDriver()->isVisible($this->cssSelectToXpath($css_selector)), $message);
-    @trigger_error('The ' . __METHOD__ . ' method is deprecated since version 8.1.0 and will be removed in 9.0.0. Use \Behat\Mink\Element\NodeElement::isVisible() instead.', E_USER_DEPRECATED);
-  }
-
-  /**
-   * Waits for the given time or until the given JS condition becomes TRUE.
-   *
-   * @param string $condition
-   *   JS condition to wait until it becomes TRUE.
-   * @param int $timeout
-   *   (Optional) Timeout in milliseconds, defaults to 10000.
-   * @param string $message
-   *   (optional) A message to display with the assertion. If left blank, a
-   *   default message will be displayed.
-   *
-   * @throws \PHPUnit_Framework_AssertionFailedError
-   *
-   * @see \Behat\Mink\Driver\DriverInterface::evaluateScript()
-   */
-  protected function assertJsCondition($condition, $timeout = 10000, $message = '') {
-    $message = $message ?: "Javascript condition met:\n" . $condition;
-    $result = $this->getSession()->getDriver()->wait($timeout, $condition);
-    $this->assertTrue($result, $message);
-  }
-
-  /**
-   * Creates a screenshot.
-   *
-   * @param string $filename
-   *   The file name of the resulting screenshot. If using the default phantomjs
-   *   driver then this should be a JPG filename.
-   * @param bool $set_background_color
-   *   (optional) By default this method will set the background color to white.
-   *   Set to FALSE to override this behaviour.
-   *
-   * @throws \Behat\Mink\Exception\UnsupportedDriverActionException
-   *   When operation not supported by the driver.
-   * @throws \Behat\Mink\Exception\DriverException
-   *   When the operation cannot be done.
-   */
-  protected function createScreenshot($filename, $set_background_color = TRUE) {
-    $session = $this->getSession();
-    if ($set_background_color) {
-      $session->executeScript("document.body.style.backgroundColor = 'white';");
-    }
-    $image = $session->getScreenshot();
-    file_put_contents($filename, $image);
-  }
-
   /**
    * {@inheritdoc}
    */
   public function assertSession($name = NULL) {
-    return new WebDriverWebAssert($this->getSession($name), $this->baseUrl);
-  }
-
-  /**
-   * Gets the current Drupal javascript settings and parses into an array.
-   *
-   * Unlike BrowserTestBase::getDrupalSettings(), this implementation reads the
-   * current values of drupalSettings, capturing all changes made via javascript
-   * after the page was loaded.
-   *
-   * @return array
-   *   The Drupal javascript settings array.
-   *
-   * @see \Drupal\Tests\BrowserTestBase::getDrupalSettings()
-   */
-  protected function getDrupalSettings() {
-    $script = <<<EndOfScript
-(function () {
-  if (typeof drupalSettings !== 'undefined') {
-    return drupalSettings;
-  }
-})();
-EndOfScript;
-
-    return $this->getSession()->evaluateScript($script) ?: [];
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  protected function getHtmlOutputHeaders() {
-    // The webdriver API does not support fetching headers.
-    return '';
+    // Return a WebAssert that supports status code and header assertions.
+    return new JSWebAssert($this->getSession($name), $this->baseUrl);
   }
 
 }
diff --git a/core/tests/Drupal/FunctionalJavascriptTests/LegacyJavascriptTestBase.php b/core/tests/Drupal/FunctionalJavascriptTests/LegacyJavascriptTestBase.php
index b3baf6e2d3..70869d08b4 100644
--- a/core/tests/Drupal/FunctionalJavascriptTests/LegacyJavascriptTestBase.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/LegacyJavascriptTestBase.php
@@ -2,26 +2,14 @@
 
 namespace Drupal\FunctionalJavascriptTests;
 
-use Zumba\Mink\Driver\PhantomJSDriver;
-
 /**
  * Runs a browser test using PhantomJS.
  *
- * Base class for testing browser interaction implemented in JavaScript.
+ * @deprecated in Drupal 8.6.0, will be removed before Drupal 9.0.0.
+ * Use \Drupal\FunctionalJavascriptTests\WebDriverTestBase instead
+ *
+ * BC layer for testing browser interaction implemented in JavaScript.
  */
 abstract class LegacyJavascriptTestBase extends JavascriptTestBase {
 
-  /**
-   * {@inheritdoc}
-   */
-  protected $minkDefaultDriverClass = PhantomJSDriver::class;
-
-  /**
-   * {@inheritdoc}
-   */
-  public function assertSession($name = NULL) {
-    // Return a WebAssert that supports status code and header assertions.
-    return new JSWebAssert($this->getSession($name), $this->baseUrl);
-  }
-
 }
diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Tests/JSWebAssertTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Tests/JSWebAssertTest.php
index 36f6340f72..6dd591f5fe 100644
--- a/core/tests/Drupal/FunctionalJavascriptTests/Tests/JSWebAssertTest.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/Tests/JSWebAssertTest.php
@@ -3,14 +3,14 @@
 namespace Drupal\FunctionalJavascriptTests\Tests;
 
 use Behat\Mink\Element\NodeElement;
-use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
 
 /**
  * Tests for the JSWebAssert class.
  *
  * @group javascript
  */
-class JSWebAssertTest extends JavascriptTestBase {
+class JSWebAssertTest extends WebDriverTestBase {
 
   /**
    * Required modules.
diff --git a/core/tests/Drupal/FunctionalJavascriptTests/WebDriverCurlService.php b/core/tests/Drupal/FunctionalJavascriptTests/WebDriverCurlService.php
new file mode 100644
index 0000000000..13991afd5d
--- /dev/null
+++ b/core/tests/Drupal/FunctionalJavascriptTests/WebDriverCurlService.php
@@ -0,0 +1,110 @@
+<?php
+
+namespace Drupal\FunctionalJavascriptTests;
+
+use WebDriver\Service\CurlService;
+use WebDriver\Exception\CurlExec;
+use WebDriver\Exception as WebDriverException;
+
+/**
+ * Provides a curl service to interact with Selenium driver.
+ *
+ * Extends WebDriver\Service\CurlService to solve problem with race conditions,
+ * when multiple processes requests.
+ */
+class WebDriverCurlService extends CurlService {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function execute($requestMethod, $url, $parameters = NULL, $extraOptions = []) {
+    $extraOptions += [
+      CURLOPT_FAILONERROR => TRUE,
+    ];
+    $retries = 0;
+    while ($retries < 10) {
+      try {
+        $customHeaders = [
+          'Content-Type: application/json;charset=UTF-8',
+          'Accept: application/json;charset=UTF-8',
+        ];
+
+        $curl = curl_init($url);
+        curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
+
+        switch ($requestMethod) {
+          case 'GET':
+            break;
+
+          case 'POST':
+            if ($parameters && is_array($parameters)) {
+              curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($parameters));
+            }
+            else {
+              $customHeaders[] = 'Content-Length: 0';
+            }
+
+            // Suppress "Expect: 100-continue" header automatically added by
+            // cURL that causes a 1 second delay if the remote server does not
+            // support Expect.
+            $customHeaders[] = 'Expect:';
+
+            curl_setopt($curl, CURLOPT_POST, TRUE);
+            break;
+
+          case 'DELETE':
+            curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'DELETE');
+            break;
+
+          case 'PUT':
+            if ($parameters && is_array($parameters)) {
+              curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($parameters));
+            }
+            else {
+              $customHeaders[] = 'Content-Length: 0';
+            }
+
+            // Suppress "Expect: 100-continue" header automatically added by
+            // cURL that causes a 1 second delay if the remote server does not
+            // support Expect.
+            $customHeaders[] = 'Expect:';
+
+            curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT');
+            break;
+        }
+
+        foreach ($extraOptions as $option => $value) {
+          curl_setopt($curl, $option, $value);
+        }
+
+        curl_setopt($curl, CURLOPT_HTTPHEADER, $customHeaders);
+
+        $rawResult = trim(curl_exec($curl));
+
+        $info = curl_getinfo($curl);
+        $info['request_method'] = $requestMethod;
+
+        if (array_key_exists(CURLOPT_FAILONERROR, $extraOptions) && $extraOptions[CURLOPT_FAILONERROR] && CURLE_GOT_NOTHING !== ($errno = curl_errno($curl)) && $error = curl_error($curl)) {
+          curl_close($curl);
+
+          throw WebDriverException::factory(WebDriverException::CURL_EXEC, sprintf("Curl error thrown for http %s to %s%s\n\n%s", $requestMethod, $url, $parameters && is_array($parameters) ? ' with params: ' . json_encode($parameters) : '', $error));
+        }
+
+        curl_close($curl);
+
+        $result = json_decode($rawResult, TRUE);
+        if (isset($result['status']) && $result['status'] === WebDriverException::STALE_ELEMENT_REFERENCE) {
+          usleep(100000);
+          $retries++;
+          continue;
+        }
+        return [$rawResult, $info];
+      }
+      catch (CurlExec $exception) {
+        $retries++;
+      }
+    }
+    throw WebDriverException::factory(WebDriverException::CURL_EXEC, sprintf("Curl error thrown for http %s to %s%s\n\n%s", $requestMethod, $url, $parameters && is_array($parameters) ? ' with params: ' . json_encode($parameters) : '', $error));
+  }
+
+}
diff --git a/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php b/core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php
similarity index 96%
copy from core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php
copy to core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php
index 44b83c1633..1d32371cea 100644
--- a/core/tests/Drupal/FunctionalJavascriptTests/JavascriptTestBase.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php
@@ -11,15 +11,14 @@
  *
  * Base class for testing browser interaction implemented in JavaScript.
  */
-abstract class JavascriptTestBase extends BrowserTestBase {
+abstract class WebDriverTestBase extends BrowserTestBase {
 
   /**
    * {@inheritdoc}
    *
-   * To use a webdriver based approach, please use DrupalSelenium2Driver::class.
-   * We will switch the default later.
+   * To use a legacy phantomjs based approach, please use PhantomJSDriver::class.
    */
-  protected $minkDefaultDriverClass = PhantomJSDriver::class;
+  protected $minkDefaultDriverClass = DrupalSelenium2Driver::class;
 
   /**
    * {@inheritdoc}
