使用Tcl擴充套件包cwind進行介面自動化測試
[@more@]
cwind擴充套件包命令介紹:
to simulate a left click on the mouse
::cwind::lclick
to simulate a right click on the mouse
::cwind::rclick
to simulate a middle click on the mouse
::cwind::mclick
to set the mouse position
::cwind::setpos
where the starting position (0 0) is the upper left corner
to get the mouse position
::cwind::getpos
to get the cursor postion based on the position of the foreground window
::cwind::getwpos
to set the cursor postion based on the position of the foreground window
::cwind::setwpos
In version 1.3
to send a message to the foreground window.
::cwind::sendmessage
Message name is the windows's message to be sent.
Wparam and lparam are additional value.
to post a message to the foreground window.
::cwind::postmessage
Message name is the windows's message to be posted.
Wparam and lparam are additional value.
In version 1.2
I've expanded the specification of some commands for MDI.
to put in active a window.
::cwind::show ?-exact?
Search into the list of active window's name and set in foreground this window.
Window's name is treated as a glob-style pattern.
Window's name is specified in list form,
The first element is a parent window name and the optional second element is a MDI child window name.
to get the status of a window (Maximized, Minimized or Normal).
::cwind::state ?-exact?
Window's name is treated as a glob-style pattern.
Window's name is specified in list form,
The first element is a parent window name and the optional second element is a MDI child window name.
to have a list of all opened windows.
::cwind::wlist ?-exact? ?
If Window's name is omitted, Will show you a Tcl list with all the window's name.
If Window's name is specified, Will show you a Tcl list with all the MDI child window's name.
Window's name is treated as a glob-style pattern.
In version 1.1
Due to confilcts with the Tcl command "list",
I've renamed the command ::cwind::list to ::cwind::wlist.
::cwind::wlist
to get the status of a window (Maximized, Minimized or Normal).
::cwind::state ?-exact?
Window's name is treated as a glob-style pattern.
to restore the foreground window at the original size.
::cwind::restore
to minimize the foreground window.
::cwind::minimize
to maximize the foreground window.
::cwind::maximize
to minimize all the windows.
::cwind::minimizeAll
to wait a specific window on the foreground.
::cwind::waitwind
Max wait is in seconds and the default value is 5.
Window's name is treated as a glob-style pattern.
In version 1.0
to send a text to the foreground window.
::cwind::send
Send the arguments, separated by spaces.
If you want send the spaces, enclose your text into { and }.
to put in active a window.
::cwind::show ?-exact?
Search into the list of active window's name and set in foreground this window.
Window's name is treated as a glob-style pattern.
to get the active window name.
::cwind::gettext
Get the test of the foreground window.
to get the content of the clipboard.
::cwind::getcb
to put strings into the clipboard.
::cwind::putcb
to have a list of all opened windows.
::cwind::list
Will show you a Tcl list with all the window's name.
to set the sleep time.
::cwind::sleeptime ?
一些特殊鍵的用法:
如果要使用像ctrl + c這樣的特殊鍵,必須用下面的字串序列來表示
"|CTRL+| c |CTRL-|"
特殊鍵的名字對應關係如下:
"ALT+" press ALT "ALT-" release ALT "ALTL+" press left ALT key "ALTL-" release left ALT key "ALTR+" press right ALT key "ALTR-" release right ALT key "CTRL+" press CTRL "CTRL-" release CTRL "CTRLL+" press left CTRL key "CTRLL-" release left CTRL key "CTRLR+" press right CTRL key "CTRLR-" release right CTRL key "SHIFT+" press SHIFT "SHIFT-" release SHIFT "SHIFTL+" press left SHIFT key "SHIFTL-" release left SHIFT key "SHIFTR+" press right SHIFT key "SHIFTR-" release right SHIFT key "TAB" press the tabulation key "RET" press the return key "ESC" press the escape key "BACK" press the backward key "DEL" press the delete key "INS" press the insert key "HELP" press the help key "LEFT" send the cursor to the left "RIGHT" send the cursor to the right "UP" send the cursor to up "DOWN" send the cursor to down "PGUP" press the page up key "PGDN" press the page down key "HOME" press the home key "END" press the end key "F1" press the function key F1 "F2" press the function key F2 "F3" press the function key F3 "F4" press the function key F4 "F5" press the function key F5 "F6" press the function key F6 "F7" press the function key F7 "F8" press the function key F8 "F9" press the function key F9 "F10" press the function key F10 "F11" press the function key F11 "F12" press the function key F12 "NUM0" press the 0 on the key pad "NUM1" press the 1 on the key pad "NUM2" press the 2 on the key pad "NUM3" press the 3 on the key pad "NUM4" press the 4 on the key pad "NUM5" press the 5 on the key pad "NUM6" press the 6 on the key pad "NUM7" press the 7 on the key pad "NUM8" press the 8 on the key pad "NUM9" press the 9 on the key pad "NUM*" press the * on the key pad "NUM+" press the + on the key pad "NUM-" press the - on the key pad "NUM," press the , on the key pad "NUM/" press the / on the key pad "SNAP" press the print key "APPS" press the application key "KANJI" press the kanji key "CONV" press the convert key "NCONV" press the nonconvert key
下面是一段演示程式,演示了開啟一個記事本,輸入hello world,開啟about視窗,然後複製視窗到剪貼簿,開啟畫筆,把介面抓圖複製到畫圖程式。下面程式中使用的視窗名是按照英文作業系統的,對於中文作業系統,需要修改其中的視窗名,例如*WordPad修改為記事本的視窗名,*Paint修改為畫筆的中文視窗名。
package require cwind exec $env(COMSPEC) /c start wordpad.exe & ::cwind::waitwind {*WordPad} 10::cwind::send {Hello World!} |RET| after 1000 ::cwind::send |CTRL+| a |CTRL-| after 1000::cwind::send |CTRL+| c |CTRL-| after 1000 set clip [::cwind::getcb] after 1000 ::cwind::send |END| |CTRL+| v |CTRL-| after 1000 ::cwind::send |ALT+| h |ALT-| a after 1000 ::cwind::send |ALT+| |SNAP| |ALT-| exec $env(COMSPEC) /c start mspaint.exe & ::cwind::waitwind {*Paint} 10 ::cwind::send |ALT+| e |ALT-| p exit
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/459749/viewspace-1057378/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 真的要進行介面測試自動化?
- 使用PostMan進行自動化測試Postman
- 使用 PostMan 進行自動化測試Postman
- PDF 擴充套件包使用套件
- 自動化擴充套件挑戰:ROI套件
- 使用 Headless Chrome 進行自動化測試Chrome
- Golang中使用lua進行擴充套件Golang套件
- 使用 testng 做介面自動化測試
- 介面自動化測試
- 使用 Robot Framework 進行自動化視覺測試Framework視覺
- Android使用Espresso進行UI自動化測試AndroidEspressoUI
- 使用QTP進行非GUI的自動化測試QTGUI
- swift - 基於TCL的自動化測試框架Swift框架
- 如何開發、本地測試、釋出 Laravel 擴充套件包?Laravel套件
- 當在laravel中開發擴充套件時,如何將本地擴充套件載入進其他laravel專案中進行測試?Laravel套件
- Python + requests + unittest + ddt 進行介面自動化測試的框架Python框架
- 「擴充套件包推薦」蘑菇丁 SDK—自動簽到套件
- laravel下使用 pdf 擴充套件包Laravel套件
- 表空間自動擴充套件 AUTOALLOCATE 的擴充套件規律套件
- 試著使用 jmeter 實現介面自動化測試JMeter
- Flutter應用進行自動化測試Flutter
- 自動化時序異常檢測的可擴充套件通用框架套件框架
- 介面自動化使用requests生成測試報告測試報告
- python 介面自動化測試Python
- 介面自動化測試框架 HttpFPT框架HTTP
- 二、介面自動化測試(2)
- protobuf 介面自動化測試摸索
- 在Python中呼叫Java擴充套件包HanLP測試記錄PythonJava套件HanLP
- Appium自動化(15) - 針對 webview 進行自動化測試APPWebView
- 測試開發之介面篇-使用K6完成介面自動化測試
- WCF擴充套件:行為擴充套件Behavior Extension套件
- 使用 MeterSphere 進行 Dubbo 介面測試
- 使用Jmeter進行http介面測試JMeterHTTP
- 關於使用擴充套件包的問題。套件
- 大資料包表如何進行自動化測試大資料
- 使用jmeter+ant進行介面自動化測試(資料驅動)之一:設計jmeter指令碼JMeter指令碼
- Django 介面自動化測試平臺Django
- 介面自動化測試解決方案