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.

[Bug] function call in _assert() message and linebreak

globalwormingglobalworming Moderators
edited May 2011 in Sahi - Open Source
Hi

i just discovered some misbehavior

function someFunction($string){
return $string;
}
_assertNotExists("something", "Here i want" + someFunction("this string"));

this works well when testing in the record tab of the sahi controller, but when I playback this piece of code, it says :
"ReferenceError: someFunction is not defined"

Additionally, when the message in the assert gets to long to fit my editor, I add a linebreak

_assertNotExists("something", "Here i want" +
"a long string to be diplayed);

This also only works in the testfield of the record tab, but will on playback say: missing ";"
I think that testfield and playback should behave equally, or am I doing something wrong?

Regards
Wormi

Comments

  • narayannarayan Administrators
    Hi Wormi,

    1) You need to do
    <browser>
    function someFunction($string){
          return $string;
    }
    </browser>
    _assertNotExists("something", "Here i want" + someFunction("this string"));
    

    Have a look at the parsed script (from the Controller) to see why this is needed.

    2) The parser of Sahi is not very sophisticated; so statements with actions APIs should be in a single line.


    You could break it down like this:
    var $msg = "Here i want" + 
                          "a long string to be diplayed";
    _assertNotExists("something", $msg);
    


    Regards,
    Narayan
  • globalwormingglobalworming Moderators
    Thanks Narayan

    I rarely look at the parsed script, kinda confusing :)
    Thanks for your advice.

    Regards Wormi
Sign In or Register to comment.