diff --git a/core/modules/ckeditor5/tests/src/Nightwatch/Tests/ckEditor5EditorHeightTest.js b/core/modules/ckeditor5/tests/src/Nightwatch/Tests/ckEditor5EditorHeightTest.js
index 2d1f001d2e953d2fcd13333eb1626a1216738b9b..b5bf5f41ecc20ce32427cba795f5bfd42dc9c065 100644
--- a/core/modules/ckeditor5/tests/src/Nightwatch/Tests/ckEditor5EditorHeightTest.js
+++ b/core/modules/ckeditor5/tests/src/Nightwatch/Tests/ckEditor5EditorHeightTest.js
@@ -1,7 +1,11 @@
 module.exports = {
   '@tags': ['core', 'ckeditor5'],
   before(browser) {
-    browser.drupalInstall({ installProfile: 'minimal' });
+    browser
+      .drupalInstall({ installProfile: 'minimal' })
+      .drupalInstallModule('ckeditor5', true)
+      .drupalInstallModule('field_ui');
+
     // Set fixed (desktop-ish) size to ensure a maximum viewport.
     browser.resizeWindow(1920, 1080);
   },
@@ -11,17 +15,6 @@ module.exports = {
   'Ensure CKEditor respects field widget row value': (browser) => {
     browser.drupalLoginAsAdmin(() => {
       browser
-        // Enable required modules.
-        .drupalRelativeURL('/admin/modules')
-        .click('[name="modules[ckeditor5][enable]"]')
-        .click('[name="modules[field_ui][enable]"]')
-        .submitForm('input[type="submit"]') // Submit module form.
-        .waitForElementVisible(
-          '.system-modules-confirm-form input[value="Continue"]',
-        )
-        .submitForm('input[value="Continue"]') // Confirm installation of dependencies.
-        .waitForElementVisible('.system-modules', 10000)
-
         // Create new input format.
         .drupalRelativeURL('/admin/config/content/formats/add')
         .waitForElementVisible('[data-drupal-selector="edit-name"]')
diff --git a/core/modules/toolbar/tests/src/Nightwatch/Tests/toolbarApiTest.js b/core/modules/toolbar/tests/src/Nightwatch/Tests/toolbarApiTest.js
index a013010a107c2b28cc460f435efbc341e85aeb59..8e10c135a0117d869c26356d684ce9243613524e 100644
--- a/core/modules/toolbar/tests/src/Nightwatch/Tests/toolbarApiTest.js
+++ b/core/modules/toolbar/tests/src/Nightwatch/Tests/toolbarApiTest.js
@@ -8,8 +8,7 @@ module.exports = {
   before(browser) {
     browser
       .drupalInstall()
-      .drupalInstallModule('breakpoint')
-      .drupalInstallModule('toolbar')
+      .drupalInstallModule('toolbar', true)
       .drupalCreateUser({
         name: 'user',
         password: '123',
diff --git a/core/modules/toolbar/tests/src/Nightwatch/Tests/toolbarTest.js b/core/modules/toolbar/tests/src/Nightwatch/Tests/toolbarTest.js
index 91773a7dac9aa95ea89072b0412b3271cd79df09..a87b3982780fadb0b5388ea9f38e91d8a534495f 100644
--- a/core/modules/toolbar/tests/src/Nightwatch/Tests/toolbarTest.js
+++ b/core/modules/toolbar/tests/src/Nightwatch/Tests/toolbarTest.js
@@ -15,8 +15,7 @@ module.exports = {
   before(browser) {
     browser
       .drupalInstall()
-      .drupalInstallModule('breakpoint')
-      .drupalInstallModule('toolbar')
+      .drupalInstallModule('toolbar', true)
       .drupalCreateUser({
         name: 'user',
         password: '123',
diff --git a/core/tests/Drupal/Nightwatch/Commands/drupalInstallModule.js b/core/tests/Drupal/Nightwatch/Commands/drupalInstallModule.js
index c791774974e5229803b67751c44d67e1b37d22cb..be8b1aa0b02931da6673ca6ed33c26ed78a22c39 100644
--- a/core/tests/Drupal/Nightwatch/Commands/drupalInstallModule.js
+++ b/core/tests/Drupal/Nightwatch/Commands/drupalInstallModule.js
@@ -3,12 +3,14 @@
  *
  * @param {string} module
  *   The module machine name to enable.
+ * @param {boolean} force
+ *   Force to install dependencies if applicable.
  * @param {function} callback
  *   A callback which will be called, when the module has been enabled.
  * @return {object}
  *   The drupalInstallModule command.
  */
-exports.command = function drupalInstallModule(module, callback) {
+exports.command = function drupalInstallModule(module, force, callback) {
   const self = this;
   this.drupalLoginAsAdmin(() => {
     this.drupalRelativeURL('/admin/modules')
@@ -22,13 +24,22 @@ exports.command = function drupalInstallModule(module, callback) {
         10000,
       )
       .click(`form.system-modules [name="modules[${module}][enable]"]`)
-      .submitForm('form.system-modules')
-      // Wait for the checkbox for the module to be disabled as a sign that the
-      // module has been enabled.
-      .waitForElementPresent(
-        `form.system-modules [name="modules[${module}][enable]"]:disabled`,
+      .submitForm('form.system-modules');
+    if (force) {
+      // Click `Continue` if applicable.
+      this.waitForElementPresent(
+        '#system-modules-confirm-form',
         10000,
+        false,
+        () => self.click('input[value=Continue]'),
       );
+    }
+    // Wait for the checkbox for the module to be disabled as a sign that the
+    // module has been enabled.
+    this.waitForElementPresent(
+      `form.system-modules [name="modules[${module}][enable]"]:disabled`,
+      10000,
+    );
   }).perform(() => {
     if (typeof callback === 'function') {
       callback.call(self);
diff --git a/core/tests/Drupal/Nightwatch/Tests/ajaxExecutionOrderTest.js b/core/tests/Drupal/Nightwatch/Tests/ajaxExecutionOrderTest.js
index da54f6015a6c5a52527433f761f58d498ca3fd4e..6284e99054231da823094cc7baf34861714774f2 100644
--- a/core/tests/Drupal/Nightwatch/Tests/ajaxExecutionOrderTest.js
+++ b/core/tests/Drupal/Nightwatch/Tests/ajaxExecutionOrderTest.js
@@ -1,20 +1,7 @@
 module.exports = {
   '@tags': ['core', 'ajax'],
   before(browser) {
-    browser.drupalInstall().drupalLoginAsAdmin(() => {
-      browser
-        .drupalRelativeURL('/admin/modules')
-        .setValue('input[type="search"]', 'Ajax test')
-        .waitForElementVisible('input[name="modules[ajax_test][enable]"]', 1000)
-        .click('input[name="modules[ajax_test][enable]"]')
-        .submitForm('input[type="submit"]') // Submit module form.
-        .waitForElementVisible(
-          '.system-modules-confirm-form input[value="Continue"]',
-          2000,
-        )
-        .submitForm('input[value="Continue"]') // Confirm installation of dependencies.
-        .waitForElementVisible('.system-modules', 10000);
-    });
+    browser.drupalInstall().drupalInstallModule('ajax_test', true);
   },
   after(browser) {
     browser.drupalUninstall();
diff --git a/core/tests/Drupal/Nightwatch/Tests/claroAutocompleteTest.js b/core/tests/Drupal/Nightwatch/Tests/claroAutocompleteTest.js
index 054f40ab7937ab993d8bf06d603a56e55b9aa9e6..446b52665d8675dfe2a00058be16e3b99dd86d7d 100644
--- a/core/tests/Drupal/Nightwatch/Tests/claroAutocompleteTest.js
+++ b/core/tests/Drupal/Nightwatch/Tests/claroAutocompleteTest.js
@@ -2,25 +2,15 @@ module.exports = {
   '@tags': ['core'],
 
   before(browser) {
-    browser.drupalInstall().drupalLoginAsAdmin(() => {
-      browser
-        .drupalRelativeURL('/admin/modules')
-        .setValue('input[type="search"]', 'FormAPI Test')
-        .waitForElementVisible('input[name="modules[form_test][enable]"]', 1000)
-        .click('input[name="modules[form_test][enable]"]')
-        .submitForm('input[type="submit"]') // Submit module form.
-        .waitForElementVisible(
-          '.system-modules-confirm-form input[value="Continue"]',
-          2000,
-        )
-        .submitForm('input[value="Continue"]') // Confirm installation of dependencies.
-        .waitForElementVisible('.system-modules', 10000);
-
-      browser
-        .drupalRelativeURL('/admin/appearance')
-        .click('[title="Install Claro as default theme"]')
-        .waitForElementVisible('.system-themes-list', 10000); // Confirm installation.
-    });
+    browser
+      .drupalInstall()
+      .drupalInstallModule('form_test', true)
+      .drupalLoginAsAdmin(() => {
+        browser
+          .drupalRelativeURL('/admin/appearance')
+          .click('[title="Install Claro as default theme"]')
+          .waitForElementVisible('.system-themes-list', 10000); // Confirm installation.
+      });
   },
   after(browser) {
     browser.drupalUninstall();
diff --git a/core/tests/Drupal/Nightwatch/Tests/jQueryUIPositionShimTest.js b/core/tests/Drupal/Nightwatch/Tests/jQueryUIPositionShimTest.js
index 7c82cc83c6b08cec3a10a5375bacb003038f10cb..0cbcf58687887010490a77f55f4fa223c92f4a88 100644
--- a/core/tests/Drupal/Nightwatch/Tests/jQueryUIPositionShimTest.js
+++ b/core/tests/Drupal/Nightwatch/Tests/jQueryUIPositionShimTest.js
@@ -758,17 +758,7 @@ testScenarios.element = testScenarios.selector;
 module.exports = {
   '@tags': ['core'],
   before(browser) {
-    browser.drupalInstall().drupalLoginAsAdmin(() => {
-      browser
-        .drupalRelativeURL('/admin/modules')
-        .setValue('input[type="search"]', 'position Shim Test')
-        .waitForElementVisible(
-          'input[name="modules[position_shim_test][enable]"]',
-          1000,
-        )
-        .click('input[name="modules[position_shim_test][enable]"]')
-        .click('input[type="submit"]');
-    });
+    browser.drupalInstall().drupalInstallModule('position_shim_test');
   },
   after(browser) {
     browser.drupalUninstall();
diff --git a/core/tests/Drupal/Nightwatch/Tests/jsDeprecationTest.js b/core/tests/Drupal/Nightwatch/Tests/jsDeprecationTest.js
index c3cb964306530481c1f8b390be0fb77a5624ffc5..b146cd290c47cff0b5f576ac3f3d4f9a14a56903 100644
--- a/core/tests/Drupal/Nightwatch/Tests/jsDeprecationTest.js
+++ b/core/tests/Drupal/Nightwatch/Tests/jsDeprecationTest.js
@@ -1,17 +1,7 @@
 module.exports = {
   '@tags': ['core'],
   before(browser) {
-    browser.drupalInstall().drupalLoginAsAdmin(() => {
-      browser
-        .drupalRelativeURL('/admin/modules')
-        .setValue('input[type="search"]', 'JS Deprecation test')
-        .waitForElementVisible(
-          'input[name="modules[js_deprecation_test][enable]"]',
-          1000,
-        )
-        .click('input[name="modules[js_deprecation_test][enable]"]')
-        .click('input[type="submit"]'); // Submit module form.
-    });
+    browser.drupalInstall().drupalInstallModule('js_deprecation_test');
   },
   after(browser) {
     browser.drupalUninstall();
diff --git a/core/tests/Drupal/Nightwatch/Tests/jsOnceTest.js b/core/tests/Drupal/Nightwatch/Tests/jsOnceTest.js
index 9e8a7476f3074de51cd67695c9dd83edddd7716d..3a34078520487cc7748ba7ccef19065825b37b59 100644
--- a/core/tests/Drupal/Nightwatch/Tests/jsOnceTest.js
+++ b/core/tests/Drupal/Nightwatch/Tests/jsOnceTest.js
@@ -1,17 +1,7 @@
 module.exports = {
   '@tags': ['core'],
   before(browser) {
-    browser.drupalInstall().drupalLoginAsAdmin(() => {
-      browser
-        .drupalRelativeURL('/admin/modules')
-        .setValue('input[type="search"]', 'JS Once Test')
-        .waitForElementVisible(
-          'input[name="modules[js_once_test][enable]"]',
-          1000,
-        )
-        .click('input[name="modules[js_once_test][enable]"]')
-        .click('input[type="submit"]'); // Submit module form.
-    });
+    browser.drupalInstall().drupalInstallModule('js_once_test');
   },
   after(browser) {
     browser.drupalUninstall();
diff --git a/core/tests/Drupal/Nightwatch/Tests/statesTest.js b/core/tests/Drupal/Nightwatch/Tests/statesTest.js
index 4d48d8d3aac8ae31d02643187fc64d3f50777d7c..8c037e53eccc95cb638430686c4f0a56bb5816ce 100644
--- a/core/tests/Drupal/Nightwatch/Tests/statesTest.js
+++ b/core/tests/Drupal/Nightwatch/Tests/statesTest.js
@@ -1,15 +1,7 @@
 module.exports = {
   '@tags': ['core'],
   before(browser) {
-    browser.drupalInstall().drupalLoginAsAdmin(() => {
-      browser
-        .drupalRelativeURL('/admin/modules')
-        .setValue('input[type="search"]', 'FormAPI')
-        .waitForElementVisible('input[name="modules[form_test][enable]"]', 1000)
-        .click('input[name="modules[form_test][enable]"]')
-        .click('input[type="submit"]') // Submit module form.
-        .click('input[type="submit"]'); // Confirm installation of dependencies.
-    });
+    browser.drupalInstall().drupalInstallModule('form_test', true);
   },
   after(browser) {
     browser.drupalUninstall();
diff --git a/core/tests/Drupal/Nightwatch/Tests/tabbableShimTest.js b/core/tests/Drupal/Nightwatch/Tests/tabbableShimTest.js
index f1a87ad09c569da34f3d4cd2cb60ea6806dcbf46..c76026d6ff899313db47175f53b6acdb55b41586 100644
--- a/core/tests/Drupal/Nightwatch/Tests/tabbableShimTest.js
+++ b/core/tests/Drupal/Nightwatch/Tests/tabbableShimTest.js
@@ -258,17 +258,7 @@ const dialogIntegrationTestScenarios = [
 module.exports = {
   '@tags': ['core'],
   before(browser) {
-    browser.drupalInstall().drupalLoginAsAdmin(() => {
-      browser
-        .drupalRelativeURL('/admin/modules')
-        .setValue('input[type="search"]', 'Tabbable Shim Test')
-        .waitForElementVisible(
-          'input[name="modules[tabbable_shim_test][enable]"]',
-          1000,
-        )
-        .click('input[name="modules[tabbable_shim_test][enable]"]')
-        .click('input[type="submit"]');
-    });
+    browser.drupalInstall().drupalInstallModule('tabbable_shim_test');
   },
   after(browser) {
     browser.drupalUninstall();
diff --git a/core/tests/Drupal/Nightwatch/Tests/tabbingManagerTest.js b/core/tests/Drupal/Nightwatch/Tests/tabbingManagerTest.js
index bee2da6f0c90b081b1fb967b338eaf0f2082e9e2..a90cd7bf9f8e5f7f73e17296e3f5bf81e7e1ac38 100644
--- a/core/tests/Drupal/Nightwatch/Tests/tabbingManagerTest.js
+++ b/core/tests/Drupal/Nightwatch/Tests/tabbingManagerTest.js
@@ -1,17 +1,7 @@
 module.exports = {
   '@tags': ['core'],
   before(browser) {
-    browser.drupalInstall().drupalLoginAsAdmin(() => {
-      browser
-        .drupalRelativeURL('/admin/modules')
-        .setValue('input[type="search"]', 'Tabbing Manager Test')
-        .waitForElementVisible(
-          'input[name="modules[tabbingmanager_test][enable]"]',
-          1000,
-        )
-        .click('input[name="modules[tabbingmanager_test][enable]"]')
-        .click('input[type="submit"]');
-    });
+    browser.drupalInstall().drupalInstallModule('tabbingmanager_test');
   },
   after(browser) {
     browser.drupalUninstall();