AI Steps and Checks
Reference for the high-level AI methods ai.step()
and ai.check()
used within Magnitude tests.
The ai
object provided in the test function context allows you to interact with the application using natural language. The primary methods for this are ai.step()
for performing actions and ai.check()
for verifying outcomes.
ai.step(description, options?)
Executes one or more browser actions based on a natural language description. Magnitude interprets the description and determines the necessary interactions (clicks, types, scrolls, etc.).
A natural language description of the action(s) to perform. Can include placeholders like {key}
which will be substituted by values from options.data
.
Optional parameters for the step.
For sensitive data (passwords, API keys), use environment variables or secure vaults and pass the values into the data
object (e.g., data: { password: process.env.SECRET }
). Do not hardcode sensitive information.
ai.check(description)
Verifies that a certain condition holds true on the web page based on a natural language description. The AI evaluates the description against the current page state (DOM, visibility, text content).
A natural language statement describing the expected condition or state to verify.