diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php
index 2db22c06ba0507f3e6d28f60237f60ee06d838f0..25e6b3972b600ba8bcc20956c17ab6ca82392347 100644
--- a/modules/simpletest/drupal_web_test_case.php
+++ b/modules/simpletest/drupal_web_test_case.php
@@ -575,6 +575,9 @@ protected function setUp() {
     $db_prefix = Database::getConnection()->prefixTables('{simpletest' . mt_rand(1000, 1000000) . '}');
     $conf['file_public_path'] = $this->originalFileDirectory . '/' . $db_prefix;
 
+    // Set user agent to be consistent with web test case.
+    $_SERVER['HTTP_USER_AGENT'] = $db_prefix;
+
     // If locale is enabled then t() will try to access the database and
     // subsequently will fail as the database is not accessible.
     $module_list = module_list();