I was trying to use child_window() func to get an element under a parent node but get not found error. Here is the print_control_identifier() output of the parent:
>>> txb_custom.print_control_identifiers()
Control Identifiers:
Custom - '' (L997, T127, R1075, B177)
['PET WBCustom', 'Custom']
child_window(auto_id="textBox", control_type="Custom")
|
| Edit - 'PET WB' (L997, T127, R1075, B177)
| ['Edit', 'PET WBEdit']
| child_window(title="PET WB", auto_id="textBox", control_type="Edit")
| |
| | ScrollBar - '' (L0, T0, R0, B0)
| | ['ScrollBar', 'ScrollBar0', 'ScrollBar1']
| | child_window(auto_id="VerticalScrollBar", control_type="ScrollBar")
| |
| | ScrollBar - '' (L0, T0, R0, B0)
| | ['ScrollBar2']
| | child_window(auto_id="HorizontalScrollBar", control_type="ScrollBar")
|
| Static - 'PET WB' (L997, T150, R1075, B177)
| ['Static', 'PET WB', 'PET WBStatic']
| child_window(title="PET WB", auto_id="textBlock", control_type="Text")
I ran the following code to try to change text in the edit control and got error:
>>> txb_custom.child_window(title="PET WB", auto_id="textBox", control_type="Edit").set_text("test")
Traceback (most recent call last):
File "C:\Program Files\Python38\lib\site-packages\pywinauto\application.py", line 250, in __resolve_control
ctrl = wait_until_passes(
File "C:\Program Files\Python38\lib\site-packages\pywinauto\timings.py", line 458, in wait_until_passes
raise err
pywinauto.timings.TimeoutError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<pyshell#81>", line 1, in <module>
txb_custom.child_window(title="PET WB", auto_id="textBox", control_type="Edit").set_text("test")
File "C:\Program Files\Python38\lib\site-packages\pywinauto\application.py", line 379, in __getattribute__
ctrls = self.__resolve_control(self.criteria)
File "C:\Program Files\Python38\lib\site-packages\pywinauto\application.py", line 261, in __resolve_control
raise e.original_exception
File "C:\Program Files\Python38\lib\site-packages\pywinauto\timings.py", line 436, in wait_until_passes
func_val = func(*args, **kwargs)
File "C:\Program Files\Python38\lib\site-packages\pywinauto\application.py", line 222, in __get_ctrl
ctrl = self.backend.generic_wrapper_class(findwindows.find_element(**ctrl_criteria))
File "C:\Program Files\Python38\lib\site-packages\pywinauto\findwindows.py", line 87, in find_element
raise ElementNotFoundError(kwargs)
pywinauto.findwindows.ElementNotFoundError: {'title': 'PET WB', 'auto_id': 'textBox', 'control_type': 'Edit', 'top_level_only': False, 'parent': <uia_element_info.UIAElementInfo - '', TextBoxWithEllipsis, None>, 'backend': 'uia'}