Skip to content
Get Free Trial

Best Practices

Writing a test is quick. Keeping hundreds of them working as the application changes is the hard part. These practices keep a large suite easy to maintain.

  • Keep each team’s or application’s tests in their own project.

  • Use Business Driven Test Automation as much as possible. Thinking about the business first leads to much cleaner and maintainable test automation suites.

    • In the No-Code Test Editor, create a scenario file and add test cases. Ensure that keywords express business intent.
    • Record each keyword in the Controller. AI Suggest (beta) can also author the keyword for you.
    • While recording, use an Accessor Repository: in the Controller, open File Settings and turn on Enable AR, then use Update in AR to save an element’s accessor. For an application with a lot of elements, create one AR file per module, so each file stays easy to find your way around. Keep each element in one AR file only. The intent is to have a single place of modification in case an element identifier changes.
    • Follow a naming convention for files, keywords and parameters. Name keywords in Title Case, such as Add Books To Cart. Sahi Pro names the function behind it, AddBooksToCart.
    • Keep keyword files (.sah) per module, with a common file for shared keywords. If needed, create sub folders for different modules of your application.
    • Attach a test data file with Data Drive to run a test case with several sets of data. See also Parameters and Data Generators.
    • To get a better accessor for an element, choose Run upto this keyword in the Controller, identify the element in the Advanced Editor (anchor it if needed), then click Update in AR.
  • Group scenario files in a test suite (.dd.csv file). Add tags for module, priority, version etc. as needed. See Test Suites for all the options.

  • Run the suite from the Editor’s Run Configuration, or from Ant. The Run Configuration can create the Ant target.

  • Run with Autoheal enabled if the application under test is evolving. Turn it on in the Run Configuration. This will catch and rectify element identification problems and reduce failures.

  • Use Suite Analysis to pinpoint errors in the suite run.

  • Keep each element in one Accessor Repository file, shared by all tests that use it.
  • Create a few simple smoke tests which pass through elements of all pages and assert for their existence.
  • Make sure these smoke tests run with the developers’ Continuous Integration build
  • If these tests fail, the developers need to modify the Accessor Repository file and make the build pass. This ensures that the Accessor Repository reflects any changes that the developer has made to the web application. It also ensures that QA tests fail only for Scenario and flow changes and not for element changes.
  • Write tests aimed at parallel execution. Most tests can run in parallel once they don’t depend on each other’s data.
  • Run your QA builds as frequently as your processes allow (Aim for once a day at least). Tests which have not run for some time invariably become unmaintainable.
  • If you believe you need to build a framework to make things work, talk to our support team. You can save significant time and money by adapting to what is already available. Sahi Pro has been evolving with various customer requirements and we already have most things that you may need. If you need something that isn’t there, tell us.
  • Check in tests into a Version Control System (VCS) such as Git. The Editor has built-in Git. Instead of working on tests in a common shared folder, work on individual versions and use the VCS features like versioning, diff, rollback, merge etc. to your advantage. Data files should also be checked in along with tests.
  • Use file types which allow easy “diff”ing between versions. When a test fails today which passed yesterday, you may pinpoint the error easily by performing a diff with the older file. However diff may only be possible on text based files. So we recommend using .csv format files instead of Excel files.
  • Hire good, thinking testers rather than “automation engineers”. A thinking tester understands the business and how its users work, so they know what is worth testing, which edge cases can break it, and why a failure matters. With Sahi Pro, they don’t need to be programmers to automate those tests.

Build tests in the No-Code Test Editor first: anyone on the team can read and change them, and Sahi Pro handles reports, suites, parallel and distributed suite runs, and reusable keywords for you.

When a scenario needs logic that no-code can’t express, write that keyword in Sahi Script. It is JavaScript, so it needs less programming expertise than Java, and it keeps all of Sahi Pro’s reporting, debugging and suite features. Sahi Script can also call and reuse any Java code or libraries, so you can use the power of Java when needed.

If you use the Java driver without Sahi Pro’s framework:

The Java driver is a bare-bones library that launches a browser and performs actions on it. Everything else a framework needs is then up to you: logging, reporting and storing reports, a UI for historic reports, building suites, running them in parallel or across machines as distributed suite runs, keeping code and test cases separate, and maintaining object repositories or page objects. Sahi Pro already has all of these. If you use the Java driver, use it with Sahi’s scenario files to keep these benefits.