|
我把 SCRIPT改了一下,在DATAPOOL中只输入num1 和 num2 的值,然后在script 中算出sum的值,再做比较。如何在Datapool 中赋值,我是用下面几步来实现的:(不好意思我用英文,因为我的是英文版)。
1. Open Rational Task Manager.
2. Select Tools-> Manage-> DataPools.
3. Click on New and enter "jsq" as name. Click OK.
4. You will get a message "An Empty datapool called jsq has been registered..." Select Yes
5. Select Insert Before. In the "Data Type Specification jsq" dialogue, enter "B" in the "Name". Select Insert Before again. Enter "A" in the "Name".
6. Click Save.
7. Click Close.
8. Select OK on the message beginning "If you leave the Datapool editor..."
9. In the "Manage Datapools" dialogue, select jsq and press Edit
10. Click on on Edit Datapool Data in the "Datapool Properties" dialogue.
11. Enter three pairs of numbers. There will be one number in each pair for for A and one for B. and click on Save and Close. For example:
A B
1 0
-1 1
15 16
12. Click on OK in the "Datapool Properties" dialogues.
13. Click on Close in "Manage Datapools."
14. Return to the "Rational Robot" and select File and Playback in the Test "CaclTest-2" Script.
15. Click on OK and if it asks you about overwriting a log, click Yes
16. The system will bring up the Test log. Expand "Script Start" You should observe one "Application Start" and three "Verification Point."
17. If you want to see the numbers each time, go to the Test Add script. Just before "Result - EditBoxVP..." enter the line Print "sum is" & sum
18. Then select File and Playback. (Click after viewing each message.)
下面是我的script.
注意我是在WINDOW XP 下测的,所以StartAppUnderNone "C:\WINDOWS\system32\calc.exe"
'$Include "sqautil.sbh"
Sub Main
Dim Result As Integer
dim dp as long
dim x as integer
dim num1 as string
dim num2 as string
dim sum as string
'Initially Recorded: 7/13/2005 3:00:36 PM
'Script Name: CaclTest-2
StartAppUnderNone "C:\WINDOWS\system32\calc.exe"
dp=SQADatapoolOpen("jsq")
for x=1 to 3
Call SQADatapoolFetch(dp)
Call SQADatapoolValue(dp,1,num1)
Call SQADatapoolValue(dp,2,num2)
'Call SQADatapoolValue(dp,3,sum)
Window SetContext, "Caption=Calculator", ""
EditBox Click, "ObjectIndex=1", "Coords=301,9"
'InputKeys num1&"{+}"& num2 & "{ENTER}" has mistake?
InputKeys num1 &"{+}"& num2 &"{ENTER}"
sum = str(val(num1) + val(num2))
Print "num1 is" & num1
Print "num2 is" & num2
Print "sum is" & sum
Result = EditBoxVP (CompareNumeric, "ObjectIndex=1", "VP=Alphanumeric;Value="& sum &",")
next
Call SQADatapoolClose(dp)
Window CloseWin, "", ""
End Sub |
|