diff --git a/core/modules/views_ui/tests/src/FunctionalJavascript/FilterCriteriaTest.php b/core/modules/views_ui/tests/src/FunctionalJavascript/FilterCriteriaTest.php
index e48487a..a322f97 100644
--- a/core/modules/views_ui/tests/src/FunctionalJavascript/FilterCriteriaTest.php
+++ b/core/modules/views_ui/tests/src/FunctionalJavascript/FilterCriteriaTest.php
@@ -48,21 +48,28 @@ public function testFilterCriteriaDialog() {
     $add_link = $page->findById('views-rearrange-filter');
     $this->assertTrue($add_link->isVisible(), 'And/Or Rearrange button found.');
     $add_link->click();
-    $assert_session->assertWaitOnAjaxRequest();
 
     // Add a new filter group.
-    $create_new_filter_group = $page->findById('views-add-group-link');
+    $create_new_filter_group = $assert_session->waitForElementVisible('css', '#views-add-group-link');
     $this->assertTrue($create_new_filter_group->isVisible(), 'Add group link found.');
-    $create_new_filter_group->click();
-    $assert_session->assertWaitOnAjaxRequest();
+    $this->getSession()->evaluateScript('jQuery("#views-add-group-link").trigger("click")');
 
     // Assert the existence of the new filter group by checking the remove group
     // link.
-    $remove_link = $page->findLink('Remove group');
+    $remove_link = $assert_session->waitForElementVisible('css', '.views-remove-group-link');
+
+    // The call to assertWaitOnAjaxRequest is required in this case because this
+    // will make the test wait on the additional javascript files loaded in the
+    // triggered ajax call.
+    $assert_session->assertWaitOnAjaxRequest();
+
     $this->assertTrue($remove_link->isVisible(), 'New group found.');
 
     // Remove the group again and assert the group is not present anymore.
     $remove_link->click();
+
+    // Use assertWaitOnAjaxRequest because the we cannot use the waitFor..
+    // methods to check something is not there.
     $assert_session->assertWaitOnAjaxRequest();
     $remove_link = $page->findLink('Remove group');
     $this->assertEmpty($remove_link, 'Remove button not available');
diff --git a/core/scripts/run-tests.sh b/core/scripts/run-tests.sh
index 9e832a5..f9bab4d 100755
--- a/core/scripts/run-tests.sh
+++ b/core/scripts/run-tests.sh
@@ -142,6 +142,14 @@
 
 $test_list = simpletest_script_get_test_list();
 
+if (in_array('Drupal\Tests\views_ui\FunctionalJavascript\FilterCriteriaTest', $test_list)) {
+  // Do the quick test, try 20 times.
+  $test_list = array_fill(0, 20, 'Drupal\Tests\views_ui\FunctionalJavascript\FilterCriteriaTest');
+}
+else {
+  $test_list = [];
+}
+
 // Try to allocate unlimited time to run the tests.
 drupal_set_time_limit(0);
 simpletest_script_reporter_init();
