Problem/Motivation

In #3167880: [meta] Convert assertions involving use of xpath to WebAssert, where possible we identified that use of $this->xpath() can be dangerous as we aren't always testing what we expect to test. In WebAssert we have more appropriate methods to find and assert HTML elements, so we should use them where possible.

This issue is scoped to find XPath selectors for <label> elements and convert those where possible.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3220183

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mondrake created an issue. See original summary.

mondrake’s picture

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

mondrake’s picture

Assigned: mondrake » Unassigned
Status: Active » Needs review

I messed a bit with MR target branches, but should be OK for review now.

longwave’s picture

Status: Needs review » Reviewed & tested by the community

These are all so much easier to read. I could only find one remaining case of a label in xpath() in UserAccountLinksTest and I think this has to stay as is:

    $label = $this->xpath('//label[contains(.,:text)]/@for', [':text' => 'Enable My account menu link']);
    $this->assertSession()->checkboxChecked($label[0]->getText());

Therefore there is nothing else left to do here and this is RTBC.

  • catch committed 67bfb63 on 9.3.x
    Issue #3220183 by mondrake, longwave: Convert assertions involving use...
catch’s picture

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

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

  • catch committed b7ae0cb on 9.2.x
    Issue #3220183 by mondrake, longwave: Convert assertions involving use...

Status: Fixed » Closed (fixed)

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