我正在尝试使用 PyWinAuto 进行一些 Tkinter GUI 测试。我有一个用 Tk 编写的简单应用程序,看起来像这样。
问题是 - 我无法让 PyWinAuto 识别和使用我的应用程序中的按钮/条目。我已经尝试过
>>> app.Prototype.PrintControlIdentifiers()
,但它什么也没返回,或者:
>>> app.Prototype.print_control_identifiers()
Control Identifiers:
TkChild - '' (L308, T81, R1108, B681)
'' '0' '1' 'TkChild' 'TkChild0' 'TkChild1'
Button - '' (L763, T86, R878, B112)
'2' 'Button' 'Button0' 'Button1'
Button - '' (L613, T86, R728, B112)
'3' 'Button2'
Button - '' (L463, T86, R578, B112)
'4' 'Button3'
Button - '' (L313, T86, R428, B112)
'5' 'Button4'
TkChild - '' (L613, T171, R737, B198)
'6' 'TkChild2'
TkChild - '' (L463, T171, R587, B198)
'7' 'TkChild3'
TkChild - '' (L313, T171, R437, B198)
'8' 'TkChild4'
Static - '' (L613, T141, R949, B170)
'9' 'Static' 'Static0' 'Static1'
Static - '' (L463, T141, R799, B170)
'10' 'Static2'
Static - '' (L313, T141, R649, B170)
'11' 'Static3'
应用程序窗口名称为 Prototype(Tkinter 标题 Prototype-GUI)。我也尝试过设置_name
和name
小部件,如下所示:
param_range = Entry(wrapper, self.basicEntrySett, name="entryrange")
或者:
param_range = Entry(wrapper, self.basicEntrySett, _name="entryrange")
但它所做的只是:
print param_range.winfo_name()
entryrange
并且打印 PrintControlIdentifiers 输出没有改变。我想以人类可读的方式命名它们。