Skip to content
Get Free Trial

Create Your First Test Scenario

Create a project, a scenario file, a test case and keywords, then record, run and edit your first test in Sahi Pro.

In Sahi Pro, a test case is made of keywords, and each keyword holds its steps. You record each keyword’s steps once, then reuse the keyword in other test cases.

This is how Sahi Pro is built to work, called Business-Driven Test Automation (BDTA). You first describe the test in business terms, as keywords, and then automate each keyword. You can write the keywords before the application is even ready. On this page, you add all the keywords first, then record their steps.

On this page, you build a test for Sahi’s sample application at https://sahitest.com/demo/training/login.htm. The test logs in, adds books to the cart, checks the total, and logs out.

A project keeps a team’s tests together. Sahi Pro comes with a default project, scripts, which holds example tests you can refer to later.

  1. On the Dashboard, click Test Editor to open the No-Code Test Editor.
  2. Click the project name (scripts) at the top left, then click New.
  3. Name the project sahi_training and click Create.
The No-Code Test Editor on the default scripts project, with the project picker open and New highlighted next to All Projects

A scenario file (.s.csv) holds test cases. A new project comes with a sample one, MyFirstScenario.s.csv, in its Feature directory. To create your own:

  1. Click Create Test Scenario, or click File > New > Scenario File.
  2. Name it books and click Create.
A new, empty project with its sample scenario file in the Navigator and the Create Test Scenario button highlighted

A new scenario file starts with a test case named Default Test Case. You can rename it, or add your own:

  1. Click Add Test Case.
  2. In the Create Test Case dialog, name it Buy Books, add a description such as Log in, add books to the cart, check the total and log out, and click Create.
The Create Test Case dialog with the name Buy Books and its description

The test case needs three keywords: one to log in, one to add books, and one to log out.

  1. Under the test case, click Add Keyword, type Login, and press Enter. A new keyword field opens below it.
  2. Type Add Books and press Enter, then Logout and press Enter. Press Esc to close the empty field.
  3. Select Login. Sahi Pro asks you to confirm the keyword file path, where the keyword’s steps are kept. Keep the suggested file, books.sah, and click Confirm.
The Buy Books test case with the Login, Add Books and Logout keywords, and the panel to confirm the keyword file books.sah

The keywords have no steps yet. You record them in the Controller.

  1. With Login selected, click Automate.

  2. In the Automate with Controller dialog, choose the browser and set Start URL to https://sahitest.com/demo/training/login.htm. Check that Testcase / Global shows Buy Books and Keyword shows Login.

  3. Click Launch Controller. The browser opens at the start URL, and the Controller opens on the Login keyword.

    The Automate with Controller dialog with Google Chrome, the sample application URL, books.s.csv, Buy Books, Login and books.sah
  4. In the Controller, click Record. The status changes from idle to Recording.

    The Controller on the Login keyword of Buy Books, with the Record button highlighted
  5. In the browser, enter the username test and the password secret, and click Login.

Each action you take in the browser appears as a step in the Controller.

Steps that aren’t saved yet have an orange dot, and the Save icon next to the test case turns orange. Click Save.

The Controller with three recorded Login steps not yet saved, shown by orange dots and an orange Save icon, which is highlighted

A test checks that the application behaves as expected. In Sahi Pro, these checks are assertions, and you can add them while you record.

  1. In the Controller, choose the Add Books keyword.

  2. In the browser, enter the quantities 2, 3 and 1 for Core Java, Ruby for Rails and Python Cookbook, and click Add. The cart shows the books and the total, 1550.

  3. To check the total, open the Controller’s Advanced Editor tab.

  4. Hold Ctrl (⌘ on Mac) and hover over the total field in the browser. The Controller fills in Element Accessor.

  5. Under Quick Actions, choose Assert Equal. Set Value to 1550.

  6. Click Evaluate Step to check that the assertion passes, then click Add as Step.

The Advanced Editor tab with the total field's accessor filled in, Assert Equal selected, the value 1550, and the Add as Step button, both highlighted
  1. In the Controller, choose the Logout keyword.
  2. In the browser, click Logout.
  3. Click Stop Recording, then click Save.

All three keywords now have their steps.

In the Controller, hover over Run and choose Run this testcase. Sahi Pro runs the whole Buy Books test case, keyword by keyword, and shows each step’s result.

The Run menu has other options too, such as running only the current keyword, or running up to it.

The Controller on the Add Books keyword with the Run menu open and Run this testcase highlighted

Every test run creates a report. When the run finishes, click Reports, the second icon from the left in the Controller’s bottom bar. The report shows each keyword and step, and the result of your assertion.

You can also open Reports from the left bar of the No-Code Test Editor, where the latest test runs are listed first.

The report for books.s.csv: the Buy Books test case passed, with Login, Add Books and Logout, and the steps of Add Books

You can change a keyword’s steps without recording it again.

  1. In the Controller, choose the keyword.
  2. Click a step. It opens as Edit Step, where you can change its Action, Element and Value.
  3. Click Update.
  4. To move, copy, disable or delete steps, use the toolbar above the steps. To add one, click Add Step.
  5. Click Save.

Saved changes go to the keyword’s .sah file, so every test case that uses the keyword gets them.

A step of the Add Books keyword open in Edit Step, with Action, Element and Value, and the Update button highlighted

A scenario file can hold many test cases, and they can reuse the same keywords.

  1. In the No-Code Test Editor, click Add Test Case and name it, for example, Buy One Book.
  2. Add the keywords Login, Add Books and Logout, picking them from the list as you type.

You can run one test case, or the whole scenario file.