Problem/Motivation

AssertLegacyTrait::assertFieldByXPath() is deprecated in drupal:8.3.0 and is removed from drupal:10.0.0. Use $this->xpath() instead and check the values directly in the test. See https://www.drupal.org/node/3129738

Proposed resolution

Replace assertFieldByXPath() and assertNOFieldByXPath() with $this->xpath().

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#81 rawdiff_76-81.txt2.31 KBmondrake
#81 3139429-81.patch123.33 KBmondrake
#79 3139429-79.patch121.89 KBpaulocs
#76 3139429-76.patch123.3 KBmondrake
#70 interdiff_66-70.txt2.13 KBmondrake
#70 3139429-70.patch123.03 KBmondrake
#66 interdiff.3139429.62-66.txt1.12 KBlongwave
#66 3139429-66.patch122.95 KBlongwave
#62 3139429-62.patch122.37 KBmondrake
#62 interdiff_58-62.txt747 bytesmondrake
#58 interdiff_55-58.txt10.86 KBmondrake
#58 3139429-58.patch122.36 KBmondrake
#58 3139429-58.patch10.86 KBmondrake
#55 3139429-55.patch122.41 KBpaulocs
#51 interdiff_49-51.txt4.6 KBmondrake
#51 3139429-51.patch122.42 KBmondrake
#49 3139429-49.patch120.97 KBmondrake
#49 interdiff_48-49.txt24.97 KBmondrake
#48 interdiff_47-48.txt14.93 KBmondrake
#48 3139429-48.patch95.99 KBmondrake
#47 3139429-47.patch82.26 KBmondrake
#47 interdiff_44-47.txt6.59 KBmondrake
#46 interdiff_44-46.txt6.41 KBmondrake
#46 3139429-46.patch82.26 KBmondrake
#45 interdiff-44-45.txt829 bytesjungle
#45 3139429-45.patch82.21 KBjungle
#44 interdiff_43-44.txt23.12 KBmondrake
#44 3139429-44.patch82.21 KBmondrake
#43 3139429-43.patch60.07 KBmondrake
#43 interdiff_42-43.txt11.89 KBmondrake
#42 interdiff_41-42.txt9.58 KBmondrake
#42 3139429-42.patch50.37 KBmondrake
#41 interdiff_40-41.txt10.15 KBmondrake
#41 3139429-41.patch51.51 KBmondrake
#40 3139429-40.patch41.36 KBmondrake
#40 interdiff_39-40.txt4.46 KBmondrake
#39 interdiff_38-39.txt20.93 KBmondrake
#39 3139429-39.patch38.6 KBmondrake
#38 interdiff_36-38.txt11.54 KBmondrake
#38 3139429-38.patch17.66 KBmondrake
#36 3139429-36.patch6.13 KBmondrake
#29 interdiff_28-29.txt2.82 KBrahulrasgon
#29 3139429-29.patch130.94 KBrahulrasgon
#28 interdiff_23-28.txt74.55 KBrahulrasgon
#28 3139429-28.patch127.86 KBrahulrasgon
#25 interdiff_23-25.txt71.61 KBrahulrasgon
#25 3139429-25.patch127.78 KBrahulrasgon
#23 3139429-23.patch129.12 KBrahulrasgon
#22 3139429-22.patch129.12 KBrahulrasgon
#19 interdiff_18-19.txt6.62 KBmohrerao
#19 3139429-19.patch150.84 KBmohrerao
#18 3139429-18.patch150.79 KBmohrerao
#16 interdiff_13-16.txt12.07 KBmohrerao
#16 3139429-16.patch151.13 KBmohrerao
#13 3139429-13.patch151.17 KBcburschka
#10 interdiff_8-10.txt10.29 KBsiddhant.bhosale
#10 3139429-10.patch151.71 KBsiddhant.bhosale
#8 3139429-8.patch151.26 KBsiddhant.bhosale
#4 3139429-4.patch94.52 KBmunish.kumar
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mondrake created an issue. See original summary.

jungle’s picture

Issue tags: +Deprecated assertions

Adding the "Deprecated assertions" tag to add this into the kanban board https://contribkanban.com/board/Deprecatedassertions

munish.kumar’s picture

Assigned: Unassigned » munish.kumar
munish.kumar’s picture

