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.

using a wrapper for sahi api

Rams0727Rams0727 Members
edited November -1 in Sahi - Open Source
i have a written a wrapper class (SahiWrapper.sah) for all the sahi apis like as follows..

function setValue($element, $text)
{
_setValue($element, $text);
}

function textbox($identifier,$domRelation)
{
_textbox($identifier,$domRelation);
}

I have included this SahiWrapper.sah in my function and i'm trying to use the script as follows

setValue(textbox("loginId"), "HRD");

1. If i use like this the outer most wrapper for setvalue is working fine.
2. But the wrapper for the inside function "textbox" isn't working.
3. It recognizes like this as follows
_setValue(null, "HRD");
4. It is not recognizing the wrapper inside a wrapper.
5. I want to know is there any method to use the wrapper for all the Sahi APIs

Awaiting response as this is very important and urgent....

Comments

  • narayannarayan Administrators
    Hi Rams0727,

    1) Writing wrappers almost never serves any useful purpose.
    2) You need to return the element correctly in your wrapper APIs.

    function textbox($identifier,$domRelation)
    {
    return _textbox($identifier,$domRelation);
    }

    Regards,
    Narayan
  • Thanks narayan...
    its working now...
    but may i know the reason why it would be of no use...
  • I discovered some strange things too..
    function assertContainsText($text, $el, $log){
      _assertContainsText($text, $el);
    }
    
    is working but
    
    function assertContainsText($text, $element, $log){
      _assertContainsText($text, $element);
    }
    is not 
    

    our wrappers are supposed to automatically log a human readable action. Not everyone understands asserts ;-) So a little automatically generated text logs a understandable message when doing asserts.
Sign In or Register to comment.