Skip to content
Get Free Trial

Sahi Script Overview

Sahi Script is the scripting language of Sahi Pro. Its built-in functions, formerly called Sahi APIs, find elements with accessors, act on them, check results with assertions, and work with data, files, logs and screenshots.

A Sahi script is a .sah file of steps. Each step calls one of Sahi’s built-in functions, which cover:

  • Accessors, which find elements on the screen, such as _link("Login") or _textbox("user").
  • Actions, which act on those elements, such as _click or _setValue.
  • Assertions, which check results, such as _assertExists or _assertEqual.
  • Everything else a test needs: reading data from Excel, CSV files and databases, working with files, logging, taking screenshots, calling REST APIs and controlling how a script runs.

Most tests do not need code. Build them in the No-Code Test Editor, described in Using Sahi. Use Sahi Script when you want to:

  • Keep working with scripts you already have, for example from Sahi Pro Classic.
  • Write a test faster in code, or have an AI assistant write it for you.
  • Do something the Editor does not cover, such as calling Java, reading a PDF or connecting over SSH.
_setValue(_textbox("user"), "test");
_setValue(_password("password"), "secret");
_click(_submit("Login"));
_assertExists(_link("Logout"));

Each line finds an element with an accessor function (_textbox, _password, _submit, _link) and acts on it or checks it with an action or assertion function (_setValue, _click, _assertExists).

If you want to Read
Have an AI assistant write or fix scripts Write Scripts with AI
Write scripts that are reliable and easy to maintain Best Practices
Learn the language Sahi Scripting Basics
Look up a function Function Reference