Please note that Sahi's development and support teams do not actively monitor this. This is more a community forum. If you are a Sahi Pro user looking for commercial support, please email support @ with your query.

Using suites to drive component level sah files (not end to end tests)

RensterUKRensterUK Members
edited 10:31AM in Sahi - Open Source

As part of our ongoing investigation into Sahi, it seems likely that we might want to create something like:

Login.sah - a script to start the browser, and login as a specified user/password
Navigate.sah - a script to click a short sequence of links to get to a given page
DostuffHere.sah - there would be a number of scripts along these lines, each aimed at testing the navigated-to page
Lougout.sah - click logout, and close the browser

This of course, is as opposed to having a single "Dostuffhere.sah" that does the login, navigate, and logout itself.

I know that Suite entries obviously look a bit like:
test.sah urltostartat

Is there a way to have a test.sah that contains something like:
Login.sah username password
Navigate.sah firstlink secondlink thirdlink
DostuffHere.sah param1 param2 param3 etc




  • narayannarayan Administrators

    What you need are parametrized functions. Here is an example:
    function login($username, $password){
        _setValue(_textbox("user"), $username);
        _setValue(_password("password"), $password);
    function addBooks($numJava, $numRuby, $numPython){
        _setValue(_textbox("q"), $numJava);
        _setValue(_textbox("q[1]"), $numRuby);
        _setValue(_textbox("q[2]"), $numPython);
    function verifyTotal($total){
        _assertEqual($total, _textbox("total").value);    
    login("test", "secret");
    addBooks(2, 1, 1);

  • Narayan,

    Thats fine, but in time we would have a huge number of functions, such as login for example would be common across many tests - and so we would need to create funtion libraries.

    Is it possible to just do a sort of "include commonfunctions.sah" - or did I read somewhere that each and every function in such a library would need declaring? If so, can you point me to a link on how this is done?!

    Many thanks again for your help - you're a star!

  • narayannarayan Administrators
    Hi Steve,

    You can move all the common functions into another file and just include it using _include.

    Have a look at this: and

    You do not need to declare them explicitly. You just need to include your commonfunctions.sah wherever you need those functions.

  • Fab stuff,

    Thanks again Narayan!

Sign In or Register to comment.