diff --git a/core/modules/filter/src/Tests/FilterFormTest.php b/core/modules/filter/src/Tests/FilterFormTest.php
index f8555fd..c40b883 100644
--- a/core/modules/filter/src/Tests/FilterFormTest.php
+++ b/core/modules/filter/src/Tests/FilterFormTest.php
@@ -91,40 +91,40 @@ protected function doFilterFormTestAsAdmin() {
     $this->assertEnabledTextarea('edit-all-formats-no-default-value');
     // If no default is given, the format with the lowest weight becomes the
     // default.
-    $this->assertOptions('edit-all-formats-no-default-format--2', $formats, 'filtered_html');
+    $this->assertOptions('edit-all-formats-no-default-format', $formats, 'filtered_html');
     $this->assertEnabledTextarea('edit-all-formats-default-value');
     // \Drupal\filter_test\Form\FilterTestFormatForm::buildForm() uses
     // 'filter_test' as the default value in this case.
-    $this->assertOptions('edit-all-formats-default-format--2', $formats, 'filter_test');
+    $this->assertOptions('edit-all-formats-default-format', $formats, 'filter_test');
     $this->assertEnabledTextarea('edit-all-formats-default-missing-value');
     // If a missing format is set as the default, administrators must select a
     // valid replacement format.
-    $this->assertRequiredSelectAndOptions('edit-all-formats-default-missing-format--2', $formats);
+    $this->assertRequiredSelectAndOptions('edit-all-formats-default-missing-format', $formats);
 
     // Test a text format element with a predefined list of formats.
     $formats = array('full_html', 'filter_test');
     $this->assertEnabledTextarea('edit-restricted-formats-no-default-value');
-    $this->assertOptions('edit-restricted-formats-no-default-format--2', $formats, 'full_html');
+    $this->assertOptions('edit-restricted-formats-no-default-format', $formats, 'full_html');
     $this->assertEnabledTextarea('edit-restricted-formats-default-value');
-    $this->assertOptions('edit-restricted-formats-default-format--2', $formats, 'full_html');
+    $this->assertOptions('edit-restricted-formats-default-format', $formats, 'full_html');
     $this->assertEnabledTextarea('edit-restricted-formats-default-missing-value');
-    $this->assertRequiredSelectAndOptions('edit-restricted-formats-default-missing-format--2', $formats);
+    $this->assertRequiredSelectAndOptions('edit-restricted-formats-default-missing-format', $formats);
     $this->assertEnabledTextarea('edit-restricted-formats-default-disallowed-value');
-    $this->assertRequiredSelectAndOptions('edit-restricted-formats-default-disallowed-format--2', $formats);
+    $this->assertRequiredSelectAndOptions('edit-restricted-formats-default-disallowed-format', $formats);
 
     // Test a text format element with a fixed format.
     $formats = array('filter_test');
     // When there is only a single option there is no point in choosing.
     $this->assertEnabledTextarea('edit-single-format-no-default-value');
-    $this->assertNoSelect('edit-single-format-no-default-format--2');
+    $this->assertNoSelect('edit-single-format-no-default-format');
     $this->assertEnabledTextarea('edit-single-format-default-value');
-    $this->assertNoSelect('edit-single-format-default-format--2');
+    $this->assertNoSelect('edit-single-format-default-format');
     // If the select has a missing or disallowed format, administrators must
     // explicitly choose the format.
     $this->assertEnabledTextarea('edit-single-format-default-missing-value');
-    $this->assertRequiredSelectAndOptions('edit-single-format-default-missing-format--2', $formats);
+    $this->assertRequiredSelectAndOptions('edit-single-format-default-missing-format', $formats);
     $this->assertEnabledTextarea('edit-single-format-default-disallowed-value');
-    $this->assertRequiredSelectAndOptions('edit-single-format-default-disallowed-format--2', $formats);
+    $this->assertRequiredSelectAndOptions('edit-single-format-default-disallowed-format', $formats);
   }
 
   /**
@@ -140,11 +140,11 @@ protected function doFilterFormTestAsNonAdmin() {
     $this->assertEnabledTextarea('edit-all-formats-no-default-value');
     // If no default is given, the format with the lowest weight becomes the
     // default. This happens to be 'filtered_html'.
-    $this->assertOptions('edit-all-formats-no-default-format--2', $formats, 'filtered_html');
+    $this->assertOptions('edit-all-formats-no-default-format', $formats, 'filtered_html');
     $this->assertEnabledTextarea('edit-all-formats-default-value');
     // \Drupal\filter_test\Form\FilterTestFormatForm::buildForm() uses
     // 'filter_test' as the default value in this case.
-    $this->assertOptions('edit-all-formats-default-format--2', $formats, 'filter_test');
+    $this->assertOptions('edit-all-formats-default-format', $formats, 'filter_test');
     // If a missing format is given as default, non-admin users are presented
     // with a disabled textarea.
     $this->assertDisabledTextarea('edit-all-formats-default-missing-value');
@@ -153,7 +153,7 @@ protected function doFilterFormTestAsNonAdmin() {
     $this->assertEnabledTextarea('edit-restricted-formats-no-default-value');
     // The user only has access to the 'filter_test' format, so when no default
     // is given that is preselected and the text format select is hidden.
-    $this->assertNoSelect('edit-restricted-formats-no-default-format--2');
+    $this->assertNoSelect('edit-restricted-formats-no-default-format');
     // When the format that the user does not have access to is preselected, the
     // textarea should be disabled.
     $this->assertDisabledTextarea('edit-restricted-formats-default-value');
@@ -163,9 +163,9 @@ protected function doFilterFormTestAsNonAdmin() {
     // Test a text format element with a fixed format.
     // When there is only a single option there is no point in choosing.
     $this->assertEnabledTextarea('edit-single-format-no-default-value');
-    $this->assertNoSelect('edit-single-format-no-default-format--2');
+    $this->assertNoSelect('edit-single-format-no-default-format');
     $this->assertEnabledTextarea('edit-single-format-default-value');
-    $this->assertNoSelect('edit-single-format-default-format--2');
+    $this->assertNoSelect('edit-single-format-default-format');
     // If the select has a missing or disallowed format make sure the textarea
     // is disabled.
     $this->assertDisabledTextarea('edit-single-format-default-missing-value');
@@ -191,8 +191,8 @@ protected function assertNoSelect($id) {
   /**
    * Asserts that a select element has the correct options.
    *
-   * @param string $id
-   *   The HTML ID of the select element.
+   * @param string $drupal_selector
+   *   The HTML name of the select element.
    * @param array $expected_options
    *   An array of option values.
    * @param string $selected
@@ -201,11 +201,11 @@ protected function assertNoSelect($id) {
    * @return bool
    *   TRUE if the assertion passed; FALSE otherwise.
    */
