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.

How to test the status of a button

Lou10120Lou10120 Members
edited November -1 in Sahi - Open Source
Hi all,

In my application, I want to test if a button is enabled or disabled (greyed out).

Could anybody tell me which function should I use ?

Thanks in advance.

Lou10120

Comments

  • StringyLowStringyLow Members
    edited September 2008
    How about:

    if (_button("Example").disabled == true) {

    _alert("The button is disabled");
    }


    You'll get a lot more mileage out of Sahi if you understand how the HTML DOM works:

    http://www.w3schools.com/htmldom/dom_reference.asp
    http://www.w3schools.com/jsref/default.asp

    Good luck and keep the questions coming!
  • I use the following for testing if a button is enabled or disabled.
    function assertButtonEnabled($popup, $name)
    {
        if ($popup == null)
        {
                _assertFalse(_button($name).isDisabled);
        }
        else
        {
                _popup($popup)._assertFalse(_button($name).isDisabled);
        }       
    }
    
    function assertButtonDisabled($popup, $name, $space)
    {
        if ($popup == null)
        {
                _assertTrue(_button($name).isDisabled);
        }
        else
        {
                _popup($popup)._assertTrue(_button($name).isDisabled);
        }       
    }
    
    I call the functions like
    assertButton("BrowserDetail", "OK");
    or
    assertButtonDisabled(null, "OK");
    
  • I should take my own advice!

    I wasn't aware there was a "isDisabled" property.

    Thanks Donna!
Sign In or Register to comment.