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.

Does _click() function returns a successful/failure value?

edimistraedimistra Members
edited November -1 in Sahi - Open Source
Hi,

I'd like to know if _click() function returns a successful/failure value and how can I capture it.

Thanks

Comments

  • DonnaMooresDonnaMoores Members
    edited March 2009
    I use the technique shown below. In the catch part of the code you can do whatever kind of corrective action you wish.

    See http://sahi.co.in/w/exception-handling
    <browser>
    function getButton($control)
    {
        try
        {
            return _button($control);
        }
        catch(e)
        {
            _log("getButton Failed: " + $control, "failure");   // Logs the exception, and fails, 
                                                                                        // and in the logs, points to the original line as source of failure.     
        }
    }
    </browser>
    
    
    function clickButton($popupName, $buttonName)
    {
        try
        {
            if ($popupName == null)
            {
                    _click(getButton($buttonName));
            }
            else
            {
                    _popup($popupName)._click(getButton($buttonName));
            }        
        }
        catch (e)
        {
            Logout(); // Corrective action
            _log("clickButton Failed: " + $buttonName, "failure");   // Logs the exception, and fails, 
                                         // Logs the exception, and fails, 
                                         // and in the logs, points to the original line as source of failure.     
        }
    }
    
  • Thanks DonnaMoores, I've resolved using try/catch statements and works fine!!
Sign In or Register to comment.