Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By alexpott on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.2.x
Introduced in version:
8.2.6
Issue links:
Description:
New methods have been added to Drupal\FunctionalJavascriptTests\JSWebAssert
to facilitate testing javascript driven events that added new elements to the page. There are:
::waitForElement()
::waitForElementVisible()
::waitForButton()
::waitForLink()
::waitForField()
::waitForId()
Additionally we discourage the use of:
::assertWaitOnAjaxRequest()
::waitOnAutocomplete()
Example usage in a JavascriptTestBase test:
$assert_session = $this->assertSession();
// Do something that makes an element visible.
$result = $assert_session->waitForElementVisible('named', array('button', 'Added WaitForElementVisible'));
$this->assertNotEmpty($result);
// Do something that adds a button.
$result = $assert_session->waitForButton('Added button');
$this->assertNotEmpty($result);
// Do something that adds a link
$result = $assert_session->waitForLink('Added link');
$this->assertNotEmpty($result);
// Do something that adds a field.
$result = $assert_session->waitForField('added_field');
$this->assertNotEmpty($result);
// Do something that adds an HTML element with a particular ID.
$result = $assert_session->waitForId('js_webassert_test_field_id');
$this->assertNotEmpty($result);
Impacts:
Module developers