Target property

The target, while not an action on its own, is an important property used by most of the GSLv2 actions. The target consists of the target window and a list of locators. The locator specifies the page element with which an action should interact.

targetWindow

The target window references the window and/or frame containing the element.

The GSLv2 model accepts target windows using the following syntax:

 gomez_top[window_index].frames[frame_index]

The window_index and frame_index share a numeric value corresponding to the respective window or frame index in the page DOM.

Locators

The list of locators consists of one or more CSS selectors or JavaScript DOM references.

If you have written CSS styles or JQuery selectors, the syntax for the CSS locator will be familiar. This is a standard syntax for identifying HTML elements by their attributes.

CSS locators cannot be used across frame boundaries.

The browser agents use the Sizzle selector library, which is a component of the jQuery JavaScript library. The jQuery documentation is the definitive guide to the selectors that you can use. The documentation is available at http://api.jquery.com/category/selectors/.

The W3C also has a good online reference for CSS locator syntax: http://www.w3.org/TR/CSS2/selector.html.

You can use Firebug, a Firefox tool, to verify or write locators. Use the inspect feature to highlight and find the code for an element. In some cases, the Style section of Firebug shows the relevant CSS styles for the element, including the CSS selector used to identify the element for styling purposes. In some cases, you can use that selector as your locator. Sometimes, however, it may not be specific enough for scripting purposes and you should write your own selector. You can download Firebug from http://getfirebug.com/.

The FirePath extension integrates into Firebug. It enables you to evaluate locators using the Sizzle library on selected web pages. This enables you to test CSS locator syntax against the page itself. You can obtain Firepath from https://addons.mozilla.org/en-US/firefox/addon/firepath/.

If the application does not work in Firefox or is different in Internet Explorer, you can use the IE Developer toolbar, the IE equivalent of Firebug. It is available for free from Microsoft. It has a feature similar to Firebug's inspect feature with which you can select to highlight and show details for an element. It also shows the style information, but you need to right-click an element and select Trace Style to see the CSS selector.