-  protected function assertOptions($id, array $expected_options, $selected) {
-    $select = $this->xpath('//select[@id=:id]', array(':id' => $id));
+  protected function assertOptions($drupal_selector, array $expected_options, $selected) {
+    $select = $this->xpath('//select[@data-drupal-selector=:data_drupal_selector]', [':data_drupal_selector' => $drupal_selector]);
     $select = reset($select);
-    $passed = $this->assertTrue($select instanceof \SimpleXMLElement, SafeMarkup::format('Field @id exists.', array(
-      '@id' => $id,
+    $passed = $this->assertTrue($select instanceof \SimpleXMLElement, SafeMarkup::format('Field @data-drupal-selector exists.', array(
+      '@data-drupal-selector' => $drupal_selector,
     )));
 
     $found_options = $this->getAllOptions($select);
@@ -214,7 +214,7 @@ protected function assertOptions($id, array $expected_options, $selected) {
       if ($expected_key !== FALSE) {
         $this->pass(SafeMarkup::format('Option @option for field @id exists.', array(
           '@option' => $expected_options[$expected_key],
-          '@id' => $id,
+          '@id' => $drupal_selector,
         )));
         unset($found_options[$found_key]);
         unset($expected_options[$expected_key]);
@@ -226,25 +226,25 @@ protected function assertOptions($id, array $expected_options, $selected) {
     foreach ($expected_options as $expected_option) {
       $this->fail(SafeMarkup::format('Option @option for field @id exists.', array(
         '@option' => $expected_option,
-        '@id' => $id,
+        '@id' => $drupal_selector,
       )));
       $passed = FALSE;
     }
     foreach ($found_options as $found_option) {
       $this->fail(SafeMarkup::format('Option @option for field @id does not exist.', array(
         '@option' => $found_option->attributes()->value,
-        '@id' => $id,
+        '@id' => $drupal_selector,
       )));
       $passed = FALSE;
     }
 
-    return $passed && $this->assertOptionSelected($id, $selected);
+    return $passed && $this->assertOptionSelected($drupal_selector, $selected);
   }
 
   /**
    * Asserts that there is a select element with the given ID that is required.
    *
-   * @param string $id
+   * @param string $drupal_selector
    *   The HTML ID of the select element.
    * @param array $options
    *   An array of option values that are contained in the select element
@@ -253,18 +253,16 @@ protected function assertOptions($id, array $expected_options, $selected) {
    * @return bool
    *   TRUE if the assertion passed; FALSE otherwise.
    */
-  protected function assertRequiredSelectAndOptions($id, array $options) {
-    $select = $this->xpath('//select[@id=:id and contains(@required, "required")]', array(
-      ':id' => $id,
-    ));
+  protected function assertRequiredSelectAndOptions($drupal_selector, array $options) {
+    $select = $this->xpath('//select[@data-drupal-selector=:data_drupal_selector]', [':data_drupal_selector' => $drupal_selector]);
     $select = reset($select);
-    $passed = $this->assertTrue($select instanceof \SimpleXMLElement, SafeMarkup::format('Required field @id exists.', array(
-      '@id' => $id,
+    $passed = $this->assertTrue($select instanceof \SimpleXMLElement, SafeMarkup::format('Required field @data-drupal-selector exists.', array(
+      '@data-drupal-selector' => $drupal_selector,
     )));
     // A required select element has a "- Select -" option whose key is an empty
     // string.
     $options[] = '';
-    return $passed && $this->assertOptions($id, $options, '');
+    return $passed && $this->assertOptions($drupal_selector, $options, '');
   }
 
   /**
diff --git a/core/modules/simpletest/src/AssertContentTrait.php b/core/modules/simpletest/src/AssertContentTrait.php
index b0efbe5..b9200a4 100644
--- a/core/modules/simpletest/src/AssertContentTrait.php
+++ b/core/modules/simpletest/src/AssertContentTrait.php
@@ -1163,8 +1163,7 @@ protected function assertNoFieldChecked($id, $message = '', $group = 'Browser')
    *   TRUE on pass, FALSE on fail.
    */
   protected function assertOption($id, $option, $message = '', $group = 'Browser') {
-    $options = $this->xpath('//select[@id=:id]//option[@value=:option]', array(':id' => $id, ':option' => $option));
-    return $this->assertTrue(isset($options[0]), $message ? $message : SafeMarkup::format('Option @option for field @id exists.', array('@option' => $option, '@id' => $id)), $group);
+    return $this->assertOptionWithDrupalSelector($id, $option, $message, $group);
   }
 
   /**
@@ -1213,9 +1212,9 @@ protected function assertOptionWithDrupalSelector($drupal_selector, $option, $me
    *   TRUE on pass, FALSE on fail.
    */
   protected function assertNoOption($id, $option, $message = '', $group = 'Browser') {
-    $selects = $this->xpath('//select[@id=:id]', array(':id' => $id));
-    $options = $this->xpath('//select[@id=:id]//option[@value=:option]', array(':id' => $id, ':option' => $option));
-    return $this->assertTrue(isset($selects[0]) && !isset($options[0]), $message ? $message : SafeMarkup::format('Option @option for field @id does not exist.', array('@option' => $option, '@id' => $id)), $group);
+    $options = $this->xpath('//select[@data-drupal-selector=:data_drupal_selector]//option[@value=:option]', array(':data_drupal_selector' => $id, ':option' => $option));
+    return $this->assertFalse(isset($options[0]), $message ? $message : SafeMarkup::format('Option @option for field @data_drupal_selector exists.', array('@option' => $option, '@data_drupal_selector' => $id)), $group);
+
   }
 
   /**
@@ -1241,8 +1240,7 @@ protected function assertNoOption($id, $option, $message = '', $group = 'Browser
    * @todo $id is unusable. Replace with $name.
    */
   protected function assertOptionSelected($id, $option, $message = '', $group = 'Browser') {
-    $elements = $this->xpath('//select[@id=:id]//option[@value=:option]', array(':id' => $id, ':option' => $option));
-    return $this->assertTrue(isset($elements[0]) && !empty($elements[0]['selected']), $message ? $message : SafeMarkup::format('Option @option for field @id is selected.', array('@option' => $option, '@id' => $id)), $group);
+    return $this->assertOptionSelectedWithDrupalSelector($id, $option, $message, $group);
   }
 
   /**
@@ -1293,8 +1291,8 @@ protected function assertOptionSelectedWithDrupalSelector($drupal_selector, $opt
    *   TRUE on pass, FALSE on fail.
    */
   protected function assertNoOptionSelected($id, $option, $message = '', $group = 'Browser') {
-    $elements = $this->xpath('//select[@id=:id]//option[@value=:option]', array(':id' => $id, ':option' => $option));
-    return $this->assertTrue(isset($elements[0]) && empty($elements[0]['selected']), $message ? $message : SafeMarkup::format('Option @option for field @id is not selected.', array('@option' => $option, '@id' => $id)), $group);
+    $elements = $this->xpath('//select[@data-drupal-selector=:data_drupal_selector]//option[@value=:option]', array(':data_drupal_selector' => $id, ':option' => $option));
+    return $this->assertFalse(isset($elements[0]) && !empty($elements[0]['selected']), $message ? $message : SafeMarkup::format('Option @option for field @data_drupal_selector is selected.', array('@option' => $option, '@data_drupal_selector' => $id)), $group);
   }
 
   /**
