Ask a Question

How to check if a button is Clickable

SOLVED
testbuilder
Contributor

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??

6 REPLIES 6
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

 

 

Reshail
Contributor

Hi,

Enabled is the property used for buttons in test complete to check their state. Maybe a bit more detail would allow someone to help you out. 

 

Reference to doc: https://support.smartbear.com/testcomplete/docs/app-objects/specific-tasks/standard/button/checking-...

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".


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
AlexKaras
Champion Level 2

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.

 

Regards,
  /Alex [Community Champion]
____
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
sonya_m
SmartBear Alumni (Retired)

Thanks everyone. Great insights.

 

@testbuilder please mark the best answer as a solution here🙂


Sonya Mihaljova
Community and Education Specialist

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. 

cancel
Showing results for 
Search instead for 
Did you mean: