public function testAjaxElementValidation() { $this->
drupalGet('ajax_validation_test'
);
$page =
$this->
getSession()->
getPage();
$assert =
$this->
assertSession();
// Partially complete the form with a string.
$page->
fillField('drivertext', 'some dumb text'
);
// Move focus away from this field to trigger AJAX.
$page->
findField('spare_required_field'
)->
focus();
// When the AJAX command updates the DOM a <ul> unsorted list
// "message__list" structure will appear on the page echoing back the
// "some dumb text" message.
$placeholder_text =
$assert->
waitForElement('css', "[aria-label='Status message'] > ul > li > em:contains('some dumb text')"
);
$this->
assertNotNull($placeholder_text, 'A callback successfully echoed back a string.'
);
$this->
drupalGet('ajax_validation_test'
);
// Partially complete the form with a number.
$page->
fillField('drivernumber', '12345'
);
$page->
findField('spare_required_field'
)->
focus();