AutoIT: 开发界面结合GUI automation和Watir Automation
可以应用AutoIT开发出界面,从而把AutoIT对GUI的自动化测试与Watir对web的自动化测结合在一起。
以下代码是我学习GUI界面开发的实例代码。
1. 当点击Watir_Test_Button,就会打开IE 浏览器,到达百度页面;
2. 当点击GUI_Automation_Test,就会打开notepad,并在其中输入一些文字。
#include <GuiConstantsEx.au3>
#include <AVIConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <TreeViewConstants.au3> ; Window, Pic, Label, Lable background color
GUICreate("Sample GUI", , )
;GUICtrlCreatePic("C:\Users\chenpassion\Desktop\Beauty\wesley1.png", , , , )
;GuiCtrlSetState(-,$GUI_DISABLE)
GUICtrlCreateLabel("Beauty Pic", , , , )
GUICtrlSetBkColor(-, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-, 0xFFFFFF) ; Set Title Icon
GUISetIcon("D:\Thunder Network\Thunder\Program\XmpIcon\mov.ico")
$filemenu = GUICtrlCreateMenu("&File")
$openitem = GUICtrlCreateMenuItem("Open", $filemenu)
GUICtrlSetState(-, $GUI_DEFBUTTON)
$helpmenu = GUICtrlCreateMenu("?")
GUISetHelp("NOTEPAD.EXE") ;Set Menu, MenuItem
$saveitem = GUICtrlCreateMenuItem("Save", $filemenu)
$exititem = GUICtrlCreateMenuItem("Exit", $filemenu)
GUICtrlSetState(-, $GUI_CHECKED)
$recentfilesmenu = GUICtrlCreateMenu("Recent Files", $filemenu, )
$recentfilesmenuchild = GUICtrlCreateMenuItem("C:\\Program", $recentfilesmenu)
$recentfilesmenuchild = GUICtrlCreateMenuItem("D:\\Program", $recentfilesmenu)
$separator1 = GUICtrlCreateMenuItem("", $filemenu, )
$viewmenu = GUICtrlCreateMenu("View", -, )
$viewstatusitem = GUICtrlCreateMenuItem("Statusbar", $viewmenu)
GUICtrlSetState(-, $GUI_CHECKED) ;Create button
$okbutton = GUICtrlCreateButton("OK", , , , )
GUICtrlSetState(-, $GUI_FOCUS)
$cancelbutton = GUICtrlCreateButton("Cancel", , , , )
;GUICtrlSetState(-, $GUI_FOCUS) $cancelbutton2 = GUICtrlCreateButton("Cancel2", , , , ) ;Create Context Menu
$buttoncontext = GUICtrlCreateContextMenu($okbutton)
$buttonitem1 = GUICtrlCreateMenuItem("About button 1", $buttoncontext)
$buttonitem2 = GUICtrlCreateMenuItem("About button 2", $buttoncontext)
$Cancelcontext = GUICtrlCreateContextMenu($cancelbutton)
$buttonitem3 = GUICtrlCreateMenuItem("About Cancel Button", $Cancelcontext) ;Create AVI
$ani1 = GUICtrlCreateAvi(@SystemDir & "\shell32.dll", , , )
GUICtrlSetBkColor(-, 0x00ff00)
$buttonstart = GUICtrlCreateButton("start", , , , )
$buttonstop = GUICtrlCreateButton("stop", , , , ) ;Tab test
$child1_tab = GUICtrlCreateTab(, , , )
$child1_tabitem1 = GUICtrlCreateTabItem("Child1Tab1")
$child1_tabitem2 = GUICtrlCreateTabItem("Child1Tab2")
$buttonTab = GUICtrlCreateButton("OK2", , , , )
;GUICtrlSetState(-, $GUI_SHOW)
;GUISetState(@SW_SHOW)
$child1_tabitem3 = GUICtrlCreateTabItem("")
GUICtrlSetState(-, $GUI_SHOW) ;Combo, setfont, GUICtrlSetFont
$font = "Comic Sans MS"
$fontlabel = GUICtrlCreateLabel("Combo Test: ", , , , )
GUICtrlSetFont($fontlabel,, , , $FONT)
GUICtrlSetBkColor(-, $GUI_BKCOLOR_TRANSPARENT)
$comboFont = GUICtrlCreateCombo("", , , , , $CBS_DROPDOWNLIST)
GUICtrlSetFont($comboFont,, , +, $font)
GUICtrlSetData($comboFont, "Sample Combo|Item2|Item3", "Item3") ; PROGRESS
$progress_bar = GUICtrlCreateProgress(, , , )
GUICtrlCreateLabel("Progress:", , )
GUICtrlSetBkColor(-, $GUI_BKCOLOR_TRANSPARENT) ; EDIT
GUICtrlCreateEdit("Type your Name here: ", , , , , BitOR($ES_WANTRETURN, $WS_VSCROLL, $ES_AUTOVSCROLL)) ; LIST
GUICtrlCreateList("", , , , )
GUICtrlSetData(-, "A.Sample|B.List|C.Control|D.Here", "D.Here") ;Create Icon
GUICtrlCreateIcon("explorer.exe", , , )
GUICtrlCreateLabel("Icon", , , , ) ;Listview
$listview = GUICtrlCreateListView("col1 |col2|col3 ", , , , );,$LVS_SORTDESCENDING)
$button = GUICtrlCreateButton("Value?", , , , )
$item1 = GUICtrlCreateListViewItem("item2|col22|col23", $listview)
$item2 = GUICtrlCreateListViewItem("item1|col12|col13", $listview)
$item3 = GUICtrlCreateListViewItem("item3|col32|col33", $listview) $Watir_Test_button = GUICtrlCreateButton("Watir_Test_Button", , , , )
$GUI_Automation_Test = GUICtrlCreateButton("GUI_Automation_Test", , , , ) GUICtrlCreateInput("Hello", , , )
GUICtrlSetState(-, $GUI_DROPACCEPTED) ; to allow drag and dropping
GUICtrlSetData($item2, "ITEM1")
GUICtrlSetData($item3, "||COL33") ; TREEVIEW TWO
Local $iTreeView_2 = GUICtrlCreateTreeView(, , , , $TVS_DISABLEDRAGDROP)
GUICtrlCreateTreeViewItem("TreeView", $iTreeView_2)
GUICtrlCreateTreeViewItem("With", $iTreeView_2)
GUICtrlCreateTreeViewItem("$TVS_CHECKBOXES", $iTreeView_2)
GUICtrlSetState(-, $GUI_CHECKED)
GUICtrlCreateTreeViewItem("Style", $iTreeView_2) GUISetState()
While
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $buttonstart
GUICtrlSetState($ani1, )
Case $msg = $buttonstop
GUICtrlSetState($ani1, )
Case $msg = $buttonTab
GUICtrlSetState($child1_tabitem1, $GUI_SHOW)
Case $msg = $child1_tabitem1
GUICtrlSetState($buttonTab, $GUI_HIDE)
Case $msg = $child1_tabitem2
GUICtrlSetState($buttonTab, $GUI_SHOW)
Case $msg = $okbutton
$lable3 = GUICtrlCreateLabel("", , , , )
GUICtrlSetColor($lable3, $GUI_BKCOLOR_TRANSPARENT)
$i =
While($i < )
GUICtrlSetData($progress_bar, $i)
$i += 0.01
GUICtrlSetData($lable3, GUICtrlRead($progress_bar))
WEnd
case $msg = $cancelbutton
GUICtrlSetData($item2, "||COL"&Random(,,))
Case $msg = $Watir_Test_button
run("D:\Ruby193\bin\ruby.exe C:\Users\chenpassion\Desktop\abc.rb")
Case $msg = $GUI_Automation_Test
Run("notepad.exe")
WinWait("[CLASS:Notepad]")
$winhandle = WinGetHandle("[class:Notepad]")
ConsoleWrite($winhandle & @LF)
$handle = ControlGetHandle($winhandle,"","Edit1")
ConsoleWrite($handle & @LF)
ControlSetText($winhandle,"",$handle,"GUI automation is going on")
EndSelect
WEnd
AutoIT: 开发界面结合GUI automation和Watir Automation的更多相关文章
- Python+AutoIt实现界面工具开发
前言 不同于Linux服务器上的命令行操作,在windows系统上用户的使用习惯还是倾向于使用有界面的工具.如果工具是命令行交互操作的方式,可能是有悖于在windows上使用的操作习惯,往往不容易推广 ...
- AWTK(Toolkit AnyWhere): 为嵌入式、手机和桌面开发的通用GUI【转】
转自:https://blog.csdn.net/absurd/article/details/80958279 AWTK = Toolkit AnyWhere AWTK是吸取了FTK和CanTK的精 ...
- Unity iOS混合开发界面切换思路
Unity iOS混合开发界面切换思路 最近有很多博友QQ 私信 或则 留言联系我,请教iOS和Unity界面之前相互切换的问题,源代码就不私下发你们了,界面跳转功能的代码我直接贴到下面好了,顺带说i ...
- JAVA之旅(三十一)——JAVA的图形化界面,GUI布局,Frame,GUI事件监听机制,Action事件,鼠标事件
JAVA之旅(三十一)--JAVA的图形化界面,GUI布局,Frame,GUI事件监听机制,Action事件,鼠标事件 有段时间没有更新JAVA了,我们今天来说一下JAVA中的图形化界面,也就是GUI ...
- Lakeshore 中文开发界面,示例项目,飞机大战 等 Lakeshore Chinese development interface, sample project, aircraft war, etc
Lakeshore 中文开发界面,示例项目,飞机大战 等 Lakeshore Chinese development interface, sample project, aircraft war, ...
- 使用xib开发界面
使用xib开发界面 2015-02-02 10:03 编辑: suiling 分类:iOS开发 来源:jymn_chen‘s blog 纯代码写界面有时候会降低开发效率,对于一些通用简单的界面,例 ...
- python图形界面(GUI)设计
不要问我为什么要用 python 来做这种事,我回到“高兴咋地”也不是不可以,总之好奇有没有好的解决方案.逛了一圈下来,总体上来说,python 图形界面有以下几个可行度比较高的解决方案. 1. py ...
- IOS 使用Interface Builder开发界面入门与技巧
引言: 通过Interface Builder(简称IB)来制作界面一直是iOS开发界饱受争议的方式.主要争议的话题是不太适合团队协作开发,再就是对IB的使用比较生疏,觉得IB只能完成一些很简单的功能 ...
- 几款开源的图形界面库(GUI Libraries)
SmartWin++ 遵循BSD许可协议的C++ GUI库,建立在Windows API之上,但仍可以通过使用WineLib在Linux/xNix上使用.也支持Pocket PC和基于Windows ...
随机推荐
- POJ 1985 Cow Marathon【树的直径】
题目大意:给你一棵树,要你求树的直径的长度 思路:随便找个点bfs出最长的点,那个点一定是一条直径的起点,再从那个点BFS出最长点即可 以下研究了半天才敢交,1.这题的输入格式遵照poj1984,其实 ...
- Mysql的常见几种错误:1045,1044
Mysql的常见几种错误: 一.在进入 mysql 数据库时出错 # mysql -u root -p Enter password: ERROR 1045 (28000): Access den ...
- BZOJ1704: [Usaco2007 Mar]Face The Right Way 自动转身机
n<=5000个数0或1,每次可以连续对固定长度区间取反,目标把所有1变0,求一个取反区间的固定长度K使取反次数最少. 答案关于K不单调,因此枚举K,对每个K扫一遍区间,遇到1就把连续K个数反转 ...
- ubuntu 12.04 64bit 安装 teamviewer 8.0
1. 在http://www.teamviewer.com下载teamviewer_linux_x64.deb 2.sudo dpkg -i teamviewer_linux_x64.deb 3.如果 ...
- 动态规划:HDU 1114 Piggy-Bank
Problem Description Before ACM can do anything, a budget must be prepared and the necessary financia ...
- xml建模
1.建模的由来 就是将指定的xml字符串当作对象来操作 如果说当对一个指定的xml格式字符串完成了建模操作, 好处在于,只需要调用指定的方法就可以完成预定的字符串获取: 2.建模的思路 1.分析需要被 ...
- stored procedure --存储过程
存储过程(Stored Procedure),计算机用语,是一组为了完成特定功能的SQL语句集,是利用SQL Server所提供的Transact-SQL语言所编写的程序.经编译后存储在数据库中.存储 ...
- ntfs格式uefi启动u盘
http://www.laomaotao.org/softhelp/syjc/925.html http://www.laomaotao.org/softhelp/wtjd/989.html http ...
- c++多线程编程:常见面试题
题目:子线程循环 10 次,接着主线程循环 100 次,接着又回到子线程循环 10 次,接着再回到主线程又循环 100 次,如此循环50次,试写出代码 子线程与主线程必有一个满足条件(flag == ...
- 关于rman duplicate 一些比較重要的知识点--系列三
FYI: http://docs.oracle.com/cd/E11882_01/backup.112/e10643/rcmsynta020.htm#RCMRF126 rman duplicate d ...