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.

Problem with customer function

escapeescape Members
edited November -1 in Sahi - Open Source
Hi

I'm testing a web application, to aviode repetition I'm trying to use functions:

function checkMessage($htmlobject, $text)
{
_assertNotNull($htmlobject);
_assertEqual($text, _getText($htmlobject));
_assertContainsText($text,$htmlobject);
}

this functions looks good to me, but with the following call "checkMessage("<objectname>", "<text>"); " I'm getting this error:

_assertEqual("sometext", _getText("_cell(_table(8), 0, 0)")); Assertion Failed. Expected:[sometext] Actual:[undefined]
_assertContainsText("sometext","_cell(_table(8), 0, 0)"); TypeError: 'undefined' is Null

I think in case of _getText, there are problems with " " . it should be _getText(_cell(_table(8), 0, 0)) . Is there a workaround or a better solution?

thanks for help

best regards

escape

Comments

  • narayannarayan Administrators
    $htmlobject seems to be a string in your case.
    Could you show how $htmlobject is declared and how checkMessage is being called?
  • escapeescape Members
    edited February 2008
    Hi

    yes you're right - it is string, because I try to identify the object by name, I'm told to use name instead of id or DOM-Position *o*

    call for checkMessage:

    checkMassege("_cell(_table(8), 0, 0)","verify_this_text")

    So the function _assertNotNull needs an object, is there a function to built this _assertNotNull( < _getobjectbyname("objectname")> )
  • narayannarayan Administrators
    edited February 2008
    You could use something like this:
    _assertNotNull(eval($htmlobject));
    _assertEqual($text, _getText(eval($htmlobject)));
    _assertContainsText($text,eval($htmlobject));
    
    This will work, but I am not sure you are doing the right thing here.

    try this:
    function checkMessage($htmlobject, $text){
      _assertNotNull($htmlobject);
      _assertEqual($text, _getText($htmlobject));
      _assertContainsText($text,$htmlobject);
    }
    
    _call(checkMessage(_cell(_table(8), 0, 0), "verify_this_text"));
    
Sign In or Register to comment.