Assertions

Why add assertions?

Use assertions to observe if everything works as it should.
An assertion is a check that does not interact with your page, for example, you can check if your page shows a specific text without clicking anything.

Types of assertions

Choose from one of the following types of assertions. We are regularly adding more types of assertions to this list - please contact us if you need to have a new type of assertion.
Type of assertion
What happens
Element is visible
BugBug checks if the element is actually visible on the screen, if the element is not covered or scrolled outside of the viewport
Element has text
BugBug checks if the element is visible, but also checks if it has a specific text
Form field has value
BugBug checks if any form input has a specific value, for example, you can check if your radio buttons group is selected to "No" after the user clicks "No" button
Custom JavaScript
Run any JS function and if it returns true, the assertion is passed - learn more in custom javascript actions

Advanced assertions editing

By default BugBug records assertions that check if the element is visible or it contains a specific text. But you can also create advanced assertions, such as checking if a number is greater than some specific value. Select options from the dropdown menu to perform a more thorough check of your test case.
Assertion property
Use it when
value
You want to check if the value of the form element matches specific conditions. Only works with form elements like input, select, checkbox, radio, etc.
text content
You want to assert the text in an element, for example, if a registration button contains a "Sign up" text. This is the most common type of assertion.
custom Javascript
You need to do an advanced assertion, ex. comparing the element text with variables, making an API request, or using localStorage. When your JS function returns true, the assertion will be marked as passed. Also see custom JS actions
count
You want to check the number of elements that match a given selector, for example, you want to assert that a list shows 10 elements
visible
You want to check if an element is visible, meaning that it's in the viewport, opacity is not 0, and its visibility is not set to hidden. For example, you can assert that some error message is shown and visible to the user.
not visible
You want to check if an element is not visible
exists
You want to check if an element exists in the DOM (HTML structure), but not necessarily must be visible
not exists
You want to check if an element is not present in the DOM (HTML structure), ex. you want to make sure that some element disappeared completely from the page and it's not just set to "display: none"
checked
You want to check if a checkbox or radio button is checked, meaning that it is selected, enabled
not checked
You want to check if a checkbox or radio button is unselected, unchecked
Copy link
On this page
Why add assertions?
Types of assertions
Advanced assertions editing