This topic explains how to exercise greater control over the way that Virtualize record Web web scenarios.
You to customize the clickable elements that can be recorded during scenario recording. The scripts to modify are located in the following directories:
For Chrome:
<Installation_Directory>/eclipse/plugins/com.parasoft.xtest.libs.web_<version>/root/browsers/chrome/UserCustomizableOptions.js
For Internet Explorer:
<Installation_Directory>/plugins/com.parasoft.xtest.libs.web_<version>/root/browsers/i.e./UserCustomizableOptions.js
For Firefox:
<Installation_Directory>/eclipse/plugins/com.parasoft.xtest.libs.web_<version>/root/browsers/ff/user.js
Virtualize use the array variables defined in UserCustomizableOptions.js (or user.js, for Firefox) during recording. The following are the variables currently available in this script; note that variables names for UserCustomizableOptions.js are listed first, followed by the user.js equivalent in parentheses:
_wk_Recorder.clickableAttributes: This variable defines the type of attribute of HTML elements that Virtualize is looking for when determining if it should record a click on this element. For example, the onclick is used to initiate script execution and is a good candidate in this array.
_wk_Recorder.clickableTags: This variable defines the HTML tags that will be considered when recording click actions. In an Ajax web application, there are cases where tags such as span or li are clicked that caused certain functionalities to execute on the client side. This variable is used to define such tags.
_wk_Recorder.clickableInputTypes: This variable defines the form input types that will be considered when recording clicks. Types such as text and textarea are not considered clickable by default because the user usually clicks on it just to gain focus and enter text.
_wk_Recorder.structuralTags and _wk_Recorder.containerTags: The following two variables work together to limit cases for which user actions are recorded against elements. User actions are not recorded for elements named in the former variable if those elements have at least one child element (either direct or indirect) that is specified in the latter variable.
For example, click actions on div elements are normally recorded, but sometimes a div element might not be used as a UI element. The element may be used as a container element that contains a number of other elements (e.g., it could contain a table that contains many other elements). In this case, a click action could potentially be recorded against the container div that contains the table. You might not want a click action recorded in this case, though, because the div is used as a container element and not as a lower-level UI element. To tell Virtualize not to record the click action against the div in cases where the div contains a table element, you would ensure that the
_wk_Recorder.structuralTags
array (or equivalent) contains "div" and that the_wk_Recorder.containerTags
array (or equivalent) contains "table".
_wk_Recorder.disallowedTags: This variable contains a list of tags that will never be recorded, even if they satisfy other recording criteria.
_wk_LocatorBuilders.order: This variable defines the order used to create the locator. A locator is created to identify the html element on the page that the user action should take place. It is needed during playback to repeat the user action. The order is constructed such that visual attributes in an element are more favorable when creating the locator.
To see which locator builder is used, enable debugging information in the console
(Parasoft> Preferences> Browser> Print debugging information). With this enabled, the console will show messages such asLocator - /descendant::img[@id='changeing'][1]. Used id builder
.
This tells you what locator from LocatorBuilders.order is actually used (in the above example,Used id builder
is used). See Browser Settings for more information about this option._wk_LocatorBuilders.preferredAttributesOrder: This field is used by the locator builders 'attributesXPath' and 'attributesXPathWithIndex' from the above
_wk_LocatorBuilders.order.
When invoked, this array determines the preferred attributes used. You can add, remove, or reorder attribute names to this array to better customize the locators that get built for elements on your site. Removing an attribute will prevent it from being used by the aforementioned locator builders (which may be important if you know certain attributes on your web page are dynamic and should never be used). Re-ordering the attributes will change the priority of the attributes. The first attributes of the array, like 'id', take precedence to be used in locators over the last elements
_wk_PageController.xpathLibrary: This variable lets you configure Virtualize to use a specific XPath library for resolving XPath locators used in web scenarios. It applies only to Internet Explorer and Chrome. This option has three possible values: ajaxlt, wgxpath, and default.
- ajaxlt: Uses the Google Ajaxlt XPath implementation: http://code.google.com/p/ajaxslt/
javascript-xpath: Uses Cybozu Labs Javascript-XPath implementation: http://codereposorg/share/wiki/JavaScript-XPath
- default: Uses the default implementation (currently, Wicked Good XPath).