После выполнения операций в окне, используя pywinauto, я получаю "pywinauto.findwindows.ElementAmbiguousError" - PullRequest
0 голосов
/ 07 марта 2019

Я пытаюсь автоматизировать свое приложение, используя pywinauto.Я мог бы сделать много вещей.Но когда я попытался выполнить некоторые операции в окне, которое будет запущено после нажатия одной кнопки в моем приложении, это показало pywinauto.findwindows.ElementAmbiguousError: There are 18 elements that match the criteria.Хотя я уже выполнил некоторые операции в запущенном окне.Вот мой код:

def fw_trace_advanced(self):
    self.dlg = desk_control.window(title_re='WRT Settings')
    self.win = self.dlg.child_window(title_re="System", control_type="Window")
    self.dlg.print_control_identifiers()
    self.win.child_window(title="BT Presets Selection", auto_id="BTTraceSelection_Grp", control_type="Group").click_input()
    self.combo = self.win.child_window(title="BT Presets Selection", auto_id="BTTraceSelection_Grp",control_type="Group").child_window(auto_id="BTTraceSelection_Panel", control_type="Pane")
    self.combo.child_window(title="FW Trace", control_type="ComboBox").click_input()
    self.win.print_control_identifiers()

при запуске я получаю сообщение об ошибке:

pywinauto.findwindows.ElementAmbiguousError: There are 18 elements that match the criteria {'title_re': 'System', 'control_type': 'Window', 'top_level_only': False, 'parent': <uia_element_info.UIAElementInfo - 'WRT Settings ', WindowsForms10.Window.8.app.0.1d89703_r9_ad1, 3671830>, 'backend': 'uia'}

self.dlg.print_control_identifiers() дает следующее:

Dialog - 'WRT Settings '    (L130, T130, R1203, B619)
['WRT Settings Dialog', 'Dialog', 'WRT Settings ', 'Dialog0', 'Dialog1']
child_window(title="WRT Settings ", auto_id="WRTSettingsForm", control_type="Window")
   | 
   | Dialog - 'System'    (L156, T156, R540, B536)
   | ['System', 'Dialog2', 'SystemDialog', 'System0', 'System1']
   | child_window(title="System", auto_id="BTTraceSourcePresets", control_type="Window")
   |    | 
   |    | Button - 'Cancel'    (L352, T496, R427, B519)
   |    | ['Button', 'Cancel', 'CancelButton', 'Button0', 'Button1', 'Cancel0', 'Cancel1', 'CancelButton0', 'CancelButton1']
   |    | child_window(title="Cancel", auto_id="BTSrcPresetCancel_Btn", control_type="Button")
   |    | 
   |    | Button - 'Save'    (L270, T497, R345, B520)
   |    | ['SaveButton', 'Button2', 'Save', 'SaveButton0', 'SaveButton1', 'Save0', 'Save1']
   |    | child_window(title="Save", auto_id="BTSrcPresetSave_Btn", control_type="Button")
   |    | 
   |    | GroupBox - 'BT Presets Selection'    (L176, T199, R520, B491)
   |    | ['BT Presets Selection', 'BT Presets SelectionGroupBox', 'GroupBox', 'GroupBox0', 'GroupBox1']
   |    | child_window(title="BT Presets Selection", auto_id="BTTraceSelection_Grp", control_type="Group")
   |    |    | 
   |    |    | Pane - ''    (L179, T215, R517, B488)
   |    |    | ['', 'Pane', '0', '1', 'Pane0', 'Pane1']
   |    |    | child_window(auto_id="BTTraceSelection_Panel", control_type="Pane")
   |    |    |    | 
   |    |    |    | Button - 'Edit...'    (L439, T233, R514, B256)
   |    |    |    | ['Edit...', 'Button3', 'Edit...Button', 'Edit...0', 'Edit...1', 'Edit...Button0', 'Edit...Button1']
   |    |    |    | child_window(title="Edit...", auto_id="1967972", control_type="Button")
   |    |    |    | 
   |    |    |    | Static - 'FW Trace'    (L199, T235, R299, B258)
   |    |    |    | ['FW Trace', 'FW TraceStatic', 'Static', 'FW Trace0', 'FW Trace1', 'FW TraceStatic0', 'FW TraceStatic1', 'Static0', 'Static1']
   |    |    |    | child_window(title="FW Trace", auto_id="2492250", control_type="Text")
   |    |    |    | 
   |    |    |    | ComboBox - 'FW Trace'    (L299, T233, R420, B254)
   |    |    |    | ['FW TraceComboBox', 'FW Trace2', 'ComboBox', 'ComboBox0', 'ComboBox1']
   |    |    |    | child_window(title="FW Trace", auto_id="3213090", control_type="ComboBox")
   |    |    |    |    | 
   |    |    |    |    | Static - 'FW Trace'    (L3, T3, R101, B18)
   |    |    |    |    | ['FW Trace3', 'FW TraceStatic2', 'Static2']
   |    |    |    |    | child_window(title="FW Trace", control_type="Text")
   |    |    |    |    | 
   |    |    |    |    | Button - 'Open'    (L401, T235, R418, B252)
   |    |    |    |    | ['Open', 'Button4', 'OpenButton', 'Open0', 'Open1', 'OpenButton0', 'OpenButton1']
   |    |    |    |    | child_window(title="Open", control_type="Button")

почему эта неоднозначная ошибка вошла в картину?

...