Skip to main content
2 of 6
added 633 characters in body
Michael Durrant
  • 25.2k
  • 3
  • 41
  • 113

The asserts I commonly use are:

Assert that:

  • An element is present based on a CSS identifier, ideally ID
  • An element is present based on other selectors
  • When a user choose an option that should present a form, a form element is present
  • A form element is correctly not present (e.g. not redisplayed due to error)
  • The correct markup is present after an action is performed
  • An error form has the correct markup and information for validations
  • When I submit a form, application pages then list the new item as added
  • When I delete content as a user, the content no longer shows on the relevant pages

Avoid or be conservative in these assertions because they are brittle, likely to break and require maintenance over time:

  • specific text for large blocks of text or text that is likely to have wording changed
  • specific text in one language when the site serves multiple languages
  • identifiers such as css class which may not be or remain unique
  • identifiers that are overly specific and include page layout
Michael Durrant
  • 25.2k
  • 3
  • 41
  • 113