function MultipleValueWidgetTest::assertHasFocusByAttribute

Same name in other branches
  1. 11.x core/modules/field/tests/src/FunctionalJavascript/MultipleValueWidgetTest.php \Drupal\Tests\field\FunctionalJavascript\MultipleValueWidgetTest::assertHasFocusByAttribute()

Asserts an element specified by an attribute value has focus.

@todo Replace with assertHasFocus() in https://drupal.org/i/3041768.

Parameters

string $name: The attribute name.

string $value: The attribute value.

1 call to MultipleValueWidgetTest::assertHasFocusByAttribute()
MultipleValueWidgetTest::testFieldMultipleValueWidgetAddMoreNoValidation in core/modules/field/tests/src/FunctionalJavascript/MultipleValueWidgetTest.php
Tests that no validation occurs on field on "Add more" click.

File

core/modules/field/tests/src/FunctionalJavascript/MultipleValueWidgetTest.php, line 208

Class

MultipleValueWidgetTest
Tests widget form for a multiple value field.

Namespace

Drupal\Tests\field\FunctionalJavascript

Code

private function assertHasFocusByAttribute(string $name, string $value) : void {
    $active_element = $this->getSession()
        ->evaluateScript('document.activeElement');
    $this->assertSame($value, $active_element->attribute($name));
}

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