Forum Discussion

testbuilder's avatar
testbuilder
Contributor
4 years ago
Solved

How to check if a button is Clickable

There is a List of names in a table with pagination on my web page  with Previous and Next buttons. 

Each page displays 5 results

If there are less than or equal to 5 pages-> Next button is disabled.

I was trying to write a test to see if the button is clickable or not->if it is clickable then Click on it , if not no action

I was trying to use properties Enabled but Enabled always gives me True not matter if the button is disabled or not.

I have tried the following properties. None of them seemed to help:

1. Enabled

2. Disabled

3. IsDisabled

are there any other properties which could help me differentiate if a button is clickable or not?

I could think of a way to see if button has a link /url behind it but it does not seem to be working as well

 

Any suggestions??

  • Hi,

     

    Like Robert wrote...

    Web applications are extremely inconsistent and may use dozens of different techniques within the same application to do the same thing: set element itself as disabled, set its parent as disabled (or parent of the parent, or...), change applied class during runtime, ...

    The most easy and effective way to answer your question is to ask developers about how this button is disabled.

    If developers are not accessible then you will have to spend your time investigating differences between the enabled and disabled button (and its parent(s) ) in the Object Browser to find out the proper indicator.

     

6 Replies

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    Like Robert wrote...

    Web applications are extremely inconsistent and may use dozens of different techniques within the same application to do the same thing: set element itself as disabled, set its parent as disabled (or parent of the parent, or...), change applied class during runtime, ...

    The most easy and effective way to answer your question is to ask developers about how this button is disabled.

    If developers are not accessible then you will have to spend your time investigating differences between the enabled and disabled button (and its parent(s) ) in the Object Browser to find out the proper indicator.

     

    • sonya_m's avatar
      sonya_m
      SmartBear Alumni (Retired)

      Thanks everyone. Great insights.

       

      testbuilder please mark the best answer as a solution here🙂

      • Vars01's avatar
        Vars01
        Occasional Contributor

        testbuilder 

        Hi, I am also facing the same issue which u mentioned. How did u solve it? Could you please help me with the same. 

        On first page my property is class = "ui-paginator" and last page the property is class = "ui-paginator disabled".

         

        How did you put the loop which doesn't go in infinite. I have used do-while loop so that even through condition is false it should run once. 

  • Wamboo's avatar
    Wamboo
    Community Hero

    Are You use nameMapping?

     

    If naswer is yes then remember to refreshMappingInfo() ob specific object before use property.

     

    "I was trying to use properties Enabled but Enabled always gives me True not matter if the button is disabled or not"

     

    NameMapping is the period of time when the object was assigned to e.g. a variable. If the state of an object changes during a program operation, you have several options:

     

    1. you can read its state directly from the "Object Browser", i.e. you can view the elements declared in the memory of the system in use

     

    2. you refresh the condition of the mapped object and use it

     

    3. you search for the item again with a function such as findxxx() and have a "fresh" object to work on

     

     

    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      One of the things I've found is that, especially if it's a web application you're testing, the button ITSELF may not be marked Enabled = false but a parent container object.  You might need to look further up the hierarchy to find what is doing the actual "disabling".