How to get a window with certainty without using the id automation

718 views Asked by At

In my application I want to make sure that a window is visible to continue an automation scenario. Now, the application has more than one window that does not have a name. Is there a way to recover a window with certainty? Control_id is not usable for me, so I don't see any solution unless using automation id.

For more information:

panel.get_properties()
Out[37]: {'exstyle': 65536, 'rectangle': <RECT L827, T79, R1017, B527>,     'is_unicode': True, 'control_id': 197612, 'fonts': [<LOGFONTW 'MS Shell Dlg'    -11>], 'client_rects': [<RECT L0, T0, R190, B448>], 'context_help_id': 0, 'friendly_class_name': 'WindowsForms10.Window.8.app.0.33c0d9d', 'is_visible': True, 'control_count': 3, 'is_enabled': True, 'texts': [''], 'menu_items': [], 'class_name': 'WindowsForms10.Window.8.app.0.33c0d9d', 'style': 1442840576, 'user_data': 0}
1

There are 1 answers

0
Vasily Ryabov On

There are many possible criteria for window search disambiguation. If no names are available, you still have found_index or parent criterion. Example:

# find the second button with empty title
app.MainWindow.child_window(title="", control_type="Button", found_index=1).click()

# find the button under the group box
#  (may work in master branch only because of known bug in 0.6.0)
app.MainWindow.child_window(title="", class_name="Button", parent=app.MainWindow.GroupBox1).click()

All possible keywords are listed in find_elements() function.