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.

TryCatch

Cubicle.JockeyCubicle.Jockey Members
edited July 2008 in Sahi - Open Source
Does the try catch block work in Sahi like it does in JavaScript?

This is what I am trying to do I want to wrap the Assert functions so that I can use them in conditional statements.

i.e function wrapper

function assertAreEqual($expectedValue, $actualValue, $logMessage)
{
try
{
_assertEqual($expected, $actualValue, $logMessage);
return true;
}
catch(err)
{
_log($logMessage);
return false;
}
}

the call using the wrapper:

var $something = "A"

if(assertAreEqual($something, $something, "PoopyPants") == "true")
{
_log("It was true");
}
else
{
_log("It was false");
}
problem is the assertAreEqual is always throwing false! ANYONE????

Comments

  • I believe you need to use _condition() when using DOM objects in conditions.

    http://sahi.co.in/w/if-condition
  • lepierrotlepierrot Members
    edited July 2008
    Hi, I have a question concerning your snippet :

    What does "return true"
    _assertEqual($expected, $actualValue, $logMessage);
    return true;
    
    allows you to do in this script ?
  • Ok I think I've understood, I didn't thought about it... that's a good idea in for use the function assertEqual with condition...because until your script, I think _assertEqual (and all similars) didn't returned any boolean...so it was difficult to use with "if" for example...

    Thank you for this idea.
Sign In or Register to comment.