Object Scripting Commands
Scripts that are recorded using robot are not very useful in actual test use. The recorded script is a linear script without control structure, if you want to test a large amount of data, relying only on the recorded script test, is not feasible. In addition, a linear script with a checkpoint, which is directly added to the control structure, is not properly replayed. In this case, using the Robot Object Scripting command is a good choice. The method is to use a recording plus a hand-coded blending method. The resulting script is clear, easy to maintain, and powerful.
The following is also an example of a calculator, using Sqagetproperty to get the object properties and using Sqalogmessage to write the test results to the log:
Sub Main
Dim Result As Integer
Dim sum as string
'Initially Recorded: 2003-7-21 11:07:34
'Script Name: jsq-对象脚本
StartApplication "C:\WINNT\system32\calc.exe"
Window SetContext, "Caption=计算器", ""
InputKeys "1{+}1{ENTER}"
Result= SQAGetProperty ("Type=Label;ObjectIndex=1", "Text", sum)
if left(sum,1)="2" then
SQALogMessage sqaPass, "测试通过", ""
else
SQALogMessage sqaFail, "测试失败", ""
end if
Window CloseWin, "", ""
End Sub
In the actual test, you will find that this kind of script is very useful.