function FieldUiTestTrait::assertTableHeaderExistsByLabel

Asserts that a header cell appears on a table.

Parameters

string $table_id: The HTML attribute value to target a given table.

string $label: The cell label.

1 call to FieldUiTestTrait::assertTableHeaderExistsByLabel()
ManageDisplayTest::testViewModeUi in core/modules/field_ui/tests/src/Functional/ManageDisplayTest.php
Tests view mode management screens.

File

core/modules/field_ui/tests/src/Traits/FieldUiTestTrait.php, line 277

Class

FieldUiTestTrait
Provides common functionality for the Field UI test classes.

Namespace

Drupal\Tests\field_ui\Traits

Code

protected function assertTableHeaderExistsByLabel(string $table_id, string $label) : void {
    $expression = '//table[@id=:id]//tr//th[1 and text() = :label]';
    $xpath = $this->assertSession()
        ->buildXPathQuery($expression, [
        ':id' => $table_id,
        ':label' => $label,
    ]);
    $element = $this->getSession()
        ->getPage()
        ->find('xpath', $xpath);
    $this->assertSession()
        ->assert($element !== NULL, sprintf('Table header not found by label: "%s".', $label));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.