1

I am trying UI automation using PywinAuto Lib. When I am trying, Multiple UI elements are having same UI Attributes . Is there any way , we can alias and identify what we need.

ControlType: RadioButtonControl    ClassName: RadioButton    AutomationId: checkBox1    Rect: (805, 259, 855, 287)    Name:     Handle: 0x0(0)    Depth: 7    CurrentIsSelected: True

ControlType: RadioButtonControl    ClassName: RadioButton    AutomationId: checkBox1    Rect: (858, 259, 908, 287)    Name:     Handle: 0x0(0)    Depth: 7    CurrentIsSelected: False

As we have see , we are seeing same UI attributes for both the UI elements. One way of deal is, we can go back to UI development and change the things .

But is there any way we can do alias and identify .

selectButton = app1.Dialog.child_window(auto_id="checkBox1",control_type="RadioButton")
selectButton .click_input(button='left')

when we run , we are seeing this error .

pywinauto.findwindows.ElementAmbiguousError: There are 3 elements that match the criteria {'auto_id': 'checkBox1', 'control_type': 'RadioButton', 'top_level_only': False, 'parent': <uia_element_info.UIAElementInfo - 'Ui automation', Window, 339012>, 'backend': 'uia'}
Sreevathsabr
  • 649
  • 7
  • 23

1 Answers1

2

There are few ways:

  1. Using found_index=i in search criteria of child_window.

  2. Using children() but there is very limited number of filter criteria in 0.6.x (planned for future improvements): class_name, control_type, content_only, title.

  3. Using best_match search rules from Getting Started Guide -> How to know magic attribute names (previous chapters are recommended to read as well).

Vasily Ryabov
  • 9,386
  • 6
  • 25
  • 78
  • The Third method worked for me . Thanks alot for help :-) I was able to get the print_control_identifiers and use the alias name of that to do my required function – Sreevathsabr Jan 24 '19 at 02:30