diff --git a/core/modules/statistics/statistics.test b/core/modules/statistics/statistics.test
index a014767..1eedbec 100644
--- a/core/modules/statistics/statistics.test
+++ b/core/modules/statistics/statistics.test
@@ -129,8 +129,9 @@ class StatisticsLoggingTestCase extends DrupalWebTestCase {
     $this->assertTrue(is_array($log) && count($log) == 7, t('Page request was logged.'));
     $this->assertEqual(array_intersect_key($log[6], $expected), $expected);
 
-    // Create a path longer than 255 characters.
-    $long_path = $this->randomString(256);
+    // Create a path longer than 255 characters with alphanumeric characters at
+    // the beginning and the end.
+    $long_path = $this->randomName(3) . $this->randomString(255) . $this->randomName(3);
 
     // Test that the long path is properly truncated when logged.
     $this->drupalGet($long_path);
