我想自动化我的 GUI 测试。我浏览了以下帖子,但如果有人可以为以下示例发布示例测试代码,我会更容易理解。
以下是我的简单Hello World代码。
namespace eval Gui {
}
proc Gui::hello {} {
toplevel .hello
wm title .hello "Hello"
wm resizable .hello 0 0 ;# not resizable
# create a frame to hold the check widgets
set f [frame .hello.boolean -borderwidth 10]
pack $f -side top
# OK and Cancel buttons
button .hello.ok -text "OK" -command [list Gui::Ok .hello ]
button .hello.cancel -text "Cancel" -command [list Gui::cancel .hello ]
pack .hello.cancel .hello.ok -side right
bind .hello <Return> {Gui::Ok .hello ; break}
bind .hello <Escape> {Gui::cancel .hello ; break}
}
proc Gui::Ok { arg } {
set x [list puts "Hello world!"]
eval $x
destroy $arg
}
proc Gui::cancel { arg } {
destroy $arg
}
#-------------------------------------------------------------------
# Gui main window
#-------------------------------------------------------------------
proc Gui::initialize { } {
# build the frame which contains menu options
frame .mbar -relief raised -bd 2
frame .mdummy -width 200 -height 240
pack .mbar .mdummy -side top -fill x
# menu options
menubutton .mbar.command -text Command -underline 0 -menu .mbar.command.menu
pack .mbar.command -side left
# menu under command options
menu .mbar.command.menu -tearoff 0
.mbar.command.menu add command -label "Hello..." -command [list Gui::hello]
}
#-------------------------------------------------------------------
# main code
#-------------------------------------------------------------------
Gui::initialize
我想测试Command -> Hello ... -> OK
一下它是否输出Hello world!
。如果有人可以发布一个模拟这些点击并自动测试它的示例代码,那就太好了。