diff -u b/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php b/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php --- b/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php +++ b/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php @@ -2,7 +2,6 @@ namespace Drupal\FunctionalTests; -use Behat\Mink\Exception\ElementNotFoundException; use Behat\Mink\Exception\ExpectationException; use Behat\Mink\Selector\Xpath\Escaper; use Drupal\Component\Render\FormattableMarkup; @@ -248,7 +247,7 @@ } /** - * Asserts that a field exists with the given ID and val.ue. + * Asserts that a field exists with the given ID and value. * * @param string $id * ID of field to assert. @@ -613,8 +612,9 @@ if ($fields) { foreach ($fields as $field) { if ($field->getAttribute('type') == 'checkbox') { - // Checkbox with the correct checked state. - $found = $field->isChecked() === $value; + // Checkbox with the correct checked state if the value was passed + // as a boolean. + $found = !is_bool($value) || $field->isChecked() === $value; } elseif ($field->getTagName() == 'select' && $field->find('xpath', '//option[@value = ' . (new Escaper())->escapeLiteral($value) . ' and @selected = "selected"]')) { // Select element with an option.