Squish tip of the week: Picking additional properties for that ‘Hard to Find’ object

When dealing with a non-standard, dynamic or hard to find object, additional or alternate object properties may be required to properly identify the object.

Topics discussed:

  • Using the Pick tool
  • Adding new object properties to an Object Map entry
  • Validating the updated Object Map entry

(more…)

Squish tip of the week: How to enable Code Completion for Shared Scripts (python)

Did you know by simply enabling a few Eclipse PyDev settings, and including an import statement in your Test Case the code completion also displays any functions defined in your Test Suite Resource scripts?

Adjust Code Completion Settings

  1. With a Squish Test Suite open, select Edit (or Squish IDE) > Preferences
  2. Expand PyDev > Editor and then select Code Completion
  3. Check the three Request Completion on… options
  4. Click OK

Tell your Test Suite where to find the Test Suite Resource scripts

  1. Click Window > Show View… > Other
  2. Expand PyDev and select PyDev Package Explorer
  3. From the PyDev Package Explorer, right click the currently active Test Suite and select Properties
  4. Select PyDev – PYTHONPATH
  5. Click Add Source Folder
  6. Expand the Test Suite > Test Suite Name > shared, and select scripts (if you do not have any Test Suite Resource Scripts this folder may not exist)
  7. Click Force restore internal info
  8. Click OK, and click OK again on the Properties window

Now you are ready to begin using the code completion in your Test Suite!

Given a Test Suite Resource script script_1.py, create a new or open an existing Test Case and add the following:

if 0: from script_1.py import *
source(findFile("scripts","script_1.py"))

def main():

With a function within your script file in mind, begin typing the first few characters of the function name as illustrated below:

Result?

The code completion is now enabled for general scripting, and Squish is also now aware of any custom functions you create and indicate using the syntax above.

(more…)

Squish tip of the week: Handling mouse position sensitive drag and drops

Mouse cursor position can impact some drag and drop objects in applications.

In a recent application I was working with, drag and dropping objects to new locations worked with the build-in drag and drop functionality; however connecting those objects with a workflow style arrow, required the mouse cursor to first hover over a specific quadrant of the object before the line drawing could take place using a drag and drop command.

To address this, I created a slightly altered drag and drop function called dragAndDropConnection. While the example below applies to a Java application, the same theory, or approach is applicable to other application toolkits.

function dragAndDropConnection(canvasObj, sx, sy, dx, dy){
    mouseMove(waitForObject(canvasObj), sx, sy);
    snooze(2);
    dragAndDrop(waitForObject(canvasObj), sx, sy, 
        canvasObj, dx, dy, DnD.DropNone);
}

The mouseMove line is the key to this case. The snooze(2), while not required, helped me to witness the breakdown of the dragAndDropConnection function.

Keep in mind, the coordinates are relative coordinates, relative to the object on which the action in performed, in this case, the canvas.

To further optimize connecting the drag and dropped objects, one could calculate the relative location from which to draw the connection based on the original drag and drop location of the two objects on the canvas.

The arrow you wish to move the cursor to resides on the left edge of the object, and about half-way between the top and the center (vertically). Given that you can use:

mouseMove(waitForObject(canvasObj), sourceElementX * 0.9,
    sourceElementY * 0.8);

(more…)

Squish tip of the week: How to execute keyboard and mouse combination commands

How can I perform a keyboard + mouse combination in a test script?

The mouseClick function accepts a modifierState and a button. The modifier state accepts a set of keyboard commands.
Take for example performing a Control + Shift + Right Click

Given a Java Swing application, Shift is 1 and Control is 2
Which results in mouseClick(“:myObject”, 5, 5, 1|2, Button.Button3), where the Shift + Control keys are pressed, followed by Button3, or a right click.

Each application type may use different modifier values:

Java Applications

Squish tip of the week: Use data to validate endless scenarios

You’ve most likely heard of data-driven tests. A key term often used in Automated GUI Testing.

But did you realize the power a set of data can provide within a single test case?

Take a simple example of enrolling a user in a membership-based program. Within the few registration fields, many variables exist:

  • What are all valid characters in each given field?
  • What are the invalid characters in each given field?
  • Minimum number of characters
  • Maximum number of characters
  • Must the field contain specific characters, such as an @ symbol?
  • Is each given field required? Or under what circumstances is each given field required?
  • etc.

Using a single iterating test case, a set of input data, as well as the anticipated result, you can validate a large set of business rules, or features/requirements.
Now imagine validating each of these scenarios manually…

Think of an area in your application where your testing could greatly benefit from such a scenario. Incorporate the test, among others, in your build process, and measure the testing duration savings!

Squish tip of the week: How to determine if a checkbox is checked?

You can check the state of a checkbox, radio button, or the property of any other object or widget using Squish.

Using a test.compare() Verification Point

The line below looks at the object :Controls.My_CheckBox and indicates if the verification point passed or failed: passed if the checkbox is checked, and failed if the checkbox isn’t checked:

test.compare(findObject(":Controls.My_CheckBox").checked, True)

(more…)