Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, windows and java based applications. Get your 30 day free trial.

Discuss your Sahi Pro usage patterns, best practices, problems and solutions. Help others solve their problems and seek help from the community when needed. If you need specific support on your application, please email support @ sahipro.com

Verifying disability of the button by Java version of Sahi

SadanaSadana Members
edited July 2013 in Sahi - Open Source
Hi!

I have read many solution about how to check if the element is disabled or enabled. Those looks easy and nice to do, but so far I haven't been able to do the verification in my environment. As in the title I have said I'm using Java version, so any javascript/speudo is not clear enough for me.

When the element is disabled it looks like:
<a id ="saveButton" ng:click="storeForm()" attribute="formbuttons.labelSave" ng-disabled="!isChanged()" class="button" href disabled="disabled">Save</a>

When the element is enabled only text " disabled="disabled" " disappears.

I am able to find and use the element by
browser.byId("saveButton")

But so far I haven't been able to verify is it disabled or no. Any idea how I can get that disabled information in Java environment?

Answers

  • Hi Sadana,

    Try using the following code:
    browser.button("your_button_id").fetch("disabled")
    

    Regards.
  • SadanaSadana Members
    Browser.button("saveButton") doesn't work in this case because my button is not type Button. If I'm trying that I will get error
    "TypeError: _sahi._button(...) is undefined".

    If I'm using
    browser.byId("saveButton").fetch("disabled")
    then I'm getting all the time value NULL even disabled exists.
  • Pratyush_TytoPratyush_Tyto Members
    edited July 2013
    Hi Sadana,
    Are you trying to get the "disabled" property of a hyperlink?
    you can try using the following code:
    browser.byId("saveButton").getAttribute("disabled")
    

    Regards.http://sahi.co.in/forums/discussion/comment/17699#
  • SadanaSadana Members
    I will try that getAttribute when our helpdesk will install the new version of Sahi. Currently I don't have it in my environment.
  • Please let me know whether that works for you.

    Regards.
  • I forgot earlier to say that button is in fact hyperlink.

    I have now tried this case again in my next problem button and still I'm not able to get things to work correctly.
    Here's the code I tried when the button was disabled.
    browser.link("Text of Button").fetch("disabled")
    browser.link("Text of Button").getAttribute("disabled")
    

    First line returns value null.
    The second line returns value undefined.

    If the button is not disabled then the clicking of button will work.
    browser.link("Text of Button").click();
    
Sign In or Register to comment.