Forum Discussion

shiva_ranabhat's avatar
shiva_ranabhat
Contributor
9 years ago
Solved

Button.Enabled returning True for disabled button

Hi, 

 

I'm having a trouble checking if a button is disabled or not. Please see the attached image for details  (script, gui & test Log). 

Usually this feature works fine but not this time.

 

Thanks in advance,

Shiva

  • Hi Shiva,

     

    Welcome to the 'creative' world of web development... :)

    Like all other guys have already said, there are usually a lot of ways to do this or that thing with the web object and different approaches might be used within the given tested web application depending on development team, used libraries, etc.

    For example, the object may have .Visible property set to True, but be invisible on the page because: its height or width is set to zero; or because some class or style is applied to it (or its parent) that makes it not visible; or because one of its parents is not visible; or...

    Note, that the opposite is also correct: if the parent of some object is not visible (or disabled) this does not necessarily mean that the object itself is not visible (or disabled) as well. So web test code should not rely on the parent's properties, but also check actual properties of the object itself.

7 Replies

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi Shiva,

     

    Welcome to the 'creative' world of web development... :)

    Like all other guys have already said, there are usually a lot of ways to do this or that thing with the web object and different approaches might be used within the given tested web application depending on development team, used libraries, etc.

    For example, the object may have .Visible property set to True, but be invisible on the page because: its height or width is set to zero; or because some class or style is applied to it (or its parent) that makes it not visible; or because one of its parents is not visible; or...

    Note, that the opposite is also correct: if the parent of some object is not visible (or disabled) this does not necessarily mean that the object itself is not visible (or disabled) as well. So web test code should not rely on the parent's properties, but also check actual properties of the object itself.

  • dmiscannon's avatar
    dmiscannon
    Frequent Contributor

    I tried your code against a webpage with a disabled button and it worked fine. Have you checked the Enabled property of the buttonExcelXls button to see what it shows when it is diplaying as disabled? Is it possible that the button displays as disabled but has a Enabled property of True?

    • Colin_McCrae's avatar
      Colin_McCrae
      Community Hero

      Check with your dev team.

       

      They may be using some weird method and styling to prevent the button being used rather than the enabled property.

      • Blur's avatar
        Blur
        Contributor

        My dev team does what Colin said.  Half the time the buttons are enabled but just size 0 or some other odd methods.