Skip to main content

Assertions

Overview

Assertions are critical components of effective testing. They make tests robust and provide the proper way to determine whether your application is working as expected. Harness AI Test Automation (AIT) supports a variety of assertions that help validate different aspects of your application's behavior.

This section describes each type of assertion available in Harness AIT.

Supported Assertions

Visual Assert

Used for ensuring visual elements display correctly.

FeatureDescription
DescriptionValidates that visual elements display correctly. Used for verifying logos, charts, and other visual components with the same input data. When creating this assertion, select a specific area in the app.
Parameter optionsNone
Advanced optionsSet a threshold that determines the sensitivity of comparison
Return valueTrue or False
Assert Script Success

User Question

Uses AI to verify user questions about the current page.

FeatureDescription
DescriptionUses AI to verify questions about specific pages (e.g., "Am I on the dashboard page?"). Harness AI evaluates the question and returns True or False.
Parameter optionsQuestion: Input your question (ensure it can be answered with True or False)
Advanced optionsNone
Return valueTrue or False
Assert Script Success

Wait for Text

Verifies if specific text exists within a time limit.

FeatureDescription
DescriptionA popular assertion that checks whether text exists within a specified wait time. Allows multiple retries after a specified wait time. Can assert on text embedded in other elements like buttons.
Parameter options• Text: The string to look for Present: Boolean flag to determine whether the text should exist or not
Advanced options• Maximum time to wait in ms: typically 30000• Reload attempts: typically 0• Retry delay in ms: typically 5000• Target picker: used to update the object
Return valueTrue or False
Assert Script Success

Object is Visible

Verifies if a specific object is visible on the page.

FeatureDescription
DescriptionAsserts the existence of a specific object
Parameter optionsTarget picker to select the object
Advanced optionsNone
Return valueTrue or False

Object is Clickable

Verifies if a specific object can be clicked.

FeatureDescription
DescriptionAsserts whether an object is clickable
Parameter optionsTarget picker to select the object
Advanced optionsNone
Return valueTrue or False

Object is Not Clickable

Verifies if a specific object cannot be clicked.

FeatureDescription
DescriptionAsserts whether an object is not clickable
Parameter optionsTarget picker to select the object
Advanced optionsNone
Return valueTrue or False

Script Success

Runs a custom script as part of test execution.

FeatureDescription
DescriptionAllows users to run custom scripts during test execution
Parameter options• Number of attempts: Usually 1• Time between retries in ms: Usually 0• Script content
Advanced optionsNone
Script TypeJavaScript or Puppeteer
Return valueTrue or False
Assert Script Success

Harness AIT supports two types of scripts:

  • JavaScript - Use when you want to write a script based on data displayed in your browser. For example, find and delete an element based on a specific string.

  • Puppeteer - Use when you need to access data outside the browser. For example, verify whether the size of a file downloaded by a Click is greater than 0 bytes.

URL Assert

Verifies if the current URL matches expected criteria.

FeatureDescription
DescriptionAsserts that the test is on the desired URL
Parameter optionsCan match either the entire URL or part of it using different condition types
Advanced optionsNone
Return valueTrue or False
Assert URL