When using Rapise to record test scripts against Windows, Java, Flex, or other thick client applications that have windows or objects whose names may change in between test runs, you will usually need to make changes to either the test script or the learned objects so that they can match correctly. This article outlines some suggested techniques for recording/playing back scripts against such applications.

When you record a test script in Rapise, it uses "locators" to determine how to find a specific learnt object when playing back the script.

The locator for each object is specified in the saved_script_objects dictionary in the <scriptname>.objects.js file in your test script folder. The locator information is highlighted in the TwoDialogs generic library example below:

 "locations": [
   "locator_name": "Location",
   "location": {
    "location": "4.4",
    "window_name": "param:window_text",
    "window_class": "param:window_class"


 "window_text": "Inflectra Rapise Two Dialogs Sample",
 "window_class": "#32770",
 "object_text": "",
 "object_role": "ROLE_SYSTEM_WINDOW",
 "object_class": "Edit",
 "version": 0,
 "object_type": "Win32Text",
 "object_flavor": "Text",
 "object_name": "Please enter someone else's name:",
 "object_library": "Generic",

 "window_name": "Inflectra Rapise Two Dialogs Sample"

When recording an application who's window name changes or who's object name changes, you may need to adjust this locator. For example you may have different localized text in the name of the window depending on the language that the user has selected.

You have two main options for changing the locators:

  1. You can replace the static window/object name with a wildcard or regular expression. This works if all the possible combinations of window name share some common text.
  2. You can override the locators through code inside your test script. This works for situations where the regular expression / wildcard option will not work because the different combinations of window/object name do not share any comment text.

We shall discuss each in turn:

1) Using a Regular Expression / Wildcard

Simply open up the <script name>.objects.js file in the Rapise editor and do a global search for the hard-coded window/object name and replace it with the appropriate regular expression. In the example above we shall change the name from "Inflectra Rapise Two Dialogs Sample" to match any window that has "Two Dialogs" in it. That way it would work for "MyCompany MyProduct Two Dialogs Demo" as well. To do this we replace the text with the regular expression:

regex:.*Two Dialogs.*

(for more details on regular expressions, please refer to: http://www.inflectra.com/Rapise/HelpReadingPane.ashx?filename=Rapise1.5.0.chm&href=regular_expressions.htm)

This would change our locator code to:

"window_text": "regex:.*Two Dialogs.*",
"window_class": "#32770",
"object_text": "",
"object_role": "ROLE_SYSTEM_WINDOW",
"object_class": "Edit",
"version": 0,
"object_type": "Win32Text",
"object_flavor": "Text",
"object_name": "Please enter someone else's name:",
"object_library": "Generic",
"window_name": "regex:.*Two Dialogs.*"

2) Overriding the Locator through Code

You can override any of the locators in code. This process is described in more detail at: http://www.inflectra.com/Rapise/HelpReadingPane.ashx?filename=Rapise1.5.0.chm&href=object_locator.htm

However for our example, lets change the object name to something different. To do that we'd simply use the following code:

//Call the first text box using the explicit name 'Please enter your name:'
SeS('Please_enter_your_name_', {object_name:"Please enter your name:"}).DoSetText("Roger");

this allows you to specify the explicit object name when you use the variable instead of just using SeS('<object name>').

If the change affects all objects, you can use the g_locatorParams["property"] collection instead:

g_locatorParams["window_name"] = 'MyCompany Two Dialogs Demo';

We've also attached some sample code to this article as well.


Selected files will be attached to any email sent on saving ticket.

file selected files selected  () Delete Selected

  • Created:
  • by:

Select files to upload

Or drag and drop files here

Uploading …
Upload More?
There was an error.
Try again?

Save to upload the selected file(s)

Article Info
  • Last Updated: 10/26/2012
  • Article ID: KB24
  • Views: 9746