1.实验目的:
1)理解自动化测试
2)学会应用AutoIT进行自动化测试
2.实验内容:
1)在文本中编辑数学表达式
2)使用AutoIT读取该文本并进行计算
3.实验过程:
1)安装AutoIT软件,阅读软件文档和example
2)设计测试用例
3)使用AutoIT进行自动化测试
4)输出并检查测试结果
5)分析测试结果
4.具体实验:
1)数学表达式:
2x4x8x16=
2/4/8/16=
2-4-8-16=
2+4+8+16=
2)测试用例:
#include <Constants.au3>
;
; Language: English
; Platform: Win7
; Author: Jiwei Wang
;
; Script Function:
; Plays with the calculator.
;
; Open the file for reading and store the handle to a variable.
Local $hFileOpen = FileOpen("C:\Users\wlove\Desktop\test.txt", 0)
If $hFileOpen = -1 Then
MsgBox($MB_SYSTEMMODAL, "", "An error occurred when reading the file.")
Return False
EndIf
; Run the calculator
Run("calc.exe")
; Wait for the calculator to become active. The classname "CalcFrame" is monitored instead of the window title
WinWaitActive("[CLASS:CalcFrame]")
While 1
; Read the fist line of the file using the handle returned by FileOpen.
Local $sFileRead = FileReadLine($hFileOpen)
If @error = -1 Then ExitLoop
; Now that the calculator window is active type the values 2 x 4 x 8 x 16
; Use AutoItSetOption to slow down the typing speed so we can see it
AutoItSetOption("SendKeyDelay", 500)
Send($sFileRead)
Sleep(2000)
WEnd
; Now quit by sending a "close" request to the calculator window using the classname
WinClose("[CLASS:CalcFrame]")
; Now wait for the calculator to close before continuing
WinWaitClose("[CLASS:CalcFrame]")
; Finished!
3)自动化测试:
4)实验结果:
2x4x8x16=1024
2/4/8/16=0.00390625
2-4-8-16=-26
2+4+8+16=2*6=12
5)分析:
分别在Win 7,Win 10环境下进行了测试。win10系统只能自动打开计算器,但无法在计算器中进行输入。Win 7可以进行正常的打开计算器、读取文本、在计算器中输入等操作,但在进行加法运算的时候也出现了问题,并不能正确地读取数据,将“2+4+8+16”读取成了“2*6”,并最终输出结果为12。可见由于autoit3在windows新版本环境中的运行中会存在一些问题。
5.相关:
原文件:calculator.au3
使用工具:软件测试工具:AutoIT3;录屏工具:Ocam