Assigned: munish.kumar » Unassigned
Status: Active » Needs review
FileSize
94.52 KB

Status: Needs review » Needs work

The last submitted patch, 4: 3139429-4.patch, failed testing. View results

siddhant.bhosale’s picture

Assigned: Unassigned » siddhant.bhosale
mohrerao’s picture

Assigned: siddhant.bhosale » mohrerao

Working on failed tests

siddhant.bhosale’s picture

Assigned: mohrerao » siddhant.bhosale
Status: Needs work » Needs review
FileSize
151.26 KB

Hi, I found the use of $this->xpath() was not correct.
Also, $this->assertNoFieldByXPath is deprecated but still used ion patch.
So solved the issues and uploading the patch.

siddhant.bhosale’s picture

Assigned: siddhant.bhosale » Unassigned
siddhant.bhosale’s picture

Assigned: Unassigned » siddhant.bhosale
Status: Needs review » Needs work
FileSize
151.71 KB
10.29 KB

Missed out a few functions descriptions. Adding the patch and interdiff.

siddhant.bhosale’s picture

Assigned: siddhant.bhosale » Unassigned
Status: Needs work » Needs review
cburschka’s picture

Assigned: Unassigned » cburschka
Status: Needs review » Needs work

patch isn't applying

cburschka’s picture

Assigned: cburschka » Unassigned
Status: Needs work » Needs review
FileSize
151.17 KB

Simple reroll

Status: Needs review » Needs work

The last submitted patch, 13: 3139429-13.patch, failed testing. View results

siddhant.bhosale’s picture

Assigned: Unassigned » siddhant.bhosale
mohrerao’s picture

Fixed some of below errors:

  1. DOMXPath::query(): Invalid predicate
  2. TypeError: Argument 2 passed to Drupal\Tests\BrowserTestBase::xpath() must be of the type array, string given, called in

Still WIP. Will take a look into the failed ones after one more pass

