ElementValidationTest.php in Drupal 8
File
core/tests/Drupal/FunctionalJavascriptTests/Ajax/ElementValidationTest.php
View source
<?php
namespace Drupal\FunctionalJavascriptTests\Ajax;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
class ElementValidationTest extends WebDriverTestBase {
public static $modules = [
'ajax_test',
'ajax_forms_test',
];
protected $defaultTheme = 'classy';
public function testAjaxElementValidation() {
$this
->drupalGet('ajax_validation_test');
$page = $this
->getSession()
->getPage();
$assert = $this
->assertSession();
$page
->fillField('drivertext', 'some dumb text');
$page
->findField('spare_required_field')
->focus();
$placeholder_text = $assert
->waitForElement('css', "ul.messages__list li.messages__item em:contains('some dumb text')");
$this
->assertNotNull($placeholder_text, 'A callback successfully echoed back a string.');
$this
->drupalGet('ajax_validation_test');
$page
->fillField('drivernumber', '12345');
$page
->findField('spare_required_field')
->focus();
$placeholder_number = $assert
->waitForElement('css', "ul.messages__list li.messages__item em:contains('12345')");
$this
->assertNotNull($placeholder_number, 'A callback successfully echoed back a number.');
}
}