Seapine Labs
Personal tools

Waiting For an Image

From Seapine Labs

Jump to: navigation, search

Control checkpoints compare an expected value against the actual value in the application and pass or fail based on this comparison. Checkpoints can be easily modified to use the Property function, which returns the runtime value of the specified property. The function can then be used in a conditional statement to check for a particular value:

           If Window(“win”).Editbox(“Status”).Property(“Text”) = “New” then
               Println(“Welcome new customer!”)
           End If

This will not work if you need to wait for a visible change in a custom control or image, since the Text property is not defined for those controls. Instead, you can use the ImageCompare function, which returns TRUE or FALSE based on whether the actual image matches the expected image.

An example of this is the browser status bar, which will display the value “Done” once a page has loaded. The goal is to have a script wait until the web page is completely loaded and the status bar displays the “Done” message, however long it takes. Since the status bar appears in the Application Repository under the Browser window as a generic control the Text property is not defined, so it is not possible to use the Property() function to retrieve the current value. In this case we don’t really need to retrieve the value, just to wait until it has the value we want.

Some points to consider:

1. QA Wizard Pro takes snapshots of your application as you record and playback scripts. These snapshots are used in the image functions, so it’s critical that the snapshots accurately reflect the application. You can add a low-level mouse click to force QA Wizard Pro to take a new snapshot.

2. Use the Add Statement dialog to add a CheckpointImage step to ensure that you are saving the correct area and the expected value, then modify it. To convert the CheckpointImage statement to a CompareImage, rename the function and remove the last two arguments.

3. The image functions rely on coordinates, so it’s a good idea to maximize the browser and keep the display setting consistent.

The steps below can be used as a template to create a “WaitForImage” situation:

   'Click on status bar to force QA Wizard Pro to update snapshot
   Window("Browser").Control("Control13").LMouseClick(146, 5, 203)
   'Initial image checkpoint - replace with CompareImage and remove last two arguments (see next step)
   'CheckpointImage(100, "C:\\ baseline.png", 0, 522, 37, 16, True, "")
   'FLAG will be set to TRUE if actual matches expected;  otherwise it will be FALSE
   FLAG=CompareImage(100, "C:\\ baseline.png", 0, 522, 37, 16)
   'Continue looping while actual image does not match expected image
   While FLAG=False
       'Give browser time to update
       Delay(500) 
       'Click on status bar to force QA Wizard Pro to update snapshot
       Window("Browser").Control("Control13").LMouseClick(38, 8, 204)
       'Compare again
       FLAG=CompareImage(100, "C:\\baseline.png", 0, 522, 37, 16)
       Wend
   'When actual matches expected FLAG will be set to TRUE, forcing script out of loop
   'Continue with next steps













Issue Management Software | Source Code Control Software | Test Case Management | Requirements Management Software