Guide to asserting on complex application state with Momentic’s AI
Category | Example |
---|---|
Presence (or absence) of text | A congratulations message is shown in the modal |
Presence (or absence) of elements | The page shows 3 search results |
Logical statements | The publish date of this article is more than 30 days ago |
Page state | There is no error message present on the page |
Color | The buy button is blue |
Layout | The ‘XL’ button is the largest button in the submission form |
Images & video | There is a LinkedIn icon on the page |
Category | Bad example | Alternative |
---|---|---|
Malformed assertion | Search results | There are search results displayed on the main body |
Ambiguous assertion | The order of the results is correct | The search results are sorted by date |
Multiple focuses in a single assertion | The logo is blue, the page shows 4 results, and the last result is more than 30 days old | Split into 3 separate assertions |
Assertion contains an action | Wait for the results to appear | Use a wait step if necessary, and then assert that the results have appeared |
Assertion about imperceivable details | The color of line divider is #ff5733 | The color of the divider looks red |
Subjective assertion | The page looks well designed | No text in the table overflows its cell |
Assertion depends on changes over time | The video plays a 10-second advertisement for an insurance product | N/A |
john@@gmail.com
” but the actual username is john@gmail.com
, the AI will pass the assertion since the test author likely typed an extra @
. If your test genuinely relies on a small, single-character difference, explicitly state this and use single quotes around the text value (e.g. “the username is exactly ‘john@@gmail.com’). If you are generating test data, we recommend creating long, distinct values using JavaScript functions like crypto.randomUUID()
or faker.word.words(3)
.{{}}
expressions, but we recommend using a JavaScript step to evaluate assertions that do not depend on the page state (e.g. mathematical calculations).document.body.style.zoom
manually using JavaScript.