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.

Check for disabled elements...

adsads Members
edited November -1 in Sahi - Open Source
Here I have an Issue like the disabled elements(text box,button) is not getting verified.

Tried with _assertTrue(_textbox("name").disabled);for disabled text box
_assertTrue((!_div("Create[3]").disabled);for enabled button.

But failed with both...Is there any other Browser Action API's for checking with disabled

button and text field.

Comments

  • narayannarayan Administrators
    Hi ads,

    There is no concept of disabled for divs. The property disabled is only available for textboxes, textareas and a few other form fields. It is possible that you are looking at a readonly textbox. In that case look for
    _assertTrue(_textbox("name").readonly);

    The button seems to be custom component. It may have some other property which shows it as disabled. Look at its css className to see if there is "disabled" in it.

    Eg.
    _alert(_div("Create[3]").className);
    _assert(_div("Create[3]").className.indexOf("disabled") != -1)

    Regards,
    Narayan
  • adsads Members
    Hi Narayan,

    Tried with
    _assertTrue(_textbox("name").readonly); for text box but failed for disabled.

    Yes the button is a custom component.But there are no properties in class which shows as

    disabled.Here it is calling a Js file for disabled which in turn is calling a class and switiching with

    enabled/disabled values.

    Checked with _alert(_div("Create[3]").className);

    which alerts undefined for all classes.

    <div class="buttons">
    <div class="buttonsLeft">
    <div id="chkBut" class="buttonoff" onclick='DeleteValidate(this);'>
    <div class="buttonLoff"></div>
    <div class="buttonCoff">Delete</div>
    <div class="buttonRoff"></div>
    </div>
    </div>
    </div>

    Is there any way out?

    Regards,
    Ads
  • narayannarayan Administrators
    Ads,

    You will just have to figure out the correct (parent/child) element which has the disabled css attribute/className.

    If you can share the URL we may be able to help you better.

    Regards,
    Narayan
  • adsads Members
    Hi Narayan,

    Yes while disabled the div button is alerting with buttonCoff class.
    buttonCoff {
    text-align: center;
    height: 18px;
    background: url(button_c.gif) repeat-x center;
    float: left;
    color: #DADADA;
    min-width: 50px;
    }

    But here in this class there is no disabled property .While I have a color property which is "#DADADA" when disabled.
  • narayannarayan Administrators
    Well, then just assert that the element has that particular className which signifies that it is disabled. May be

    _assertEqual("buttonCoff", _div("Delete").className);

    You need to ask your developer about it, or some body who understands your application.

    Regards,
    Narayan
  • adsads Members
    Hi Narayan,

    Thanks for the suggestion..Yes it worked out fine.Since its calling one class for enabled and some
    other for disabled.

    But for the textbox case its failing for disabled with

    _assertTrue(_textbox("name").readonly);

    Is there any solution?
Sign In or Register to comment.