protected function AssertLegacyTrait::assertNoFieldByXPath in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php \Drupal\FunctionalTests\AssertLegacyTrait::assertNoFieldByXPath()
Asserts that a field does not exist or its value does not match, by XPath.
Parameters
string $xpath: XPath used to find the field.
string $value: (optional) Value of the field, to assert that the field's value on the page does not match it.
string $message: (optional) A message to display with the assertion. Do not translate messages with t().
Throws
\Behat\Mink\Exception\ExpectationException
Deprecated
in drupal:8.3.0 and is removed from drupal:10.0.0. Use $this->xpath() instead and assert that the result is empty.
See also
https://www.drupal.org/node/3129738
4 calls to AssertLegacyTrait::assertNoFieldByXPath()
- AssertLegacyTrait::assertNoField in core/
tests/ Drupal/ FunctionalTests/ AssertLegacyTrait.php - Asserts that a field does NOT exist with the given name or ID.
- AssertLegacyTrait::assertNoFieldById in core/
tests/ Drupal/ FunctionalTests/ AssertLegacyTrait.php - Asserts that a field does not exist with the given ID and value.
- AssertLegacyTrait::assertNoFieldByName in core/
tests/ Drupal/ FunctionalTests/ AssertLegacyTrait.php - Asserts that a field does not exist with the given name and value.
- BrowserTestBaseTest::testAssertFieldById in core/
tests/ Drupal/ FunctionalTests/ BrowserTestBaseTest.php - Tests legacy field asserts by id and by Xpath.
File
- core/
tests/ Drupal/ FunctionalTests/ AssertLegacyTrait.php, line 700
Class
- AssertLegacyTrait
- Provides convenience methods for assertions in browser tests.
Namespace
Drupal\FunctionalTestsCode
protected function assertNoFieldByXPath($xpath, $value = NULL, $message = '') {
@trigger_error('AssertLegacyTrait::assertNoFieldByXPath() is deprecated in drupal:8.3.0 and is removed from drupal:10.0.0. Use $this->xpath() instead and assert that the result is empty. See https://www.drupal.org/node/3129738', E_USER_DEPRECATED);
$fields = $this
->xpath($xpath);
if (!empty($fields)) {
if (isset($value)) {
$found = FALSE;
try {
$this
->assertFieldsByValue($fields, $value);
$found = TRUE;
} catch (\Exception $e) {
}
if ($found) {
throw new ExpectationException(sprintf('The field resulting from %s was found with the provided value %s.', $xpath, $value), $this
->getSession()
->getDriver());
}
}
else {
throw new ExpectationException(sprintf('The field resulting from %s was found.', $xpath), $this
->getSession()
->getDriver());
}
}
}