Object Locator

Top  Previous  Next

Purpose

Object locators are created during Recording/Learning and used during Playback to identify learned objects and simulated objects. There are four types of locators:

 

Location: This locator uses the object's index relative to encapsulating objects for identification. The location is stored as a period separated list of indexes. For instance, 1.2.3 would be "the third object in the second object in the first object."  The name, class, and role of the object are also stored.
LocationPath: This locator remembers name, class, and role property information for the object and all of its encapsulating objects.
LocationRect: This locator stores screen coordinates.
Ordinal: This locator creates an array of object name/object class combinations.  Each object is assigned an index in  the array.

 

Usage

The locator for each object is specified in saved_script_objects in <scriptname>.objects.js your test script.   Locator information is highlighted in the simulated object example below:

 

Obj10:{"version":0,"object_type":"SeSSimulated","object_name":"regex:.* - Paint",

"object_class":"MSPaintApp","object_role":"ROLE_SYSTEM_WINDOW",

"object_text":"regex:.* - Paint",

"locations":[{"locator_name":"Location","location":{"location":"",

"window_name":"regex:.* - Paint","window_class":"MSPaintApp"}}]}

 

Locator Parameters

If a piece of information in the locator matches a piece of object info (object_name, object_class, object_role, object_text) then it is stored in the locator as "param:<object_info>".  For example:

 

 "object_name": "param:object_name",

 "object_class": "param:object_class",

 "object_role": "param:object_role",

 

Over-riding Locator Parameters

You can over-ride the information used to locate your object at runtime.  Normally, to refer to an object, you use the SeS function:

 

SeS('Obj9')

 

To override locator parameters, specify the new value in the function call.  In the following example, we over-ride the object_name parameter for object 9:

 

SeS('Obj9', {object_name:"regex:.*"})

 

You may want to change a parameter value for every locator/object in the program.  For instance, perhaps the url of the webpage has changed.  Use the global variable g_locatorparams as in the following example:

 

function Test()

{

  // Here we use direct parameter overriding

  SeS('Obj1', {url:"http://newaddr/"}).DoAction();

  SeS('Obj2', {url:"http://newaddr/"}).DoAction();

 

  // And this is equivalent to above

  g_locatorparams["url"]="http://newaddr/";

  SeS("Obj1").DoAction();

  SeS("Obj2").DoAction();

...

}

 

See Also

Object Learning
Playback