使用pywinauto在窗口中执行操作后,我得到“ pywinauto.findwindows.ElementAmbiguousError”

时间:2019-03-07 07:54:43

标签: python pywinauto

我正在尝试使用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")

为什么这个模棱两可的错误出现了?

0 个答案:

没有答案