Skip to main content

Messages

DrevOps\BehatSteps\Steps\Web\MessageTrait - Source, Example, Helpers

Assert status, error, warning and success messages rendered on the page.

  • Match a single message by substring, per message type.
  • Match a table of messages in 1 step.

Each message type resolves to a CSS selector from the message.selectors option, keyed default, error, success and warning. A message matches when the text of any element found by that selector contains the expected string.

Options​

OptionTypeDefaultTagDescription
message.selectorsmap[]-Selectors of the message regions the message steps assert against, one per severity: default, error, success and warning.

Steps​

@Then I should see the message :message

Assert that a status message is present

Then I should see the message "Changes saved"
@Then I should not see the message :message

Assert that a status message is absent

Then I should not see the message "Access denied"
@Then I should see the error message :message

Assert that an error message is present

Then I should see the error message "Username field is required"
@Then I should not see the error message :message

Assert that an error message is absent

Then I should not see the error message "Access denied"
@Then I should see the success message :message

Assert that a success message is present

Then I should see the success message "Article has been created"
@Then I should not see the success message :message

Assert that a success message is absent

Then I should not see the success message "Changes saved"
@Then I should see the warning message :message

Assert that a warning message is present

Then I should see the warning message "This action cannot be undone"
@Then I should not see the warning message :message

Assert that a warning message is absent

Then I should not see the warning message "deprecated"
@Then I should see the following error messages:

Assert that every error message in the table is present

Then I should see the following error messages:
| Username field is required |
| Password field is required |
@Then I should not see the following error messages:

Assert that no error message in the table is present

Then I should not see the following error messages:
| Access denied |
@Then I should see the following success messages:

Assert that every success message in the table is present

Then I should see the following success messages:
| Article has been created |
@Then I should not see the following success messages:

Assert that no success message in the table is present

Then I should not see the following success messages:
| Changes saved |
@Then I should see the following warning messages:

Assert that every warning message in the table is present

Then I should see the following warning messages:
| This action cannot be undone |
@Then I should not see the following warning messages:

Assert that no warning message in the table is present

Then I should not see the following warning messages:
| deprecated |