protected function MediaLibraryTestBase::pressSaveButton in Drupal 10
Same name and namespace in other branches
- 8 core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTestBase.php \Drupal\Tests\media_library\FunctionalJavascript\MediaLibraryTestBase::pressSaveButton()
- 9 core/modules/media_library/tests/src/FunctionalJavascript/MediaLibraryTestBase.php \Drupal\Tests\media_library\FunctionalJavascript\MediaLibraryTestBase::pressSaveButton()
Clicks "Save" button and waits for AJAX completion.
Parameters
bool $expect_errors: Whether validation errors are expected after the "Save" button is pressed. Defaults to FALSE.
File
- core/
modules/ media_library/ tests/ src/ FunctionalJavascript/ MediaLibraryTestBase.php, line 246
Class
- MediaLibraryTestBase
- Base class for functional tests of Media Library functionality.
Namespace
Drupal\Tests\media_library\FunctionalJavascriptCode
protected function pressSaveButton($expect_errors = FALSE) {
$buttons = $this
->assertElementExistsAfterWait('css', '.ui-dialog-buttonpane');
$buttons
->pressButton('Save');
// If no validation errors are expected, wait for the "Insert selected"
// button to return.
if (!$expect_errors) {
$result = $buttons
->waitFor(10, function ($buttons) {
/** @var \Behat\Mink\Element\NodeElement $buttons */
return $buttons
->findButton('Insert selected');
});
$this
->assertNotEmpty($result);
}
// assertWaitOnAjaxRequest() required for input "id" attributes to
// consistently match their label's "for" attribute.
$this
->assertSession()
->assertWaitOnAjaxRequest();
}