cburschka’s picture

  1. +++ b/core/modules/block/tests/src/Functional/BlockHtmlTest.php
    @@ -45,8 +48,8 @@ public function testHtml() {
    +    $this->assertTrue(!empty($elements), 'HTML ID and attributes for test block are valid and on the same DOM element');
    
    +++ b/core/modules/block/tests/src/Functional/BlockTest.php
    @@ -353,7 +353,7 @@ public function moveBlockToRegion(array $block, $region) {
    +    $this->assertTrue(!empty($this->xpath($xpath, [])), new FormattableMarkup('Block found in %region_name region.', ['%region_name' => Html::getClass($region)]));
    

    This should be ->assertNotEmpty(), not ->assertTrue(!empty()). (There are many of these, and probably similar ones.)

  2. +++ b/core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php
    @@ -65,7 +65,7 @@ public function testBlockContentCreation() {
    -    $this->assertNoFieldByXPath('//select[@name="settings[view_mode]"]', NULL, 'View mode setting hidden because only one exists');
    +    $this->assertCount(1, $this->xpath('//select[@name="settings[view_mode]"]', []), 'View mode setting hidden because only one exists');
    

    This one looks definitely incorrect. The assertion is turned from asserting that the field does not exist to asserting that the field does exist.

(Note, this was already in the patch before the most recent version, since #8)

mohrerao’s picture

Rerolled patch. and have fixed #17.2. Working on fixing occurances of #17.1

mohrerao’s picture

Fixed some more failing tests .

rahulrasgon’s picture

Issue summary: View changes
rahulrasgon’s picture

Working on it.

rahulrasgon’s picture

Status: Needs work » Needs review
FileSize
129.12 KB

Please review the patch.
Thanks

rahulrasgon’s picture

Fixed PHPLint errors.
Please ignore last path and review this one.
Thanks

Status: Needs review » Needs work

The last submitted patch, 23: 3139429-23.patch, failed testing. View results

rahulrasgon’s picture

Assigned: rahulrasgon » Unassigned
Status: Needs work » Needs review
FileSize
127.78 KB
71.61 KB

Fixed failing test cases.
Please review the patch.
Thanks

Status: Needs review » Needs work

The last submitted patch, 25: 3139429-25.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

rahulrasgon’s picture

Assigned: Unassigned » rahulrasgon
rahulrasgon’s picture

rahulrasgon’s picture

FileSize
130.94 KB
2.82 KB

All occurrences of $this->assertFieldByXPath() and $this->assertNoFieldByXPath() have been replaced.
The deprecation message suppression has been removed.
Added the @expectedDeprecation to the docblock of testXpathAsserts

Please review the patch.
Thanks

Status: Needs review » Needs work

The last submitted patch, 29: 3139429-29.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

narendra.rajwar27’s picture

Assigned: Unassigned » narendra.rajwar27
mohrerao’s picture

Tests are failing since assertFieldByName() uses AssertLegacyTrait::assertFieldByXPath. We will have to wait till https://www.drupal.org/project/drupal/issues/3139406 lands.

narendra.rajwar27’s picture

Assigned: narendra.rajwar27 » Unassigned

Oops, forget to unassign this issue.

mondrake’s picture

Status: Needs work » Postponed
mondrake’s picture

Assigned: Unassigned » mondrake
Status: Postponed » Active

Blockers were committed so this can be worked on now. I am on this.

mondrake’s picture

Status: Active » Needs review
FileSize
6.13 KB

Trying to use WebAssert methods instead of PHPUnit assertions on $this->xpath results. Only a start patch.

Status: Needs review » Needs work

The last submitted patch, 36: 3139429-36.patch, failed testing. View results

mondrake’s picture

mondrake’s picture

mondrake’s picture

mondrake’s picture

mondrake’s picture

mondrake’s picture

mondrake’s picture

jungle’s picture

Status: Needs work » Needs review
FileSize
82.21 KB
829 bytes

Fixing PHPLint error

mondrake’s picture

Status: Needs review » Needs work
FileSize
82.26 KB
6.41 KB
mondrake’s picture

mondrake’s picture

mondrake’s picture

Status: Needs work » Needs review
Issue tags: +Needs tests
FileSize
24.97 KB
120.97 KB

This should complete the removal of calls from Functional tests. Note that the equally named methods in Kernel tests are NOT in scope for removal here. We need a deprecation test, but if it turns back green this is ready for reviews.

Status: Needs review » Needs work

The last submitted patch, 49: 3139429-49.patch, failed testing. View results

mondrake’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
FileSize
122.42 KB
4.6 KB

Added deprecation test and fixed failures.

mondrake’s picture

Assigned: mondrake » Unassigned
paulocs’s picture

Status: Needs review » Needs work

It needs reroll.
I'll do it.

paulocs’s picture

Assigned: Unassigned » paulocs
paulocs’s picture

Assigned: paulocs » Unassigned
Status: Needs work » Needs review
FileSize
122.41 KB

Please review.

longwave’s picture

Status: Needs review » Needs work

A few places where things can be improved but overall this is looking good, great effort everyone - it's tricky getting all these right.

  1. +++ b/core/modules/config/tests/src/Functional/ConfigSingleImportExportTest.php
    @@ -243,8 +243,10 @@ public function testImportSimpleConfiguration() {
    +    $this->assertTrue($this->assertSession()->optionExists("config_type", 'Simple configuration')->isSelected());
    

    Worth breaking this out into two lines?

    $option = ...
    $this->assertTrue($option->isSelected());
    
  2. +++ b/core/modules/content_translation/tests/src/Functional/ContentTranslationSettingsTest.php
    @@ -296,7 +296,7 @@ public function testFieldTranslatableSettingsUI() {
    -    $this->assertFieldByXPath('//input[@id="edit-translatable" and not(@disabled) and @checked="checked"]');
    +    $this->assertSession()->checkboxChecked('edit-translatable');
    

    The not(@disabled) check is lost here.

  3. +++ b/core/modules/field/tests/src/Functional/EntityReference/EntityReferenceAutoCreateTest.php
    @@ -105,7 +105,7 @@ protected function setUp(): void {
    -    $this->assertFieldByXPath('//input[@id="edit-test-field-0-target-id" and contains(@class, "form-autocomplete")]', NULL, 'The autocomplete input element appears.');
    +    $this->assertSession()->elementExists('xpath', '//input[@id="edit-test-field-0-target-id" and contains(@class, "form-autocomplete")]');
    

    Here I think we can use fieldExists() then hasClass() separately.

  4. +++ b/core/modules/field/tests/src/FunctionalJavascript/EntityReference/EntityReferenceAdminTest.php
    @@ -162,7 +162,7 @@ public function testFieldAdminHandler() {
    +    $this->assertSession()->elementExists('xpath', '//table[@id="field-overview"]//tr[@id="field-test"]/td[1 and text() = "Test"]');
    

    This can be elementContains() for the text part.

  5. +++ b/core/modules/field_ui/tests/src/Functional/ManageFieldsFunctionalTest.php
    @@ -635,7 +635,7 @@ public function testHiddenFields() {
    +    $this->assertSession()->elementExists('xpath', '//table[@id="field-overview"]//tr[@id="hidden-test-field"]//td[1 and text() = "' . $field['label'] . '"]');
    

    Same

  6. +++ b/core/modules/field_ui/tests/src/Traits/FieldUiTestTrait.php
    @@ -58,7 +58,7 @@ public function fieldUIAddNewField($bundle_path, $field_name, $label = NULL, $fi
    +    $this->assertSession()->elementExists('xpath', "//table[@id=\"field-overview\"]//tr/td[1 and text()=\"$label\"]");
    
    @@ -95,7 +95,7 @@ public function fieldUIAddExistingField($bundle_path, $existing_storage_name, $l
    +    $this->assertSession()->elementExists('xpath', "//table[@id=\"field-overview\"]//tr/td[1 and text()=\"$label\"]");
    
    @@ -123,7 +123,7 @@ public function fieldUIDeleteField($bundle_path, $field_name, $label, $bundle_la
    +    $this->assertSession()->elementNotExists('xpath', '//table[@id="field-overview"]//span[@class="label-field" and text()="' . $label . '"]');
    

    Same

  7. +++ b/core/modules/file/tests/src/Functional/FileFieldDisplayTest.php
    @@ -218,7 +218,7 @@ public function testDescriptionDefaultFileFieldDisplay() {
    +    $this->assertSession()->elementTextContains('xpath', '//a[@href="' . $node->{$field_name}->entity->createFileUrl(FALSE) . '"]', $description);
    
    @@ -228,7 +228,7 @@ public function testDescriptionDefaultFileFieldDisplay() {
    +    $this->assertSession()->elementTextContains('xpath', '//a[@href="' . $node->{$field_name}->entity->createFileUrl(FALSE) . '"]', $description);
    

    The link* methods returning the element would help here, this will have to do otherwise.

  8. +++ b/core/modules/file/tests/src/Functional/FileManagedFileElementTest.php
    @@ -24,7 +24,7 @@ class FileManagedFileElementTest extends FileFieldTestBase {
    +    $this->assertSession()->elementExists('xpath', '//input[@name="files[nested_file]" and @size="13"]');
    

    This could be fieldExists() and then a separate attribute check.

  9. +++ b/core/modules/shortcut/tests/src/Functional/ShortcutSetsTest.php
    @@ -151,7 +151,7 @@ public function testShortcutSetSwitchNoSetName() {
    -    $this->assertFieldByXPath("//input[@name='label' and contains(concat(' ', normalize-space(@class), ' '), ' error ')]", NULL, 'The new set label field has the error class');
    +    $this->assertSession()->elementExists('xpath', "//input[@name='label' and contains(concat(' ', normalize-space(@class), ' '), ' error ')]");
    

    Can we use fieldExists() and then hasClass() here?

  10. +++ b/core/modules/system/tests/src/Functional/Form/ModulesListFormWebTest.php
    @@ -41,13 +41,13 @@ public function testModuleListForm() {
    +    $this->assertSession()->elementExists('xpath', "//a[contains(@href, '/system-test/configure/bar') and text()='Configure ']/span[contains(@class, 'visually-hidden') and text()='the System test module']");
    ...
    +    $this->assertSession()->elementExists('xpath', "//a[contains(@href, '/admin/people/permissions#module-system_test') and @title='Configure permissions']");
    ...
    +    $this->assertSession()->elementExists('xpath', "//a[contains(@href, '/admin/help/system_test') and @title='Help']");
    

    Again a shame that the link* methods don't return the element, as that could mean these could be broken into separate assertions.

  11. +++ b/core/modules/system/tests/src/Functional/Module/PrepareUninstallTest.php
    @@ -159,7 +159,7 @@ public function testUninstall() {
         $button_xpath = '//input[@type="submit"][@value="Delete all entity test without label entities"]';
    -    $this->assertNoFieldByXPath($button_xpath, NULL, 'Button with value "Delete all entity test without label entities" not found');
    +    $this->assertSession()->elementNotExists('xpath', $button_xpath);
    

    buttonNotExists()?

  12. +++ b/core/modules/user/tests/src/Functional/UserCreateTest.php
    @@ -78,7 +78,7 @@ public function testUserAdd() {
    -    $this->assertFieldByXPath('//input[@type="radio" and @id="edit-status-1" and @checked="checked"]', NULL, 'Default setting for user status is active.');
    +    $this->assertSession()->elementExists('xpath', '//input[@type="radio" and @id="edit-status-1" and @checked="checked"]');
    

    Can we use checkboxChecked()? (even though it's a radio, it seems like it should still work)

  13. +++ b/core/modules/user/tests/src/Functional/UserLoginTest.php
    @@ -172,7 +172,7 @@ public function assertFailedLogin($account, $flood_trigger = NULL) {
    -    $this->assertNoFieldByXPath("//input[@name='pass' and @value!='']", NULL, 'Password value attribute is blank.');
    +    $this->assertSession()->elementNotExists('xpath', "//input[@name='pass' and @value!='']");
    

    Surely we actually want fieldValueEquals('pass', '') here?

mondrake’s picture

Assigned: Unassigned » mondrake

Thanks, on this.

mondrake’s picture

Status: Needs work » Needs review
FileSize
10.86 KB
122.36 KB
10.86 KB

Done #56, with the exception of:

7, 10 - we'd need a separate issue to get linkExists and linkExistsByHref to return the identified node, oos here. For a couple of usages not sure about the effort, though.

6 - it's a subtle difference to include the selection in the xpath vs checking the value: the former works as a filter, the latter just would use the first node returned and check its value. If we are sure that the xpath w/o the condition returns one node only - OK it the same thing. But in this case I'm not convinced that's the case so I prefer to leave it as part of the filter.

Status: Needs review » Needs work

The last submitted patch, 58: 3139429-58.patch, failed testing. View results

longwave’s picture

For #56.6 I agree about the last case but the first two are just td[1] and that will always only be one element anyway.

mondrake’s picture

But "//tr/td[1]" would return all the td[1] of all the rows in the table, no?

mondrake’s picture

Status: Needs work » Needs review
FileSize
747 bytes
122.37 KB

Fixing failure in #58.

longwave’s picture

Status: Needs review » Reviewed & tested by the community

Ahh yes, sorry, you're absolutely right. The other changes look great so RTBC if bot agrees.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 62: 3139429-62.patch, failed testing. View results

mondrake’s picture

Re failure in #62,

+++ b/core/modules/user/tests/src/Functional/UserLoginTest.php
@@ -172,7 +172,7 @@ public function assertFailedLogin($account, $flood_trigger = NULL) {
     $this->drupalPostForm('user/login', $edit, t('Log in'));
-    $this->assertNoFieldByXPath("//input[@name='pass' and @value!='']", NULL, 'Password value attribute is blank.');
+    $this->assertSession()->fieldValueEquals('edit-pass', '');
     if (isset($flood_trigger)) {

it looks like Mink cannot process fields of type 'password'. Actually I suspect the current code is just a false negative, since it's asserting absence. Working on turning this to a positive check that the field exists with no value.

longwave’s picture

Status: Needs work » Needs review
FileSize
122.95 KB
1.12 KB

I don't think that's the issue, it's that either the field exists and is empty, or the field doesn't exist at all (in the case of the flood protection being triggered). The old XPath tried to cater for both these, but it's better to assert the two cases separately.

mondrake’s picture

Status: Needs review » Reviewed & tested by the community

I got to solve that differently,

-    $this->assertNoFieldByXPath("//input[@name='pass' and @value!='']", NULL, 'Password value attribute is blank.');
+    // Check that password value is blank, if the field exists.
+    $pass = $this->getSession()->getPage()->find('xpath', '//input[@id = "edit-pass"]');
+    if ($pass) {
+      $this->assertFalse($pass->hasAttribute('value'));
+      $this->assertEquals('', $pass->getValue());
+    }

but @longwave's solution in #66 is better, I think.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 66: 3139429-66.patch, failed testing. View results

mondrake’s picture

+++ b/core/modules/field_ui/tests/src/Traits/FieldUiTestTrait.php
@@ -58,7 +58,7 @@ public function fieldUIAddNewField($bundle_path, $field_name, $label = NULL, $fi
+    $this->assertSession()->elementExists('xpath', "//table[@id=\"field-overview\"]//tr/td[1 and text()=\"$label\"]");

@@ -95,7 +95,7 @@ public function fieldUIAddExistingField($bundle_path, $existing_storage_name, $l
+    $this->assertSession()->elementExists('xpath', "//table[@id=\"field-overview\"]//tr/td[1 and text()=\"$label\"]");

@@ -123,7 +123,7 @@ public function fieldUIDeleteField($bundle_path, $field_name, $label, $bundle_la
+    $this->assertSession()->elementNotExists('xpath', '//table[@id="field-overview"]//span[@class="label-field" and text()="' . $label . '"]');

mmm, I am afraid we need to escape $label here

mondrake’s picture

Status: Needs work » Needs review
FileSize
123.03 KB
2.13 KB

Doing #69

mondrake’s picture

Assigned: mondrake » Unassigned
longwave’s picture

Status: Needs review » Reviewed & tested by the community

+1 to proper escaping, looks good to me.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 70: 3139429-70.patch, failed testing. View results

mondrake’s picture

Status: Needs work » Reviewed & tested by the community

Random fail

quietone’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

Patch no longer applies.

mondrake’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs reroll
FileSize
123.3 KB

Rerolled

catch’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

Needs a re-roll.

paulocs’s picture

Assigned: Unassigned » paulocs

I'll do it.

paulocs’s picture

Assigned: paulocs » Unassigned
Status: Needs work » Needs review
FileSize
121.89 KB
mondrake’s picture

Status: Needs review » Needs work
Issue tags: -Needs reroll

In #79 we have lost the deprecation test that is in #76,

+++ b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
@@ -385,16 +385,20 @@ public function testAssertField() {
   /**
-   * Tests legacy field asserts by id.
+   * Tests legacy field asserts by id and by Xpath.
    *
    * @group legacy
    * @expectedDeprecation AssertLegacyTrait::assertFieldById() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->fieldExists() or $this->assertSession()->buttonExists() or $this->assertSession()->fieldValueEquals() instead. See https://www.drupal.org/node/3129738
    * @expectedDeprecation AssertLegacyTrait::assertNoFieldById() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->fieldNotExists() or $this->assertSession()->buttonNotExists() or $this->assertSession()->fieldValueNotEquals() instead. See https://www.drupal.org/node/3129738
+   * @expectedDeprecation AssertLegacyTrait::assertFieldByXPath() is deprecated in drupal:8.3.0 and is removed from drupal:10.0.0. Use $this->xpath() instead and check the values directly in the test. See https://www.drupal.org/node/3129738
+   * @expectedDeprecation 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
    */
   public function testAssertFieldById() {
     $this->drupalGet('test-field-xpath');
     $this->assertFieldById('edit-save', NULL);
     $this->assertNoFieldById('invalid', NULL);
+    $this->assertFieldByXPath("//input[@id = 'edit-name']", 'Test name');
+    $this->assertNoFieldByXPath("//input[@id = 'edit-name']", 'wrong value');
   }

we no longer use @expectedDeprecation annotations, we should use calls to $this->expectDeprecation().

mondrake’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
123.33 KB
2.31 KB

Rerolled

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

  • catch committed 652efc7 on 9.2.x
    Issue #3139429 by mondrake, rahulrasgon, mohrerao, siddhant.bhosale,...

  • catch committed d8f4b27 on 9.1.x
    Issue #3139429 by mondrake, rahulrasgon, mohrerao, siddhant.bhosale,...
catch’s picture

Version: 9.2.x-dev » 9.1.x-dev
Status: Reviewed & tested by the community » Fixed

Good clean-up, nice to see so many of the assertions get more readable in the process.

Committed/pushed to 9.2.x and cherry-picked to 9.1.x, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.