Robot function test example

xiaoxiao2021-03-06  77

After successfully installed and establishing test items, you can use TestManager and Robot for software testing. The following is an example of the calculator test example of a Windows, showing the Rational functionality.

1. Start the Robot, the Login window The default user name is admin, enter the password specified when the test item is established (the default is empty), you can enter the Robot main interface;

2. Click on the GUI button on the toolbar, record the GUI script, and enter the script name in the window;

3. Click the fourth button on the GUI Record toolbar, click the Start Application button at the GUI INSET toolbar, click the Browse ... button, select the calculator program;

4. Enter 1 1 = from the keyboard, then click the fourth button on the GUI RECORD toolbar, click AlphaNumeric checkpoint in the GUI INSET toolbar, select the third Numeric Equivalence;

5. Turn off the calculator, click the STOP button on the GUI Record toolbar to complete the recording of the script;

Recorded scripts:

Sub main

Dim Result As INTEGER

'INITIALLY Recorded: 2003-7-18 9:30:45

'Script name: Calculator

StartApplication "C: /Winnt/system32/calc.exe"

Window SetContext, "CAPTION = Calculator", ""

InputKeys "1 { } 1 {entry]

Result = labelvp (Comparenumeric, "Text = 2.", "VP = alphaleric; value = 200000")

Window Closewin, "", ""

End Sub

This script does not play correctly and needs

Result = labelvp (Comparenumeric, "Text = 2.", "VP = alphaleric; value = 200000")

Change to:

Result = labelvp (Comparenumeric, "text = 2.", "Vp = alphapleric; value = 2.")

This allows playback of the playback button on the toolbar.

This script can only verify a group of data and cannot reflect the convenience of automation tests. You need to manually modify the script, add a loop structure and data pool (datapool), so you can implement a large amount of data, the script is easy to maintain and powerful.

The modified script is as follows:

'$ 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: 2003-7-18 8:51:18

'Script name: Calculator-2

StartApplication "c: /winnt/system32/calc.exe" DP = SQADATAPOOLOPEN ("JSQ")

For x = 1 to 5

Call SqadataPoolFetch (DP)

Call SqadataPoolValue (DP, 1, NUM1)

Call SqadataPoolValue (DP, 2, NUM2)

Call SqadataPoolValue (DP, 3, SUM)

Window SetContext, "CAPTION = Calculator", ""

InputKeys Num1 & "{ }" & num2 & "{entry}"

Result = labelvp (Comparenumeric, "Text =" & SUM & ".", "VP = alphaumeric; value =" & sum ")

NEXT

Call SqadataPoolClose (DP)

Window Closewin, "", ""

End Sub

Note: SQADATAPOOLOPEN ("JSQ"), JSQ is a DataPool name, which needs to be created manually in TestManager.

** After a simple editor, you only need to import the test data into the data pool (DataPool) playback script, through the viewing test log, you can use it, you can use it when you start testing, not waiting to return, nor manual Simple repetition of the process. Before testing, you can prepare test data backup.

In the actual test work, most of the functional tests are based on this mode, and the use effect is also ideal.

转载请注明原文地址:https://www.9cbs.com/read-108256.html

New Post(0)