How to Check if Button is Clickable or Not

Environment: User desktop application (exe).

What needs to be accomplished:
Adding error handling, where if an inactive button is clicked the robot show message like “The button is unclickable now”.

Problem:

  1. When trying to click an unclickable button, there is no error threw by robot (means the click itself was successful, but no action is done).
  2. Tried inspecting the buttons, the panels, even other elements and windows possible with UiExplorer, found no difference with the selectors whether the button is clicked or not. Same name, same class, same parent name class and no other specific attributes (how come?)
  3. The only difference I noticed was the button appearance (the text was black when clickable and grey when unclickable) but I would like to prevent doing image compare (and since the only appearance difference was the subtle text color, I’m afraid it will be very difficult to do so)

Does anyone have any idea what to check/try in this kind of case?

Hi @whyyouandi
I tried and fixed this issue.
Using Image Exists activity and set Accuracy 1 before any Click activity.

Note that: if Accuracy is 0.8(default), UiPath robot regards the button is enable even if disable.

Thank you for you advise, but I’d like to avoid any image recognition is possible (reason stated in the question) :wink:

Did you compare aastate or disabled attributes as well? Usually they change when the button is enabled or disabled. You can get these values using Get Attribute.
image

6 Likes

Thank you @vvaidya for your response ^^
Will try it as soon as I get access to the app, and tell you how it works.

Hi @vvaidya
I tried your solution Get Attribute activity, but I can’t find which attribute means Disable in Windows Forms apps.
It seems we can know attribute values only within selector attributes finding in UiExplorer.
e.g. ctrlname

For example I set attribute name is “disabled”
getAttribute

Good way is to check which value is changing when the button gets enabled.

What do you get for aastate? If possible paste the screenshot of attributes.

Thanks,
Vinay

Hello @vvaidya. Checked it, and worked in my case!
The “aastate” attribute value changed when the button is inactive.
Thank you !

Just wondering, how do get all the list of the properties like in your screenshot? While using Get Attribute I have to specify the attribute name. Is there anyway to get all available attributes?

キャプチャ

2 Likes

You can view them in UiExplorer.

If you want everything I think you can do( did not check befor)

StrAttributes = String.Join(Environment.Newline, elementName.Atrributes)

Thanks,
Vinay

1 Like