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.

isDisabled not working

bkobs39bkobs39 Members
edited November -1 in Sahi - Open Source
I'm trying to verify that a button is disabled on a page. I've tried for the past 3+ hours without any luck. It's very weird because I can get it to work when I run the commands through the 'Record' tab of the Sahi Controller, but not through the 'Playback' tab.

I've tried the following:
1) _button("Copy").isDisabled
2) _button("Copy").disabled
3) _button("Update Devices").outerHTML.containsText(/disabled=true/)

When run through the Playback tab with a .sah script, I always get the message: TypeError: Cannot call method "containsText" of undefined.

Please help!

Comments

  • Hi bkobs39,

    Use _call(_button("button").disabled);

    Regards,
    dkulkarni
  • I tried using _call(_button("button").disabled) and _call(_button("button").isDisabled), but unfortunately neither seem to work through the Playback tab of the Sahi controller. Just as before, it works fine when run through the Record tab, but when I try to play it as a Sahi script (.sah file), the command completes, but it always reports the same result - no matter whether the button is enabled or disabled.
  • Hi bkobs39,

    Could you check if your application's button works like the one specified in this link?

    These usages work for the example.
    var $isDisabled = _call(_button("Submit Registration").disabled);
    
    or 
    
    _set($isDisabled, _button("Submit Registration").disabled);
    

    Is it possible for you to point us to an online example, similar to the one in your application?

    Regards,
    dkulkarni
  • Thank you for the reply - that did the trick.

    I ended up using:
    _set($isDisabled, _button("Button").isDisabled);
    if ($isDisabled == true)
    {
    // Button is disabled
    }
    else
    {
    // Button is enabled
    }
  • Hi bkobs39,

    For using DOM variables in conditions, you will need to use the _condition API.
    Refer this for more details.


    Regards,
    dkulkarni
This discussion has been closed.