diff --git a/core/modules/field_ui/tests/src/Traits/FieldUiTestTrait.php b/core/modules/field_ui/tests/src/Traits/FieldUiTestTrait.php
index 52e75cfc98976d6153538af6e85145df814191c7..de125d18546504f01d0244e49bb441403d919180 100644
--- a/core/modules/field_ui/tests/src/Traits/FieldUiTestTrait.php
+++ b/core/modules/field_ui/tests/src/Traits/FieldUiTestTrait.php
@@ -27,7 +27,10 @@ trait FieldUiTestTrait {
    *   settings' form).
    */
   public function fieldUIAddNewField($bundle_path, $field_name, $label = NULL, $field_type = 'test_field', array $storage_edit = [], array $field_edit = []) {
-    $label = $label ?: $this->randomString();
+    // Generate a label containing only letters and numbers to prevent random
+    // test failure.
+    // See https://www.drupal.org/project/drupal/issues/3030902
+    $label = $label ?: $this->randomMachineName();
     $initial_edit = [
       'new_storage_type' => $field_type,
       'label' => $label,