18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

Sahi scripts reusability

JithinJithin Members
edited November -1 in Sahi - Open Source
Please suggest some tips for increasing the re-usability of the sahi scripts and reduce the script size.

Thanks

Comments

  • Hi Jithin,

    Firstly, to reduce the script size, use functions in the scripts. Though this will not reduce the size of the script, it will definitely make it more readable. If some functions are common, keep them in some functions.sah file and include that file in your scripts.

    For re-usability, mostly the websites are not very similar to each other, but there may be some common features. Then also the identifiers can be different. I would mostly record the scripts using controller and then refactor then for my particular project to avoid small mistakes that may waste time.

    Thanks,
    Vivek
  • facilosfacilos Members
    edited October 2012
    Hello,

    I recommend that you know the concepts of test automation.
    Read about "datadriven", "keyworddriven" and "Frameworks" and think of creating code routines that handle generically actions on applications under test.

    Do not leave a link because I can not, but google search "automatedtestinginstitute" and read about frameworks.

    The true test automation scripts no longer use.

    function example: Is this function I am using the Click. This function gives click any button in any application.


    function Click($valor_1,$lid_caso,$lrsCtr){
    try{
    if ($Dato[$Des]!="N/A")
    {
    var $Objeto = ValorObjetoMysql ($lFunc,$Des);
    var $Obj=CreaObjeto($Objeto["Obj_Id"]);
    _setGlobal("ControlE", $lrsCtr["Ctr_Id"]+","+$lid_caso+","+$lCiclo);
    var $Tipo=$Des.split("_");
    if ($Tipo[0]=="Btn"){//Valida el tipo de objeto
    _highlight($Obj);
    }
    _focus($Obj);
    _click($Obj);
    var $lruta=TomarImagen($lFunc, $lCiclo);
    }
    }catch(e){
    _logExceptionAsFailure(e);
    }
    }

    Good luck

    Oscar C (Facilos)
Sign In or Register to comment.